BT8_070.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 BT8_070 : 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 Digimon and Tamers", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] If this Digimon has a red digivolution card, choose any number of your opponent's Digimon. If this Digimon has a black digivolution card, choose any number of your opponent's Tamers. The chosen cards' play costs must add up to 6 or less. Delete the chosen cards.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  26. {
  27. if (permanent.TopCard.GetCostItself <= 6)
  28. {
  29. if (permanent.TopCard.HasPlayCost)
  30. {
  31. if (isExistOnField(card))
  32. {
  33. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Red)) >= 1)
  34. {
  35. if (permanent.IsDigimon)
  36. {
  37. return true;
  38. }
  39. }
  40. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Black)) >= 1)
  41. {
  42. if (permanent.IsTamer)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition);
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  76. canEndSelectCondition: CanEndSelectCondition,
  77. maxCount: maxCount,
  78. canNoSelect: false,
  79. canEndNotMax: true,
  80. selectPermanentCoroutine: null,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Destroy,
  83. cardEffect: activateClass);
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. bool CanEndSelectCondition(List<Permanent> permanents)
  86. {
  87. if (CardEffectCommons.HasNoElement(permanents))
  88. {
  89. return false;
  90. }
  91. int sumCost = 0;
  92. foreach (Permanent permanent1 in permanents)
  93. {
  94. sumCost += permanent1.TopCard.GetCostItself;
  95. }
  96. if (sumCost > 6)
  97. {
  98. return false;
  99. }
  100. return true;
  101. }
  102. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  103. {
  104. int sumCost = 0;
  105. foreach (Permanent permanent1 in permanents)
  106. {
  107. sumCost += permanent1.TopCard.GetCostItself;
  108. }
  109. sumCost += permanent.TopCard.GetCostItself;
  110. if (sumCost > 6)
  111. {
  112. return false;
  113. }
  114. return true;
  115. }
  116. }
  117. }
  118. if (timing == EffectTiming.OnDestroyedAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  123. activateClass.SetHashString("Unsuspend_BT8_070");
  124. cardEffects.Add(activateClass);
  125. string EffectDiscription()
  126. {
  127. return "[All Turns][Once Per Turn] When an opponent's Digimon is deleted, you may unsuspend this Digimon.";
  128. }
  129. bool PermanentCondition(Permanent permanent)
  130. {
  131. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.IsExistOnBattleArea(card))
  136. {
  137. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  149. {
  150. return true;
  151. }
  152. }
  153. return false;
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  156. {
  157. Permanent selectedPermanent = card.PermanentOfThisCard();
  158. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  159. new List<Permanent>() { selectedPermanent },
  160. activateClass).Unsuspend());
  161. }
  162. }
  163. return cardEffects;
  164. }
  165. }