Explorar o código

Implement Permanent GainCannotSuspend to show on permanent details

hooperk hai 2 meses
pai
achega
424e0c9359

+ 2 - 2
Assets/Scripts/CardEffect/BT24/Yellow/BT24_040.cs

@@ -113,8 +113,8 @@ namespace DCGO.CardEffects.BT24
                 {
                     if (permanent != null)
                     {
-                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspendPlayerEffect(
-                                permanentCondition: (otherPermanent) => otherPermanent == permanent,
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspendEffect(
+                                targetPermanent: permanent,
                                 effectDuration: EffectDuration.UntilOpponentTurnEnd,
                                 activateClass: activateClass,
                                 isOnlyActivePhase: false,

+ 42 - 0
Assets/Scripts/Script/CardEffectCommons/GiveEffect/GiveEffectToPlayer/CanNotSuspend.cs

@@ -6,6 +6,48 @@ using UnityEngine;
 
 public partial class CardEffectCommons
 {
+    #region Permanent gains effect to can't digivolve
+    public static IEnumerator GainCanNotSuspendEffect(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass, bool isOnlyActivePhase, string effectName)
+    {
+        if (activateClass == null || activateClass.EffectSourceCard == null) yield break;
+        if (targetPermanent == null || targetPermanent.TopCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool PermanentCondition(Permanent permanent)
+        {
+            if (IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (!permanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return permanent == targetPermanent;
+                }
+            }
+
+            return false;
+        }
+
+        bool CanUseCondition()
+        {
+            return !isOnlyActivePhase || GManager.instance.turnStateMachine.gameContext.TurnPhase == GameContext.phase.Active;
+        }
+
+        CanNotSuspendClass canNotSuspendClass = CardEffectFactory.CantSuspendStaticEffect(
+            permanentCondition: PermanentCondition,
+            isInheritedEffect: false,
+            card: card,
+            condition: CanUseCondition,
+            effectName: effectName);
+
+        AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: activateClass, timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
+        }
+    }
+    #endregion
+
     #region Player gains effect to have Digimon can't suspend
     public static IEnumerator GainCanNotSuspendPlayerEffect(Func<Permanent, bool> permanentCondition, EffectDuration effectDuration, ICardEffect activateClass, bool isOnlyActivePhase, string effectName)
     {