BT5_110.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_110 : 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] You may return 1 of your Digimon with [Omnimon] in its name to its owner's hand to delete all Digimon and Tamers. Trash all of the digivolution cards of the Digimon you returned with this effect.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.ContainsCardName("Omnimon"))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  41. {
  42. Permanent bouncePermanent = null;
  43. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  44. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  45. selectPermanentEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: CanSelectPermanentCondition,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: maxCount,
  51. canNoSelect: true,
  52. canEndNotMax: false,
  53. selectPermanentCoroutine: SelectPermanentCoroutine,
  54. afterSelectPermanentCoroutine: null,
  55. mode: SelectPermanentEffect.Mode.Custom,
  56. cardEffect: activateClass);
  57. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  60. {
  61. bouncePermanent = permanent;
  62. yield return null;
  63. }
  64. if (bouncePermanent != null)
  65. {
  66. if (bouncePermanent.TopCard != null)
  67. {
  68. if (!bouncePermanent.TopCard.CanNotBeAffected(activateClass))
  69. {
  70. if (!bouncePermanent.CannotReturnToHand(activateClass))
  71. {
  72. Hashtable hashtable = new Hashtable();
  73. hashtable.Add("CardEffect", activateClass);
  74. CardSource bounceCard = bouncePermanent.TopCard;
  75. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(new List<Permanent>() { bouncePermanent }, hashtable).Bounce());
  76. if (bouncePermanent.TopCard == null && bouncePermanent.HandBounceEffect == activateClass)
  77. {
  78. //if (bounceCard.Owner.HandCards.Contains(bounceCard) || bounceCard.isToken)
  79. {
  80. List<Permanent> destroyedPermanetns = new List<Permanent>();
  81. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  82. {
  83. foreach (Permanent permanent in player.Enemy.GetBattleAreaPermanents())
  84. {
  85. if (permanent.IsDigimon || permanent.IsTamer)
  86. {
  87. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  88. {
  89. if (permanent.CanBeDestroyedBySkill(activateClass))
  90. {
  91. destroyedPermanetns.Add(permanent);
  92. }
  93. }
  94. }
  95. }
  96. }
  97. if (destroyedPermanetns.Count >= 1)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyedPermanetns, hashtable).Destroy());
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. if (timing == EffectTiming.SecuritySkill)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  115. activateClass.SetIsSecurityEffect(true);
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[Security] Add this card to its owner's hand.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  128. }
  129. }
  130. return cardEffects;
  131. }
  132. }