Megadramon_BT9_065.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 Megadramon_BT9_065 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Delete 1 Digimon or a Tamer with 3 or less Cost", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Delete 1 of your opponent's Digimon or Tamers with a play cost of 3 or less.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (permanent != null)
  26. {
  27. if (permanent.TopCard != null)
  28. {
  29. if (permanent.TopCard.Owner == card.Owner.Enemy)
  30. {
  31. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  32. {
  33. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 3)
  34. {
  35. if (permanent.IsDigimon)
  36. {
  37. return true;
  38. }
  39. if (permanent.IsTamer)
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Destroy,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. }
  85. }
  86. }
  87. if (timing == EffectTiming.OnAllyAttack)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Delete 1 Digimon or a Tamer with 3 or less Cost", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  92. activateClass.SetIsInheritedEffect(true);
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[When Attacking] If this Digimon has [Machine] or [Dragonkin] in its traits, delete 1 of your opponent's Digimon or Tamers with a play cost of 3 or less.";
  97. }
  98. bool CanSelectPermanentCondition(Permanent permanent)
  99. {
  100. if (permanent != null)
  101. {
  102. if (permanent.TopCard != null)
  103. {
  104. if (permanent.TopCard.Owner == card.Owner.Enemy)
  105. {
  106. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  107. {
  108. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 3)
  109. {
  110. if (permanent.IsDigimon)
  111. {
  112. return true;
  113. }
  114. if (permanent.IsTamer)
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. return false;
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  128. }
  129. bool CanActivateCondition(Hashtable hashtable)
  130. {
  131. if (isExistOnField(card))
  132. {
  133. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Machine"))
  138. {
  139. return true;
  140. }
  141. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Dragonkin"))
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. }
  148. return false;
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  151. {
  152. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  153. {
  154. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  155. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  156. selectPermanentEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectPermanentCondition,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: false,
  163. canEndNotMax: false,
  164. selectPermanentCoroutine: null,
  165. afterSelectPermanentCoroutine: null,
  166. mode: SelectPermanentEffect.Mode.Destroy,
  167. cardEffect: activateClass);
  168. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  169. }
  170. }
  171. }
  172. return cardEffects;
  173. }
  174. }