BlastDigivolution.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. if(!permanent.TopCard.CanNotBeAffected(activateClass))
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card)))
  33. {
  34. if (card.Owner.HandCards.Contains(card))
  35. {
  36. if (condition == null || condition())
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (card.Owner.HandCards.Contains(card))
  47. {
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. if (condition == null || condition())
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. Permanent selectedPermanent = null;
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: SelectPermanentCoroutine,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  78. {
  79. selectedPermanent = permanent;
  80. yield return null;
  81. }
  82. if (selectedPermanent != null)
  83. {
  84. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
  85. {
  86. PlayCardClass playCardClass = new PlayCardClass(
  87. cardSources: new List<CardSource>() { card },
  88. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  89. payCost: false,
  90. targetPermanent: selectedPermanent,
  91. isTapped: false,
  92. root: SelectCardEffect.Root.Hand,
  93. activateETB: true);
  94. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  95. }
  96. }
  97. }
  98. return activateClass;
  99. }
  100. #endregion
  101. }