BT3_103.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 BT3_103 : 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.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] The next time one of your green Digimon digivolves this turn, you may suspend 1 of your Digimon to reduce the memory cost of the digivolution by 5.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  28. {
  29. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  30. yield return new WaitForSeconds(0.2f);
  31. ActivateClass activateClass1 = new ActivateClass();
  32. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  33. activateClass1.SetUpICardEffect("Digivolution Cost -5", CanUseCondition1, card);
  34. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDiscription1());
  35. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect);
  36. ActivateClass activateClass2 = new ActivateClass();
  37. Func<EffectTiming, ICardEffect> getCardEffect1 = GetCardEffect1;
  38. activateClass2.SetUpICardEffect("Remove Effect", CanUseCondition1, card);
  39. activateClass2.SetUpActivateClass(null, ActivateCoroutine2, -1, false, "");
  40. activateClass2.SetIsBackgroundProcess(true);
  41. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect1);
  42. string EffectDiscription1()
  43. {
  44. return "You may suspend 1 of your Digimon to reduce the memory cost of the digivolution by 5.";
  45. }
  46. bool PermanentCondition(Permanent targetPermanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card))
  49. {
  50. if (targetPermanent.TopCard.CardColors.Contains(CardColor.Green))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanSelectPermanentCondition(Permanent permanent)
  58. {
  59. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  60. {
  61. if (CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard))
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanUseCondition1(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  71. hashtable: hashtable,
  72. permanentCondition: PermanentCondition,
  73. cardCondition: null))
  74. {
  75. return true;
  76. }
  77. return false;
  78. }
  79. bool CanActivateCondition1(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  82. {
  83. return true;
  84. }
  85. return false;
  86. }
  87. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  88. {
  89. int maxCount = 1;
  90. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CanSelectPermanentCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: true,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: null,
  100. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  101. mode: SelectPermanentEffect.Mode.Tap,
  102. cardEffect: activateClass1);
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  105. {
  106. yield return null;
  107. if (permanents.Count >= 1)
  108. {
  109. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  110. ChangeCostClass changeCostClass = new ChangeCostClass();
  111. changeCostClass.SetUpICardEffect("Digivolution Cost -5", CanUseCondition1, card);
  112. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  113. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable1));
  114. bool CanUseCondition1(Hashtable hashtable)
  115. {
  116. return true;
  117. }
  118. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  119. {
  120. if (CardSourceCondition(cardSource))
  121. {
  122. if (RootCondition(root))
  123. {
  124. if (PermanentsCondition(targetPermanents))
  125. {
  126. Cost -= 5;
  127. }
  128. }
  129. }
  130. return Cost;
  131. }
  132. bool PermanentsCondition(List<Permanent> targetPermanents)
  133. {
  134. if (targetPermanents != null)
  135. {
  136. if (targetPermanents.Count(PermanentCondition) >= 1)
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. bool PermanentCondition(Permanent targetPermanent)
  144. {
  145. return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent);
  146. }
  147. bool CardSourceCondition(CardSource cardSource)
  148. {
  149. return true;
  150. }
  151. bool RootCondition(SelectCardEffect.Root root)
  152. {
  153. return true;
  154. }
  155. bool isUpDown()
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. }
  162. ICardEffect GetCardEffect(EffectTiming _timing)
  163. {
  164. if (_timing == EffectTiming.BeforePayCost)
  165. {
  166. return activateClass1;
  167. }
  168. return null;
  169. }
  170. IEnumerator ActivateCoroutine2(Hashtable _hashtable1)
  171. {
  172. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  173. hashtable: _hashtable1,
  174. permanentCondition: PermanentCondition,
  175. cardCondition: null))
  176. {
  177. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect);
  178. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect1);
  179. yield return null;
  180. }
  181. }
  182. ICardEffect GetCardEffect1(EffectTiming _timing)
  183. {
  184. if (_timing == EffectTiming.AfterPayCost)
  185. {
  186. return activateClass2;
  187. }
  188. return null;
  189. }
  190. }
  191. }
  192. if (timing == EffectTiming.SecuritySkill)
  193. {
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  197. activateClass.SetIsSecurityEffect(true);
  198. cardEffects.Add(activateClass);
  199. string EffectDiscription()
  200. {
  201. return "[Security] Add this card to its owner's hand.";
  202. }
  203. bool CanUseCondition(Hashtable hashtable)
  204. {
  205. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  206. }
  207. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  210. }
  211. }
  212. return cardEffects;
  213. }
  214. }