BT9_050.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 BT9_050 : 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.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Leomon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Play 1 [Leomon] from digivolution cards", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. activateClass.SetHashString("Substitute_BT9_050");
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[All Turns] When this Digimon would be deleted in battle, you may play 1 [Leomon] from this Digimon's digivolution cards without paying its memory cost.";
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  35. {
  36. if (cardSource.CardNames.Contains("Leomon"))
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  48. {
  49. if (CardEffectCommons.IsByBattle(hashtable))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. Permanent selectedPermanent = card.PermanentOfThisCard();
  73. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  74. {
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. int maxCount = 1;
  77. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  78. selectCardEffect.SetUp(
  79. canTargetCondition: CanSelectCardCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. canNoSelect: () => true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. message: "Select 1 card to play.",
  86. maxCount: maxCount,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. mode: SelectCardEffect.Mode.Custom,
  90. root: SelectCardEffect.Root.Custom,
  91. customRootCardList: selectedPermanent.DigivolutionCards,
  92. canLookReverseCard: true,
  93. selectPlayer: card.Owner,
  94. cardEffect: activateClass);
  95. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  96. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  97. yield return StartCoroutine(selectCardEffect.Activate());
  98. IEnumerator SelectCardCoroutine(CardSource cardSource)
  99. {
  100. selectedCards.Add(cardSource);
  101. yield return null;
  102. }
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  104. cardSources: selectedCards,
  105. activateClass: activateClass,
  106. payCost: false,
  107. isTapped: false,
  108. root: SelectCardEffect.Root.DigivolutionCards,
  109. activateETB: true));
  110. }
  111. }
  112. }
  113. }
  114. return cardEffects;
  115. }
  116. }