BT5_086.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 BT5_086 : 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.OnEnterFieldAnyone)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlitzSelfEffect(isInheritedEffect: false, card: card, condition: null, isWhenDigivolving: true));
  16. }
  17. if (timing == EffectTiming.OnEnterFieldAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  22. cardEffects.Add(activateClass);
  23. string EffectDiscription()
  24. {
  25. return "[When Digivolving] Unsuspend this Digimon.";
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. Permanent selectedPermanent = card.PermanentOfThisCard();
  45. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  46. }
  47. }
  48. if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted or returned to hand or deck", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  53. activateClass.SetHashString("Substitute_BT5_086");
  54. cardEffects.Add(activateClass);
  55. string EffectDiscription()
  56. {
  57. return "[All Turns] If an opponent's effect would delete this Digimon or return it to its owner's hand or deck, you may prevent it from leaving play by trashing a level 6 Digimon card in this card's digivolution cards.";
  58. }
  59. bool CanSelectCardCondition(CardSource cardSource)
  60. {
  61. if (cardSource.IsDigimon)
  62. {
  63. if (cardSource.Level == 6)
  64. {
  65. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  66. {
  67. if (cardSource.HasLevel)
  68. {
  69. return true;
  70. }
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. if (CardEffectCommons.IsExistOnBattleArea(card))
  79. {
  80. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  81. {
  82. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => cardEffect.EffectSourceCard != null && cardEffect.EffectSourceCard.Owner == card.Owner.Enemy))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. return false;
  89. }
  90. bool CanActivateCondition(Hashtable hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  102. {
  103. if (CardEffectCommons.IsExistOnBattleArea(card))
  104. {
  105. Permanent selectedPermanent = card.PermanentOfThisCard();
  106. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  107. {
  108. List<CardSource> selectedCards = new List<CardSource>();
  109. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  110. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  111. selectCardEffect.SetUp(
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. canNoSelect: () => true,
  116. selectCardCoroutine: SelectCardCoroutine,
  117. afterSelectCardCoroutine: null,
  118. message: "Select 1 card to discard.",
  119. maxCount: maxCount,
  120. canEndNotMax: false,
  121. isShowOpponent: true,
  122. mode: SelectCardEffect.Mode.Custom,
  123. root: SelectCardEffect.Root.Custom,
  124. customRootCardList: selectedPermanent.DigivolutionCards,
  125. canLookReverseCard: true,
  126. selectPlayer: card.Owner,
  127. cardEffect: activateClass);
  128. selectCardEffect.SetNotShowCard();
  129. yield return StartCoroutine(selectCardEffect.Activate());
  130. IEnumerator SelectCardCoroutine(CardSource cardSource)
  131. {
  132. selectedCards.Add(cardSource);
  133. yield return null;
  134. }
  135. if (selectedCards.Count == 1)
  136. {
  137. selectedPermanent.willBeRemoveField = false;
  138. selectedPermanent.HideDeleteEffect();
  139. selectedPermanent.HideHandBounceEffect();
  140. selectedPermanent.HideDeckBounceEffect();
  141. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  142. }
  143. }
  144. }
  145. }
  146. }
  147. return cardEffects;
  148. }
  149. }