BT2_039.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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_039 : 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("Recovery +2 (Deck)", 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 3 or fewer security cards, trigger <Recovery +2 (Deck)>. (Place the top 2 cards of your deck on top of your security stack.)";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.LibraryCards.Count >= 1)
  32. {
  33. if (card.Owner.SecurityCards.Count <= 3)
  34. {
  35. if (card.Owner.CanAddSecurity(activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 2, activateClass).Recovery());
  49. }
  50. }
  51. }
  52. if (timing == EffectTiming.OnAllyAttack)
  53. {
  54. ActivateClass activateClass = new ActivateClass();
  55. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  56. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  57. cardEffects.Add(activateClass);
  58. string EffectDiscription()
  59. {
  60. return "[When Attacking] You may play 1 yellow level 3 Digimon card from your hand without paying its memory cost.";
  61. }
  62. bool CanSelectCardCondition(CardSource cardSource)
  63. {
  64. if (cardSource != null)
  65. {
  66. if (cardSource.IsDigimon)
  67. {
  68. if (cardSource.Owner == card.Owner)
  69. {
  70. if (cardSource.HasCardColor(CardColor.Yellow))
  71. {
  72. if (cardSource.Level == 3)
  73. {
  74. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  75. {
  76. if (cardSource.HasLevel)
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. return false;
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  91. }
  92. bool CanActivateCondition(Hashtable hashtable)
  93. {
  94. if (CardEffectCommons.IsExistOnBattleArea(card))
  95. {
  96. if (card.Owner.HandCards.Count >= 1)
  97. {
  98. return true;
  99. }
  100. }
  101. return false;
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  104. {
  105. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  106. {
  107. List<CardSource> selectedCards = new List<CardSource>();
  108. int maxCount = 1;
  109. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  110. selectHandEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: maxCount,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. mode: SelectHandEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  124. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  125. yield return StartCoroutine(selectHandEffect.Activate());
  126. IEnumerator SelectCardCoroutine(CardSource cardSource)
  127. {
  128. selectedCards.Add(cardSource);
  129. yield return null;
  130. }
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  132. }
  133. }
  134. }
  135. return cardEffects;
  136. }
  137. }