| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using UnityEngine;
- public partial class CardEffectFactory
- {
- #region Trigger effect of [Blast Digivolve]
- public static ActivateClass BlastDigivolveEffect(CardSource card, Func<bool> condition)
- {
- if (card == null) return null;
- if (!CardEffectCommons.IsExistOnHand(card)) return null;
- if (card.Owner.GetBattleAreaPermanents().Count == 0) return null;
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Blast Digivolve", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.BlastDigivolveEffectDiscription());
- activateClass.SetIsCounterEffect(true);
- bool CanSelectPermanentCondition(Permanent permanent)
- {
- if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
- {
- if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
- {
- if(!permanent.TopCard.CanNotBeAffected(activateClass))
- return true;
- }
- }
- return false;
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card)))
- {
- if (card.Owner.HandCards.Contains(card))
- {
- if (condition == null || condition())
- {
- return true;
- }
- }
- }
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (card.Owner.HandCards.Contains(card))
- {
- if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
- {
- if (condition == null || condition())
- {
- return true;
- }
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- Permanent selectedPermanent = null;
- int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermanentCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: maxCount,
- canNoSelect: false,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectPermanentCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- selectedPermanent = permanent;
- yield return null;
- }
- if (selectedPermanent != null)
- {
- if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClass))
- {
- PlayCardClass playCardClass = new PlayCardClass(
- cardSources: new List<CardSource>() { card },
- hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
- payCost: false,
- targetPermanent: selectedPermanent,
- isTapped: false,
- root: SelectCardEffect.Root.Hand,
- activateETB: true);
- yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
- }
- }
- }
- return activateClass;
- }
- #endregion
- }
|