BT7_013.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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_013 : 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("Memory +2 or play a Tamer", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] If you have a Tamer in play, gain 2 memory. If you don't have a Tamer in play, you may play 1 red Tamer card from your hand without paying its memory cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsTamer)
  26. {
  27. if (cardSource.HasCardColor(CardColor.Red))
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  46. {
  47. if (card.Owner.CanAddMemory(activateClass))
  48. {
  49. return true;
  50. }
  51. }
  52. else
  53. {
  54. if (card.Owner.HandCards.Count >= 1)
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  69. }
  70. else
  71. {
  72. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  73. {
  74. List<CardSource> selectedCards = new List<CardSource>();
  75. int maxCount = 1;
  76. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  77. selectHandEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectCardCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: true,
  84. canEndNotMax: false,
  85. isShowOpponent: true,
  86. selectCardCoroutine: SelectCardCoroutine,
  87. afterSelectCardCoroutine: null,
  88. mode: SelectHandEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  91. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. IEnumerator SelectCardCoroutine(CardSource cardSource)
  94. {
  95. selectedCards.Add(cardSource);
  96. yield return null;
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  99. }
  100. }
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.OnDestroyedAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  109. activateClass.SetIsInheritedEffect(true);
  110. activateClass.SetHashString("Memory+1_BT7_013");
  111. cardEffects.Add(activateClass);
  112. string EffectDiscription()
  113. {
  114. return "[Your Turn][Once Per Turn] When one of your opponent's Digimon is deleted, gain 1 memory.";
  115. }
  116. bool PermanentCondition(Permanent permanent)
  117. {
  118. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. if (CardEffectCommons.IsOwnerTurn(card))
  125. {
  126. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. bool CanActivateCondition(Hashtable hashtable)
  135. {
  136. if (CardEffectCommons.IsExistOnBattleArea(card))
  137. {
  138. return true;
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  145. }
  146. }
  147. return cardEffects;
  148. }
  149. }