BT7_077.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 BT7_077 : 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.OnDiscardHand)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "When you trash this card in your hand using one of your effects, gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. bool SkillCondition(ICardEffect cardEffect)
  26. {
  27. if (cardEffect != null)
  28. {
  29. if (cardEffect.EffectSourceCard != null)
  30. {
  31. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. return CardEffectCommons.CanTriggerOnTrashSelfHand(hashtable, SkillCondition, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnTrash(card))
  44. {
  45. if (card.Owner.CanAddMemory(activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  55. }
  56. }
  57. if (timing == EffectTiming.OnEnterFieldAnyone)
  58. {
  59. ActivateClass activateClass = new ActivateClass();
  60. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 level 4 or lower Digimon", CanUseCondition, card);
  61. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  62. cardEffects.Add(activateClass);
  63. string EffectDiscription()
  64. {
  65. return "[When Digivolving] You may trash 1 card in your hand to delete 1 of your opponent's level 4 or lower Digimon.";
  66. }
  67. bool CanSelectPermanentCondition(Permanent permanent)
  68. {
  69. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  70. {
  71. if (permanent.Level <= 4)
  72. {
  73. if (permanent.TopCard.HasLevel)
  74. {
  75. return true;
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  84. }
  85. bool CanActivateCondition(Hashtable hashtable)
  86. {
  87. if (CardEffectCommons.IsExistOnBattleArea(card))
  88. {
  89. if (card.Owner.HandCards.Count >= 1)
  90. {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  97. {
  98. if (isExistOnField(card))
  99. {
  100. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  101. {
  102. if (card.Owner.HandCards.Count >= 1)
  103. {
  104. bool discarded = false;
  105. int discardCount = 1;
  106. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  107. selectHandEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: (cardSource) => true,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: discardCount,
  113. canNoSelect: true,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. selectCardCoroutine: null,
  117. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  118. mode: SelectHandEffect.Mode.Discard,
  119. cardEffect: activateClass);
  120. yield return StartCoroutine(selectHandEffect.Activate());
  121. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  122. {
  123. if (cardSources.Count >= 1)
  124. {
  125. discarded = true;
  126. yield return null;
  127. }
  128. }
  129. if (discarded)
  130. {
  131. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  132. {
  133. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  134. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: CanSelectPermanentCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: CanEndSelectCondition,
  140. maxCount: maxCount,
  141. canNoSelect: false,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: null,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Destroy,
  146. cardEffect: activateClass);
  147. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  148. bool CanEndSelectCondition(List<Permanent> permanents)
  149. {
  150. if (permanents.Count <= 0)
  151. {
  152. return false;
  153. }
  154. return true;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. return cardEffects;
  164. }
  165. }