Decoy.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 [Decoy]
  9. public static bool CanActivateDecoy(Permanent permanent, ICardEffect activateClass)
  10. {
  11. if (IsPermanentExistsOnBattleArea(permanent))
  12. {
  13. if (permanent.CanBeDestroyedBySkill(activateClass))
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. #endregion
  21. #region Effect process of [Decoy]
  22. public static IEnumerator DecoyProcess(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. yield return ContinuousController.instance.StartCoroutine(DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  28. IEnumerator SuccessProcess()
  29. {
  30. if (HasMatchConditionPermanent(CanSelectPermanentCondition))
  31. {
  32. int maxCount = Math.Min(1, MatchConditionPermanentCount(CanSelectPermanentCondition));
  33. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  34. selectPermanentEffect.SetUp(
  35. selectPlayer: owner,
  36. canTargetCondition: CanSelectPermanentCondition,
  37. canTargetCondition_ByPreSelecetedList: null,
  38. canEndSelectCondition: null,
  39. maxCount: maxCount,
  40. canNoSelect: false,
  41. canEndNotMax: false,
  42. selectPermanentCoroutine: SelectPermanentCoroutine,
  43. afterSelectPermanentCoroutine: null,
  44. mode: SelectPermanentEffect.Mode.Custom,
  45. cardEffect: activateClass);
  46. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to prevent deletion.", "The opponent is selecting 1 Digimon to prevent deletion.");
  47. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  48. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  49. {
  50. permanent.willBeRemoveField = false;
  51. permanent.HideDeleteEffect();
  52. yield return null;
  53. }
  54. }
  55. }
  56. }
  57. #endregion
  58. }