BT2_045.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 BT2_045 : 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.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Digisorption -2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. activateClass.SetHashString("Digisorption-3_BT2_045");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "<Digisorption -2> (When one of your Digimon digivolves into this card from your hand, you may suspend 1 of your Digimon to reduce the memory cost of the digivolution by 2.)";
  23. }
  24. bool CanSelectCondition_CheckAvailability(Permanent permanent)
  25. {
  26. if (card.Owner.CanTapWhenAbsorbEvolution_CheckAvailability(permanent, activateClass))
  27. {
  28. if (permanent.CanSelectBySkill(activateClass))
  29. {
  30. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. if (card.Owner.CanTapWhenAbsorbEvolution(permanent, activateClass))
  41. {
  42. if (permanent.CanSelectBySkill(activateClass))
  43. {
  44. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (hashtable != null)
  55. {
  56. if (hashtable.ContainsKey("Card"))
  57. {
  58. if (hashtable["Card"] is CardSource)
  59. {
  60. CardSource Card = (CardSource)hashtable["Card"];
  61. if (Card == card)
  62. {
  63. if (hashtable.ContainsKey("isEvolution"))
  64. {
  65. if (hashtable["isEvolution"] is bool)
  66. {
  67. bool isEvolution = (bool)hashtable["isEvolution"];
  68. if (isEvolution)
  69. {
  70. if (hashtable.ContainsKey("Permanents"))
  71. {
  72. if (hashtable["Permanents"] is List<Permanent>)
  73. {
  74. List<Permanent> Permanents = (List<Permanent>)hashtable["Permanents"];
  75. if (Permanents != null)
  76. {
  77. if (Permanents.Count((permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent)) >= 1)
  78. {
  79. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. return false;
  95. }
  96. bool CanActivateCondition(Hashtable hashtable)
  97. {
  98. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  99. {
  100. return true;
  101. }
  102. return false;
  103. }
  104. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  105. {
  106. #region
  107. Hashtable hashtable = new Hashtable();
  108. hashtable.Add("CardEffect", activateClass);
  109. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  110. {
  111. #region
  112. foreach (Permanent permanent1 in player.GetFieldPermanents())
  113. {
  114. foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenDigisorption))
  115. {
  116. if (cardEffect is ActivateICardEffect)
  117. {
  118. if (cardEffect.CanTrigger(hashtable))
  119. {
  120. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  121. }
  122. }
  123. }
  124. }
  125. #endregion
  126. #region
  127. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenDigisorption))
  128. {
  129. if (cardEffect is ActivateICardEffect)
  130. {
  131. if (cardEffect.CanTrigger(hashtable))
  132. {
  133. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  134. }
  135. }
  136. }
  137. #endregion
  138. }
  139. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
  140. #endregion
  141. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1) >= 1)
  142. {
  143. int maxCount = 1;
  144. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectPermanentCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: null,
  154. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  155. mode: SelectPermanentEffect.Mode.Tap,
  156. cardEffect: activateClass);
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  159. {
  160. yield return null;
  161. if (permanents.Count >= 1)
  162. {
  163. if (card.Owner.CanReduceCost(new List<Permanent>() { new Permanent(new List<CardSource>()) }, card))
  164. {
  165. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  166. }
  167. ChangeCostClass changeCostClass = new ChangeCostClass();
  168. changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
  169. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  170. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  171. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  172. bool CanUseCondition1(Hashtable hashtable)
  173. {
  174. return true;
  175. }
  176. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  177. {
  178. if (CardSourceCondition(cardSource))
  179. {
  180. if (RootCondition(root))
  181. {
  182. if (PermanentsCondition(targetPermanents))
  183. {
  184. Cost -= 2;
  185. }
  186. }
  187. }
  188. return Cost;
  189. }
  190. bool PermanentsCondition(List<Permanent> targetPermanents)
  191. {
  192. if (targetPermanents != null)
  193. {
  194. if (targetPermanents.Count(PermanentCondition) >= 1)
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool PermanentCondition(Permanent targetPermanent)
  202. {
  203. if (targetPermanent.TopCard != null)
  204. {
  205. if (targetPermanent.TopCard.Owner == card.Owner)
  206. {
  207. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  208. {
  209. return true;
  210. }
  211. }
  212. }
  213. return false;
  214. }
  215. bool CardSourceCondition(CardSource cardSource)
  216. {
  217. if (cardSource != null)
  218. {
  219. if (cardSource == card)
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool RootCondition(SelectCardEffect.Root root)
  227. {
  228. return true;
  229. }
  230. bool isUpDown()
  231. {
  232. return true;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. return cardEffects;
  240. }
  241. }