BT9_018.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 BT9_018 : 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("Suspend Digimon and gain Memory", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] For each Tamer your opponent has in play, suspend 1 of your opponent's Digimon and gain 1 memory.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.CanSelectBySkill(activateClass))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleArea(card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (card.Owner.Enemy.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer) >= 1)
  45. {
  46. int tamerCount = card.Owner.Enemy.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. int maxCount = Math.Min(tamerCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: CanSelectPermanentCondition,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: maxCount,
  57. canNoSelect: false,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: null,
  60. afterSelectPermanentCoroutine: null,
  61. mode: SelectPermanentEffect.Mode.Tap,
  62. cardEffect: activateClass);
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. }
  65. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(tamerCount, activateClass));
  66. }
  67. }
  68. }
  69. if (timing == EffectTiming.OnTappedAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Delete 1 suspended Digimon", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  74. activateClass.SetHashString("Delete_BT9_018");
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[All Turns][Once Per Turn] When an opponent's Digimon with 6000 DP or less becomes suspended, you may delete that Digimon.";
  79. }
  80. bool PermanentCondition(Permanent permanent)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.DP <= 6000)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.IsExistOnBattleArea(card))
  94. {
  95. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleArea(card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleArea(card))
  109. {
  110. if (_hashtable != null)
  111. {
  112. if (_hashtable.ContainsKey("Permanents"))
  113. {
  114. if (_hashtable["Permanents"] is List<Permanent>)
  115. {
  116. List<Permanent> Permanents = (List<Permanent>)_hashtable["Permanents"];
  117. if (Permanents != null)
  118. {
  119. bool CanSelectPermanentCondition(Permanent permanent)
  120. {
  121. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  122. {
  123. if (Permanents.Contains(permanent))
  124. {
  125. if (permanent.DPWhenSuspended <= 6000)
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  134. {
  135. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectPermanentCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: false,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: null,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Destroy,
  148. cardEffect: activateClass);
  149. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. return cardEffects;
  159. }
  160. }