BT1_044.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 BT1_044 : 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, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] Play 1 level 4 or lower digivolution card under this card as another Digimon 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.Level <= 4)
  30. {
  31. if (cardSource.HasLevel)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. Permanent selectedPermanent = card.PermanentOfThisCard();
  60. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  61. List<CardSource> selectedCards = new List<CardSource>();
  62. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  63. selectCardEffect.SetUp(
  64. canTargetCondition: CanSelectCardCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. canNoSelect: () => false,
  68. selectCardCoroutine: SelectCardCoroutine,
  69. afterSelectCardCoroutine: null,
  70. message: "Select 1 digivolution card to play.",
  71. maxCount: maxCount,
  72. canEndNotMax: false,
  73. isShowOpponent: true,
  74. mode: SelectCardEffect.Mode.Custom,
  75. root: SelectCardEffect.Root.Custom,
  76. customRootCardList: selectedPermanent.DigivolutionCards,
  77. canLookReverseCard: true,
  78. selectPlayer: card.Owner,
  79. cardEffect: activateClass);
  80. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  81. yield return StartCoroutine(selectCardEffect.Activate());
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCards.Add(cardSource);
  85. yield return null;
  86. }
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true));
  88. }
  89. }
  90. }
  91. return cardEffects;
  92. }
  93. }