BT2_020.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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_020 : 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("Delete 1 Digimon with 6000 DP or less", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] If you have a red Tamer in play, delete 1 of your opponent's Digimon with 6000 DP or less.";
  22. }
  23. bool PermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  26. {
  27. if (permanent.IsTamer)
  28. {
  29. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  40. {
  41. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: false,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: null,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Destroy,
  83. cardEffect: activateClass);
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. }
  86. }
  87. }
  88. if (timing == EffectTiming.OnAllyAttack)
  89. {
  90. int count()
  91. {
  92. return card.Owner.Enemy.TrashCards.Count / 10;
  93. }
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect($"Trash {count()} cards of opponent's security", CanUseCondition, card);
  96. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  97. cardEffects.Add(activateClass);
  98. string EffectDiscription()
  99. {
  100. return "[When Attacking] Trash 1 of your opponent's security cards for every 10 cards in their trash.";
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  105. }
  106. bool CanActivateCondition(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleArea(card))
  109. {
  110. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  111. {
  112. if (count() >= 1)
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  123. player: card.Owner.Enemy,
  124. destroySecurityCount: count(),
  125. cardEffect: activateClass,
  126. fromTop: true).DestroySecurity());
  127. }
  128. }
  129. return cardEffects;
  130. }
  131. }