BlastDigivolution.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectFactory
  7. {
  8. #region Trigger effect of [Blast Digivolve]
  9. public static ActivateClass BlastDigivolveEffect(CardSource card, Func<bool> condition)
  10. {
  11. if (card == null) return null;
  12. if (!CardEffectCommons.IsExistOnHand(card)) return null;
  13. if (card.Owner.GetBattleAreaPermanents().Count == 0) return null;
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Blast Digivolve", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.BlastDigivolveEffectDiscription());
  17. activateClass.SetIsCounterEffect(true);
  18. bool CanSelectPermanentCondition(Permanent permanent)
  19. {
  20. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  21. {
  22. if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  23. {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card)))
  32. {
  33. if (card.Owner.HandCards.Contains(card))
  34. {
  35. if (condition == null || condition())
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (card.Owner.HandCards.Contains(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. if (condition == null || condition())
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. Permanent selectedPermanent = null;
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. selectedPermanent = permanent;
  79. yield return null;
  80. }
  81. if (selectedPermanent != null)
  82. {
  83. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
  84. {
  85. PlayCardClass playCardClass = new PlayCardClass(
  86. cardSources: new List<CardSource>() { card },
  87. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  88. payCost: false,
  89. targetPermanent: selectedPermanent,
  90. isTapped: false,
  91. root: SelectCardEffect.Root.Hand,
  92. activateETB: true);
  93. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  94. }
  95. }
  96. }
  97. return activateClass;
  98. }
  99. #endregion
  100. }