BT4_102.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 BT4_102 : 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.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Return 1 of your Digimon to its owner's hand to return up to 2 of your opponent's level 4 or lower Digimon to their owners' hands. Trash all of the digivolution cards of those Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectPermanentCondition1(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent.Level <= 4)
  32. {
  33. if (permanent.TopCard.HasLevel)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. Permanent bouncePermanent = null;
  50. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. bouncePermanent = permanent;
  69. yield return null;
  70. }
  71. if (bouncePermanent != null)
  72. {
  73. if (bouncePermanent.TopCard != null)
  74. {
  75. if (!bouncePermanent.TopCard.CanNotBeAffected(activateClass))
  76. {
  77. if (!bouncePermanent.CannotReturnToHand(activateClass))
  78. {
  79. Hashtable hashtable = new Hashtable();
  80. hashtable.Add("CardEffect", activateClass);
  81. CardSource bounceCard = bouncePermanent.TopCard;
  82. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(new List<Permanent>() { bouncePermanent }, hashtable).Bounce());
  83. if (bouncePermanent.TopCard == null && bouncePermanent.HandBounceEffect == activateClass)
  84. {
  85. //if (bounceCard.Owner.HandCards.Contains(bounceCard) || bounceCard.isToken)
  86. {
  87. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  88. {
  89. maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectPermanentCondition1,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: CanEndSelectCondition,
  95. maxCount: maxCount,
  96. canNoSelect: false,
  97. canEndNotMax: true,
  98. selectPermanentCoroutine: null,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.Bounce,
  101. cardEffect: activateClass);
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. bool CanEndSelectCondition(List<Permanent> permanents)
  104. {
  105. if (permanents.Count <= 0)
  106. {
  107. return false;
  108. }
  109. return true;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. if (timing == EffectTiming.SecuritySkill)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  126. activateClass.SetIsSecurityEffect(true);
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[Security] Add this card to its owner's hand.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  139. }
  140. }
  141. return cardEffects;
  142. }
  143. }