BT8_105.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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_105 : 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. int maxCost = 15;
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] Choose any number of your opponent's Digimon whose play costs add up to 15 or less and delete them.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  27. {
  28. if (permanent.TopCard.GetCostItself <= maxCost)
  29. {
  30. if (permanent.TopCard.HasPlayCost)
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  45. {
  46. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition);
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  52. canEndSelectCondition: CanEndSelectCondition,
  53. maxCount: maxCount,
  54. canNoSelect: false,
  55. canEndNotMax: true,
  56. selectPermanentCoroutine: null,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Destroy,
  59. cardEffect: activateClass);
  60. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  61. bool CanEndSelectCondition(List<Permanent> permanents)
  62. {
  63. if (CardEffectCommons.HasNoElement(permanents))
  64. {
  65. return false;
  66. }
  67. int sumCost = 0;
  68. foreach (Permanent permanent1 in permanents)
  69. {
  70. sumCost += permanent1.TopCard.GetCostItself;
  71. }
  72. if (sumCost > maxCost)
  73. {
  74. return false;
  75. }
  76. return true;
  77. }
  78. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  79. {
  80. int sumCost = 0;
  81. foreach (Permanent permanent1 in permanents)
  82. {
  83. sumCost += permanent1.TopCard.GetCostItself;
  84. }
  85. sumCost += permanent.TopCard.GetCostItself;
  86. if (sumCost > maxCost)
  87. {
  88. return false;
  89. }
  90. return true;
  91. }
  92. }
  93. }
  94. }
  95. if (timing == EffectTiming.SecuritySkill)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect($"Delete 1 Digimon with 15 or less Cost", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  100. activateClass.SetIsSecurityEffect(true);
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[Security] Delete 1 of your opponent's Digimon with a play cost of 15 or less.";
  105. }
  106. bool CanSelectPermanentCondition(Permanent permanent)
  107. {
  108. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  109. {
  110. if (permanent.TopCard.GetCostItself <= 15)
  111. {
  112. if (permanent.TopCard.HasPlayCost)
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  125. {
  126. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  127. {
  128. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  129. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  130. selectPermanentEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanSelectPermanentCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: maxCount,
  136. canNoSelect: false,
  137. canEndNotMax: false,
  138. selectPermanentCoroutine: null,
  139. afterSelectPermanentCoroutine: null,
  140. mode: SelectPermanentEffect.Mode.Destroy,
  141. cardEffect: activateClass);
  142. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  143. }
  144. }
  145. }
  146. return cardEffects;
  147. }
  148. }