BT9_030.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_030 : 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.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] You may play 1 Digimon card with [Piranimon] in its name from this Digimon's digivolution cards without paying its memory cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  28. {
  29. if (cardSource.ContainsCardName("Piranimon"))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. Permanent selectedPermanent = card.PermanentOfThisCard();
  57. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  58. {
  59. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  60. List<CardSource> selectedCards = new List<CardSource>();
  61. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  62. selectCardEffect.SetUp(
  63. canTargetCondition: CanSelectCardCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. canNoSelect: () => true,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. message: "Select 1 digivolution card to play.",
  70. maxCount: maxCount,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. mode: SelectCardEffect.Mode.Custom,
  74. root: SelectCardEffect.Root.Custom,
  75. customRootCardList: selectedPermanent.DigivolutionCards,
  76. canLookReverseCard: true,
  77. selectPlayer: card.Owner,
  78. cardEffect: activateClass);
  79. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  80. yield return StartCoroutine(selectCardEffect.Activate());
  81. IEnumerator SelectCardCoroutine(CardSource cardSource)
  82. {
  83. selectedCards.Add(cardSource);
  84. yield return null;
  85. }
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  87. cardSources: selectedCards,
  88. activateClass: activateClass,
  89. payCost: false,
  90. isTapped: false,
  91. root: SelectCardEffect.Root.DigivolutionCards,
  92. activateETB: true));
  93. }
  94. }
  95. }
  96. }
  97. return cardEffects;
  98. }
  99. }