BT21_084.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine.XR;
  6. //Haru Shinkai
  7. namespace DCGO.CardEffects.BT21
  8. {
  9. public class BT21_084 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Start of Turn
  15. if (timing == EffectTiming.OnStartTurn)
  16. {
  17. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  18. }
  19. #endregion
  20. #region Your Turn - When Linked
  21. if (timing == EffectTiming.WhenLinked)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Draw 1, then you may app fuse", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[Your Turn] When your Digimon get linked, by suspending this Tamer, <Draw 1> (Draw 1 card from your deck). Then, 1 of your Digimon may app fuse into a Digimon card in the hand.";
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkPermanentCondition, null))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  47. {
  48. if (CardEffectCommons.IsOwnerTurn(card))
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool LinkPermanentCondition(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  59. }
  60. bool CanSelectPermanent(Permanent permanent)
  61. {
  62. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  63. {
  64. foreach(CardSource hand in card.Owner.HandCards)
  65. {
  66. if (hand.appFusionCondition != null)
  67. {
  68. if (hand.CanAppFusionFromTargetPermanent(permanent, true))
  69. return true;
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. bool CanSelectCard(CardSource card, Permanent permanent)
  76. {
  77. if (CardEffectCommons.IsExistOnHand(card))
  78. {
  79. if (card.appFusionCondition != null)
  80. {
  81. if (card.CanAppFusionFromTargetPermanent(permanent, true))
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable hashtable)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  90. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  91. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  92. {
  93. Permanent selectedPermanent = null;
  94. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectPermanent,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: true,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to app fuse", "The opponent is selecting 1 digimon to app fuse");
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  111. {
  112. selectedPermanent = permanent;
  113. yield return null;
  114. }
  115. if (selectedPermanent != null)
  116. {
  117. CardSource selectedCard = null;
  118. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, handCard => CanSelectCard(handCard, selectedPermanent)));
  119. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  120. selectHandEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: handCard => CanSelectCard(handCard, selectedPermanent),
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount1,
  126. canNoSelect: true,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. selectCardCoroutine: SelectCardCoroutine,
  130. afterSelectCardCoroutine: null,
  131. mode: SelectHandEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. selectHandEffect.SetUpCustomMessage("Select digimon to app fuse into.", "The opponent is selecting digimon to app fuse into.");
  134. selectHandEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  135. yield return StartCoroutine(selectHandEffect.Activate());
  136. IEnumerator SelectCardCoroutine(CardSource cardSource)
  137. {
  138. selectedCard = cardSource;
  139. yield return null;
  140. }
  141. if (selectedCard != null && selectedCard.CanAppFusionFromTargetPermanent(selectedPermanent, true))
  142. {
  143. CardSource linkCard = selectedPermanent.LinkedCards.Where(x => selectedCard.appFusionCondition.linkedCondition(selectedPermanent, x)).First();
  144. PlayCardClass playCardClass = new PlayCardClass(new List<CardSource> { selectedCard }, hashtable, true, selectedPermanent, false, SelectCardEffect.Root.Hand, true);
  145. playCardClass.SetAppFusion(new int[] { selectedPermanent.PermanentFrame.FrameID, selectedPermanent.LinkedCards.IndexOf(linkCard) });
  146. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  147. }
  148. }
  149. }
  150. }
  151. }
  152. #endregion
  153. #region Security
  154. if (timing == EffectTiming.SecuritySkill)
  155. {
  156. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  157. }
  158. #endregion
  159. return cardEffects;
  160. }
  161. }
  162. }