BT5_079.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 BT5_079 : 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.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 level 3 Digimon from trash", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] <Digi-Burst 3> (Trash 3 of this Digimon's Digivolution cards to activate the effect below.) - You may play 1 level 3 purple Digimon card from your trash without paying its memory cost. Any [On Play] effects on Digimon played with this effect don't activate.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.IsDigimon)
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (cardSource.IsDigimon)
  32. {
  33. if (cardSource.HasCardColor(CardColor.Purple))
  34. {
  35. if (cardSource.Level == 3)
  36. {
  37. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  38. {
  39. if (cardSource.HasLevel)
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (new IDigiBurst(card.PermanentOfThisCard(), 3, activateClass).CanDigiBurst())
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(new IDigiBurst(card.PermanentOfThisCard(), 3, activateClass).DigiBurst());
  66. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  67. {
  68. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  69. List<CardSource> selectedCards = new List<CardSource>();
  70. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  71. selectCardEffect.SetUp(
  72. canTargetCondition: CanSelectCardCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. canNoSelect: () => true,
  76. selectCardCoroutine: SelectCardCoroutine,
  77. afterSelectCardCoroutine: null,
  78. message: "Select 1 card to play.",
  79. maxCount: maxCount,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. mode: SelectCardEffect.Mode.Custom,
  83. root: SelectCardEffect.Root.Trash,
  84. customRootCardList: null,
  85. canLookReverseCard: true,
  86. selectPlayer: card.Owner,
  87. cardEffect: activateClass);
  88. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  89. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  90. yield return StartCoroutine(selectCardEffect.Activate());
  91. IEnumerator SelectCardCoroutine(CardSource cardSource)
  92. {
  93. selectedCards.Add(cardSource);
  94. yield return null;
  95. }
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  97. cardSources: selectedCards,
  98. activateClass: activateClass,
  99. payCost: false,
  100. isTapped: false,
  101. root: SelectCardEffect.Root.Trash,
  102. activateETB: false));
  103. }
  104. }
  105. }
  106. if (timing == EffectTiming.OnAllyAttack)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Delete your Digimon and unsuspend this Digimon", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  111. activateClass.SetIsInheritedEffect(true);
  112. activateClass.SetHashString("Unsuspend_BT5_079");
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[When Attacking][Once Per Turn] You may delete 1 of your other Digimon to unsuspend this Digimon.";
  117. }
  118. bool CanSelectPermanentCondition(Permanent permanent)
  119. {
  120. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  121. {
  122. if (permanent != card.PermanentOfThisCard())
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  132. }
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.IsExistOnBattleArea(card))
  136. {
  137. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  145. {
  146. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  147. {
  148. int maxCount = Math.Min(1, card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  149. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  150. selectPermanentEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectPermanentCondition,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: maxCount,
  156. canNoSelect: true,
  157. canEndNotMax: false,
  158. selectPermanentCoroutine: SelectPermanentCoroutine,
  159. afterSelectPermanentCoroutine: null,
  160. mode: SelectPermanentEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  163. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  164. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  165. {
  166. Permanent thisCardPermanent = card.PermanentOfThisCard();
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  168. IEnumerator SuccessProcess()
  169. {
  170. if (thisCardPermanent.TopCard != null)
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { thisCardPermanent }, activateClass).Unsuspend());
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. return cardEffects;
  180. }
  181. }