ST13_04.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 ST13_04 : 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.None)
  14. {
  15. bool Condition()
  16. {
  17. return CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.IsExistOnBattleArea(card);
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. return targetPermanent == card.PermanentOfThisCard();
  22. }
  23. bool CardSourceCondition(CardSource cardSource)
  24. {
  25. if (cardSource.Owner.HandCards.Contains(cardSource))
  26. {
  27. if (cardSource.CardTraits.Contains("Legend-Arms"))
  28. {
  29. return true;
  30. }
  31. if (cardSource.CardColors.Contains(CardColor.Black))
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool RootCondition(SelectCardEffect.Root root)
  39. {
  40. return root == SelectCardEffect.Root.Hand;
  41. }
  42. cardEffects.Add(CardEffectFactory.ChangeDigivolutionCostStaticEffect(
  43. changeValue: -1,
  44. permanentCondition: PermanentCondition,
  45. cardCondition: CardSourceCondition,
  46. rootCondition: RootCondition,
  47. isInheritedEffect: false,
  48. card: card,
  49. condition: Condition,
  50. setFixedCost: false));
  51. }
  52. if (timing == EffectTiming.OnEndTurn)
  53. {
  54. ActivateClass activateClass = new ActivateClass();
  55. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  56. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  57. activateClass.SetIsInheritedEffect(true);
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. {
  61. return "[End of Your Turn] You may DNA digivolve this Digimon and one of your other Digimon in play into a Digimon card in your hand by paying its DNA digivolve cost.";
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource)
  64. {
  65. if (cardSource != null)
  66. {
  67. if (cardSource.IsDigimon)
  68. {
  69. if (cardSource.Owner == card.Owner)
  70. {
  71. if (cardSource.CanPlayJogress(true))
  72. {
  73. if (isExistOnField(card))
  74. {
  75. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  76. {
  77. return true;
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. if (isExistOnField(card))
  89. {
  90. return true;
  91. }
  92. return false;
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (CardEffectCommons.IsOwnerTurn(card))
  99. {
  100. if (card.Owner.HandCards.Count >= 1)
  101. {
  102. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  103. {
  104. return true;
  105. }
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  112. {
  113. if (isExistOnField(card))
  114. {
  115. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  116. {
  117. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  118. {
  119. List<CardSource> selectedCards = new List<CardSource>();
  120. int maxCount = 1;
  121. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  122. selectHandEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectCardCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: true,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. mode: SelectHandEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. selectHandEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  136. selectHandEffect.SetNotShowCard();
  137. yield return StartCoroutine(selectHandEffect.Activate());
  138. IEnumerator SelectCardCoroutine(CardSource cardSource)
  139. {
  140. selectedCards.Add(cardSource);
  141. yield return null;
  142. }
  143. if (selectedCards.Count >= 1)
  144. {
  145. foreach (CardSource selectedCard in selectedCards)
  146. {
  147. if (selectedCard.CanPlayJogress(true) && selectedCard.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  148. {
  149. JogressEvoRootsFrameIDs = new int[0];
  150. yield return GManager.instance.photonWaitController.StartWait("Patamon_BT8_020");
  151. if (card.Owner.isYou || GManager.instance.IsAI)
  152. {
  153. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  154. (card: selectedCard,
  155. isLocal: true,
  156. isPayCost: true,
  157. canNoSelect: true,
  158. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  159. noSelectCoroutine: null);
  160. GManager.instance.selectJogressEffect.SetUpCustomPermanentConditions(new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() });
  161. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  162. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  163. {
  164. permanents = permanents.Distinct().ToList();
  165. if (permanents.Count == 2)
  166. {
  167. JogressEvoRootsFrameIDs = new int[2];
  168. for (int i = 0; i < permanents.Count; i++)
  169. {
  170. if (i < JogressEvoRootsFrameIDs.Length)
  171. {
  172. JogressEvoRootsFrameIDs[i] = permanents[i].PermanentFrame.FrameID;
  173. }
  174. }
  175. }
  176. if (!permanents.Contains(card.PermanentOfThisCard()))
  177. {
  178. JogressEvoRootsFrameIDs = new int[0];
  179. }
  180. yield return null;
  181. }
  182. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, JogressEvoRootsFrameIDs);
  183. }
  184. else
  185. {
  186. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  187. }
  188. yield return new WaitWhile(() => !endSelect);
  189. endSelect = false;
  190. GManager.instance.commandText.CloseCommandText();
  191. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  192. if (JogressEvoRootsFrameIDs.Length == 2)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  195. PlayCardClass playCard = new PlayCardClass(
  196. cardSources: new List<CardSource>() { selectedCard },
  197. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  198. payCost: true,
  199. targetPermanent: null,
  200. isTapped: false,
  201. root: SelectCardEffect.Root.Hand,
  202. activateETB: true);
  203. playCard.SetJogress(JogressEvoRootsFrameIDs);
  204. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. return cardEffects;
  215. }
  216. bool endSelect = false;
  217. int[] JogressEvoRootsFrameIDs = new int[0];
  218. [PunRPC]
  219. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  220. {
  221. this.JogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  222. endSelect = true;
  223. }
  224. }