BlastDNADigivolution.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. using Photon.Pun;
  7. public class BlastDNACondition
  8. {
  9. public string Name;
  10. public List<Permanent> Permanents;
  11. public List<CardSource> CardSources;
  12. public BlastDNACondition(string name)
  13. {
  14. Name = name;
  15. Permanents = new List<Permanent>();
  16. CardSources = new List<CardSource>();
  17. }
  18. }
  19. public partial class CardEffectFactory
  20. {
  21. #region Trigger effect of [Blast DNA Digivolve]
  22. public static ActivateClass BlastDNADigivolveEffect(CardSource card, List<BlastDNACondition> blastDNAConditions, Func<bool> condition)
  23. {
  24. if (card == null) return null;
  25. if (!CardEffectCommons.IsExistOnHand(card)) return null;
  26. if (card.Owner.GetBattleAreaPermanents().Count == 0) return null;
  27. if (card.Owner.HandCards.Count < 2) return null;
  28. List<Permanent> permanentSources = card.Owner.GetBattleAreaDigimons()
  29. .Clone()
  30. .Filter(permanent => permanent.TopCard.ContainsCardName(blastDNAConditions[0].Name)
  31. || permanent.TopCard.ContainsCardName(blastDNAConditions[1].Name));
  32. List<CardSource> handSources = card.Owner.HandCards
  33. .Clone()
  34. .Filter(cardSource => cardSource.ContainsCardName(blastDNAConditions[0].Name)
  35. || cardSource.ContainsCardName(blastDNAConditions[1].Name));
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Blast DNA Digivolve", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.BlastDNADigivolveEffectDiscription());
  39. activateClass.SetIsCounterEffect(true);
  40. bool CanSelectPermanent(Permanent permanent)
  41. {
  42. return permanentSources.Contains(permanent);
  43. }
  44. bool CanSelectHandSource(CardSource cardSource)
  45. {
  46. return handSources.Contains(cardSource);
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card)))
  51. {
  52. if (card.Owner.HandCards.Contains(card))
  53. {
  54. if (condition == null || condition())
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (card.Owner.HandCards.Contains(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanent))
  67. {
  68. if (condition == null || condition())
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. Permanent selectedPermanent = null;
  79. CardSource selectedCardSource = null;
  80. /*permanentSources.ForEach(permanent =>
  81. {
  82. if (permanent.TopCard.ContainsCardName(blastDNAConditions[0].Name))
  83. blastDNAConditions[0].Permanents.Add(permanent);
  84. if (permanent.TopCard.ContainsCardName(blastDNAConditions[1].Name))
  85. blastDNAConditions[1].Permanents.Add(permanent);
  86. });
  87. handSources.ForEach(cardSource =>
  88. {
  89. if (cardSource.ContainsCardName(blastDNAConditions[0].Name))
  90. blastDNAConditions[0].CardSources.Add(cardSource);
  91. if (cardSource.ContainsCardName(blastDNAConditions[1].Name))
  92. blastDNAConditions[1].CardSources.Add(cardSource);
  93. });*/
  94. yield return null;
  95. int maxCount = Math.Min(1, permanentSources.Count);
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanent,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: SelectPermanentCoroutine,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.", "The opponent is selecting 1 Digimon to DNA digivolve.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. selectedPermanent = permanent;
  114. foreach(string name in selectedPermanent.TopCard.CardNames)
  115. handSources = handSources.Filter(source => source.ContainsCardName(name));
  116. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  117. selectHandEffect.SetUp(
  118. selectPlayer: card.Owner,
  119. canTargetCondition: CanSelectHandSource,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. maxCount: maxCount,
  123. canNoSelect: false,
  124. canEndNotMax: false,
  125. isShowOpponent: true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. mode: SelectHandEffect.Mode.Custom,
  129. cardEffect: activateClass);
  130. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.", "The opponent is selecting 1 Digimon to DNA digivolve.");
  131. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  132. }
  133. IEnumerator SelectCardCoroutine(CardSource cardSource)
  134. {
  135. selectedCardSource = cardSource;
  136. PlayCardClass playCardClass = new PlayCardClass(
  137. cardSources: new List<CardSource>() { selectedCardSource },
  138. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  139. payCost: false,
  140. targetPermanent: null,
  141. isTapped: false,
  142. root: SelectCardEffect.Root.Hand,
  143. activateETB: false);
  144. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  145. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { card }, "Played Card", true, true));
  146. int[] JogressEvoRootsFrameIDs = { selectedPermanent.PermanentFrame.FrameID, selectedCardSource.PermanentOfThisCard().PermanentFrame.FrameID };
  147. PlayCardClass playCard = new PlayCardClass(
  148. cardSources: new List<CardSource>() { card },
  149. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  150. payCost: true,
  151. targetPermanent: null,
  152. isTapped: false,
  153. root: SelectCardEffect.Root.Hand,
  154. activateETB: true);
  155. playCard.SetJogress(JogressEvoRootsFrameIDs);
  156. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  157. }
  158. #region Blast Digivolve
  159. /*Permanent selectedPermanent = null;
  160. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: CanSelectPermanentCondition,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: maxCount,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: SelectPermanentCoroutine,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Custom,
  173. cardEffect: activateClass);
  174. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  175. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  176. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  177. {
  178. selectedPermanent = permanent;
  179. yield return null;
  180. }
  181. if (selectedPermanent != null)
  182. {
  183. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
  184. {
  185. PlayCardClass playCardClass = new PlayCardClass(
  186. cardSources: new List<CardSource>() { card },
  187. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  188. payCost: false,
  189. targetPermanent: selectedPermanent,
  190. isTapped: false,
  191. root: SelectCardEffect.Root.Hand,
  192. activateETB: true);
  193. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  194. }
  195. }*/
  196. #endregion
  197. }
  198. return activateClass;
  199. }
  200. #endregion
  201. }