BT8_091.cs 8.6 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 BT8_091 : 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("Hatch a Digiegg", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may hatch 1 Digi-Egg card to an empty space in your breeding area.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.CanHatch)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(new HatchDigiEggClass(player: card.Owner, hashtable: CardEffectCommons.CardEffectHashtable(activateClass)).Hatch());
  41. }
  42. }
  43. if (timing == EffectTiming.BeforePayCost)
  44. {
  45. ActivateClass activateClass = new ActivateClass();
  46. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  47. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  48. activateClass.SetHashString("DigivoltuionCost-1_BT8_0915");
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[Your Turn] When one of your Digimon would digivolve into a Digimon with [Gargomon] or [Rapidmon] in its name, you may suspend this Tamer to reduce the digivolution cost by 1.";
  53. }
  54. bool PermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  57. }
  58. bool CardCondition(CardSource cardSource)
  59. {
  60. if (cardSource.IsDigimon)
  61. {
  62. if (cardSource.ContainsCardName("Gargomon"))
  63. {
  64. return true;
  65. }
  66. if (cardSource.ContainsCardName("Rapidmon"))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. if (CardEffectCommons.IsOwnerTurn(card))
  78. {
  79. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.IsExistOnBattleArea(card))
  90. {
  91. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  99. {
  100. if (isExistOnField(card))
  101. {
  102. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  103. {
  104. Hashtable hashtable = new Hashtable();
  105. hashtable.Add("CardEffect", activateClass);
  106. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, hashtable).Tap());
  107. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  108. ChangeCostClass changeCostClass = new ChangeCostClass();
  109. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  110. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  111. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  113. bool CanUseCondition1(Hashtable hashtable)
  114. {
  115. return true;
  116. }
  117. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  118. {
  119. if (CardSourceCondition(cardSource))
  120. {
  121. if (RootCondition(root))
  122. {
  123. if (PermanentsCondition(targetPermanents))
  124. {
  125. Cost -= 1;
  126. }
  127. }
  128. }
  129. return Cost;
  130. }
  131. bool PermanentsCondition(List<Permanent> targetPermanents)
  132. {
  133. if (targetPermanents != null)
  134. {
  135. if (targetPermanents.Count(PermanentCondition) >= 1)
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. bool PermanentCondition(Permanent targetPermanent)
  143. {
  144. if (targetPermanent.TopCard != null)
  145. {
  146. if (targetPermanent.TopCard.Owner == card.Owner)
  147. {
  148. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  149. {
  150. return true;
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CardSourceCondition(CardSource cardSource)
  157. {
  158. if (cardSource != null)
  159. {
  160. if (cardSource.Owner == card.Owner)
  161. {
  162. if (cardSource.ContainsCardName("Gargomon"))
  163. {
  164. return true;
  165. }
  166. if (cardSource.ContainsCardName("Rapidmon"))
  167. {
  168. return true;
  169. }
  170. }
  171. }
  172. return false;
  173. }
  174. bool RootCondition(SelectCardEffect.Root root)
  175. {
  176. return true;
  177. }
  178. bool isUpDown()
  179. {
  180. return true;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. if (timing == EffectTiming.SecuritySkill)
  187. {
  188. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  189. }
  190. return cardEffects;
  191. }
  192. }