BT7_097.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 BT7_097 : 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] Choose up to 2 Digimon cards in the digivolution cards of one of your Digimon and play them as other Digimon without paying their memory costs.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  52. {
  53. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: maxCount,
  61. canNoSelect: false,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: SelectPermanentCoroutine,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon which has digivolution cards.", "The opponent is selecting 1 Digimon which has digivolution cards.");
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  70. {
  71. Permanent selectedPermanent = permanent;
  72. if (selectedPermanent != null)
  73. {
  74. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  75. {
  76. maxCount = 2;
  77. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) < maxCount)
  78. {
  79. maxCount = selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition);
  80. }
  81. List<CardSource> selectedCards = new List<CardSource>();
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: CanSelectCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: CanEndSelectCondition,
  87. canNoSelect: () => false,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. message: "Select digivolution cards to play.",
  91. maxCount: maxCount,
  92. canEndNotMax: true,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Custom,
  96. customRootCardList: selectedPermanent.DigivolutionCards,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. selectCardEffect.SetUpCustomMessage("Select digivolution cards to play.", "The opponent is selecting digivolution cards to play.");
  101. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  102. yield return StartCoroutine(selectCardEffect.Activate());
  103. bool CanEndSelectCondition(List<CardSource> cardSources)
  104. {
  105. if (CardEffectCommons.HasNoElement(cardSources))
  106. {
  107. return false;
  108. }
  109. return true;
  110. }
  111. IEnumerator SelectCardCoroutine(CardSource cardSource)
  112. {
  113. selectedCards.Add(cardSource);
  114. yield return null;
  115. }
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  117. cardSources: selectedCards,
  118. activateClass: activateClass,
  119. payCost: false,
  120. isTapped: false,
  121. root: SelectCardEffect.Root.DigivolutionCards,
  122. activateETB: true));
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. if (timing == EffectTiming.SecuritySkill)
  130. {
  131. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Play digivolution cards");
  132. }
  133. return cardEffects;
  134. }
  135. }