EX5_029.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class EX5_029 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash the top card of your security to reduce digivolution cost", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] By trashing the top card of your security stack, for the turn, when one of your Digimon would next digivolve, reduce the digivolution cost by 2.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.SecurityCards.Count >= 1)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  41. player: card.Owner,
  42. destroySecurityCount: 1,
  43. cardEffect: activateClass,
  44. fromTop: true).DestroySecurity());
  45. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  46. ChangeCostClass changeCostClass = new ChangeCostClass();
  47. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  48. changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
  49. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  50. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect);
  51. ActivateClass activateClass1 = new ActivateClass();
  52. Func<EffectTiming, ICardEffect> getCardEffect1 = GetCardEffect1;
  53. activateClass1.SetUpICardEffect("Remove Effect", CanUseCondition1, card);
  54. activateClass1.SetUpActivateClass(null, ActivateCoroutine1, -1, false, "");
  55. activateClass1.SetIsBackgroundProcess(true);
  56. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect1);
  57. bool CanUseCondition1(Hashtable hashtable)
  58. {
  59. return true;
  60. }
  61. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  62. {
  63. if (CardSourceCondition(cardSource))
  64. {
  65. if (RootCondition(root))
  66. {
  67. if (PermanentsCondition(targetPermanents))
  68. {
  69. Cost -= 2;
  70. }
  71. }
  72. }
  73. return Cost;
  74. }
  75. bool PermanentsCondition(List<Permanent> targetPermanents)
  76. {
  77. if (targetPermanents != null)
  78. {
  79. if (targetPermanents.Count(PermanentCondition) >= 1)
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. bool PermanentCondition(Permanent targetPermanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  89. }
  90. bool CardSourceCondition(CardSource cardSource)
  91. {
  92. return true;
  93. }
  94. bool RootCondition(SelectCardEffect.Root root)
  95. {
  96. return true;
  97. }
  98. bool isUpDown()
  99. {
  100. return true;
  101. }
  102. ICardEffect GetCardEffect(EffectTiming _timing)
  103. {
  104. return changeCostClass;
  105. }
  106. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  107. {
  108. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  109. hashtable: _hashtable1,
  110. permanentCondition: PermanentCondition,
  111. cardCondition: CardSourceCondition))
  112. {
  113. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect);
  114. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect1);
  115. yield return null;
  116. }
  117. }
  118. ICardEffect GetCardEffect1(EffectTiming _timing)
  119. {
  120. if (_timing == EffectTiming.AfterPayCost)
  121. {
  122. return activateClass1;
  123. }
  124. return null;
  125. }
  126. }
  127. }
  128. if (timing == EffectTiming.OnAllyAttack)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("DP -2000", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  133. activateClass.SetIsInheritedEffect(true);
  134. activateClass.SetHashString("DP-2000_EX5_029");
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[When Attacking] [Once Per Turn] If there're 6 or fewer total cards in both players' security stacks, 1 of your opponent's Digimon gets -2000 DP for the turn.";
  139. }
  140. bool CanSelectPermanentCondition(Permanent permanent)
  141. {
  142. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.IsExistOnBattleArea(card))
  151. {
  152. if (card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count <= 6)
  153. {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  160. {
  161. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  162. {
  163. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  164. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  165. selectPermanentEffect.SetUp(
  166. selectPlayer: card.Owner,
  167. canTargetCondition: CanSelectPermanentCondition,
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. maxCount: maxCount,
  171. canNoSelect: false,
  172. canEndNotMax: false,
  173. selectPermanentCoroutine: SelectPermanentCoroutine,
  174. afterSelectPermanentCoroutine: null,
  175. mode: SelectPermanentEffect.Mode.Custom,
  176. cardEffect: activateClass);
  177. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  178. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  179. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  182. targetPermanent: permanent,
  183. changeValue: -2000,
  184. effectDuration: EffectDuration.UntilEachTurnEnd,
  185. activateClass: activateClass));
  186. }
  187. }
  188. }
  189. }
  190. return cardEffects;
  191. }
  192. }