RB1_023.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 RB1_023 : 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.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsCardName("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] Suspend 1 of your opponent's Digimon with DP less than or equal to this Digimon's DP. Digimon suspended by this effect don't unsuspend until the end of your opponent's turn.";
  30. }
  31. bool CanSelectPermanentCondition(Permanent permanent)
  32. {
  33. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (permanent.DP <= card.PermanentOfThisCard().DP)
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  61. {
  62. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  63. {
  64. int maxCount = 1;
  65. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) < maxCount)
  66. {
  67. maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition);
  68. }
  69. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents())
  70. {
  71. permanent.oldIsTapped_playCard = permanent.IsSuspended;
  72. }
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: null,
  83. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  84. mode: SelectPermanentEffect.Mode.Tap,
  85. cardEffect: activateClass);
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  88. {
  89. foreach (Permanent selectedPermanent in permanents)
  90. {
  91. if (selectedPermanent != null)
  92. {
  93. if (selectedPermanent.IsSuspended)
  94. {
  95. if (!selectedPermanent.oldIsTapped_playCard)
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  98. targetPermanent: selectedPermanent,
  99. activateClass: activateClass
  100. ));
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. if (timing == EffectTiming.None)
  110. {
  111. AddSkillClass addSkillClass = new AddSkillClass();
  112. addSkillClass.SetUpICardEffect("This Digimon gains all effects of [Gammamon] in digivolution cards", CanUseCondition, card);
  113. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  114. cardEffects.Add(addSkillClass);
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleArea(card);
  118. }
  119. bool PermanentCondition(Permanent permanent)
  120. {
  121. return permanent == card.PermanentOfThisCard();
  122. }
  123. bool CardSourceCondition(CardSource cardSource)
  124. {
  125. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  126. {
  127. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  128. {
  129. return true;
  130. }
  131. }
  132. return false;
  133. }
  134. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  135. {
  136. if (CardSourceCondition(cardSource))
  137. {
  138. foreach (CardSource cardSource1 in cardSource.PermanentOfThisCard().DigivolutionCards)
  139. {
  140. if (cardSource1.ContainsCardName("Gammamon"))
  141. {
  142. foreach (ICardEffect cardEffect in cardSource1.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(_timing, card))
  143. {
  144. if (!cardEffect.IsSecurityEffect && !cardEffect.IsInheritedEffect)
  145. {
  146. cardEffects.Add(cardEffect);
  147. }
  148. }
  149. }
  150. }
  151. }
  152. return cardEffects;
  153. }
  154. }
  155. if (timing == EffectTiming.None)
  156. {
  157. AddSkillClass addSkillClass = new AddSkillClass();
  158. addSkillClass.SetUpICardEffect("This Digimon gains all effects of [Gammamon] in digivolution cards", CanUseCondition, card);
  159. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  160. addSkillClass.SetIsInheritedEffect(true);
  161. cardEffects.Add(addSkillClass);
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.IsExistOnBattleArea(card);
  165. }
  166. bool PermanentCondition(Permanent permanent)
  167. {
  168. return permanent == card.PermanentOfThisCard();
  169. }
  170. bool CardSourceCondition(CardSource cardSource)
  171. {
  172. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  173. {
  174. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  182. {
  183. if (CardSourceCondition(cardSource))
  184. {
  185. foreach (CardSource cardSource1 in cardSource.PermanentOfThisCard().DigivolutionCards)
  186. {
  187. if (cardSource1.ContainsCardName("Gammamon"))
  188. {
  189. foreach (ICardEffect cardEffect in cardSource1.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(_timing, card))
  190. {
  191. if (!cardEffect.IsSecurityEffect && !cardEffect.IsInheritedEffect)
  192. {
  193. cardEffects.Add(cardEffect);
  194. }
  195. }
  196. }
  197. }
  198. }
  199. return cardEffects;
  200. }
  201. }
  202. return cardEffects;
  203. }
  204. }