BT6_042.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 BT6_042 : 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.OnDestroyedAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play Digimon from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Deletion] You may play 1 [Rosemon] or up to 2 yellow level 3 Digimon cards from your hand without paying their memory costs.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.CardNames.Contains("Rosemon"))
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectCardCondition1(CardSource cardSource)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (cardSource.HasCardColor(CardColor.Yellow))
  39. {
  40. if (cardSource.Level == 3)
  41. {
  42. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  43. {
  44. if (cardSource.HasLevel)
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnTrash(card))
  61. {
  62. if (card.Owner.HandCards.Count >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  72. {
  73. List<CardSource> selectedCards = new List<CardSource>();
  74. int maxCount = Math.Min(2, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)));
  75. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  76. selectHandEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource),
  79. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  80. canEndSelectCondition: CanEndSelectCondition,
  81. maxCount: maxCount,
  82. canNoSelect: true,
  83. canEndNotMax: true,
  84. isShowOpponent: true,
  85. selectCardCoroutine: SelectCardCoroutine,
  86. afterSelectCardCoroutine: null,
  87. mode: SelectHandEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectHandEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  90. selectHandEffect.SetUpCustomMessage_ShowCard("Played Cards");
  91. yield return StartCoroutine(selectHandEffect.Activate());
  92. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  93. {
  94. if (cardSources.Count(CanSelectCardCondition) >= 1)
  95. {
  96. if (CanSelectCardCondition1(cardSource))
  97. {
  98. return false;
  99. }
  100. }
  101. if (cardSources.Count(CanSelectCardCondition1) >= 1)
  102. {
  103. if (CanSelectCardCondition(cardSource))
  104. {
  105. return false;
  106. }
  107. }
  108. if (cardSources.Count(CanSelectCardCondition) >= 1)
  109. {
  110. if (CanSelectCardCondition(cardSource))
  111. {
  112. return false;
  113. }
  114. }
  115. if (cardSources.Count(CanSelectCardCondition1) >= 2)
  116. {
  117. if (CanSelectCardCondition1(cardSource))
  118. {
  119. return false;
  120. }
  121. }
  122. return true;
  123. }
  124. bool CanEndSelectCondition(List<CardSource> cardSources)
  125. {
  126. if (maxCount >= 1)
  127. {
  128. if (cardSources.Count <= 0)
  129. {
  130. return false;
  131. }
  132. }
  133. if (cardSources.Count(CanSelectCardCondition) >= 2)
  134. {
  135. return false;
  136. }
  137. if (cardSources.Count(CanSelectCardCondition1) >= 3)
  138. {
  139. return false;
  140. }
  141. if (cardSources.Count(CanSelectCardCondition) >= 1)
  142. {
  143. if (cardSources.Count(CanSelectCardCondition1) >= 1)
  144. {
  145. return false;
  146. }
  147. }
  148. return true;
  149. }
  150. IEnumerator SelectCardCoroutine(CardSource cardSource)
  151. {
  152. selectedCards.Add(cardSource);
  153. yield return null;
  154. }
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  156. cardSources: selectedCards,
  157. activateClass: activateClass,
  158. payCost: false,
  159. isTapped: false,
  160. root: SelectCardEffect.Root.Hand,
  161. activateETB: true));
  162. }
  163. }
  164. }
  165. return cardEffects;
  166. }
  167. }