Scapegoat.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can activate [Scapegoat]
  9. public static bool CanActivateScapegoat(Permanent permanent, Func<Permanent, bool> permanentCondition)
  10. {
  11. if (IsPermanentExistsOnBattleArea(permanent))
  12. {
  13. if (HasMatchConditionPermanent(permanentCondition))
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Scapegoat]
  22. public static IEnumerator ScapegoatProcess(ICardEffect activateClass, Permanent permanent, Func<Permanent, bool> CanSelectPermanentCondition)
  23. {
  24. if (permanent == null) yield break;
  25. if (permanent.TopCard == null) yield break;
  26. Player owner = permanent.TopCard.Owner;
  27. if (HasMatchConditionPermanent(CanSelectPermanentCondition))
  28. {
  29. int maxCount = 1;
  30. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  31. selectPermanentEffect.SetUp(
  32. selectPlayer: owner,
  33. canTargetCondition: CanSelectPermanentCondition,
  34. canTargetCondition_ByPreSelecetedList: null,
  35. canEndSelectCondition: null,
  36. maxCount: maxCount,
  37. canNoSelect: false,
  38. canEndNotMax: false,
  39. selectPermanentCoroutine: SelectPermanentCoroutine,
  40. afterSelectPermanentCoroutine: null,
  41. mode: SelectPermanentEffect.Mode.Custom,
  42. cardEffect: activateClass);
  43. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  44. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  45. IEnumerator SelectPermanentCoroutine(Permanent _permanent)
  46. {
  47. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { _permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  48. IEnumerator SuccessProcess()
  49. {
  50. permanent.willBeRemoveField = false;
  51. permanent.HideDeleteEffect();
  52. yield return null;
  53. }
  54. }
  55. }
  56. }
  57. #endregion
  58. }