Bläddra i källkod

Gain Barrier update

mbunch_kascope 2 år sedan
förälder
incheckning
dcf4192fa2

+ 63 - 38
Assets/Scripts/CardEffectCommons/KeyWordEffects/Barrier.cs

@@ -24,58 +24,83 @@ public partial class CardEffectCommons
     #region Effect process of [Barrier]
     #region Effect process of [Barrier]
     public static IEnumerator BarrierProcess(Permanent permanent, ICardEffect activateClass)
     public static IEnumerator BarrierProcess(Permanent permanent, ICardEffect activateClass)
     {
     {
-        yield return ContinuousController.instance.StartCoroutine(new BarrierClass(permanent, activateClass).Barrier());
-    }
-    #endregion
-
-    #region Barrier class
-    public class BarrierClass
-    {
-        public BarrierClass(Permanent permanent, ICardEffect cardEffect)
+        if (permanent != null)
         {
         {
-            _permanent = permanent;
-            _cardEffect = cardEffect;
-        }
-
-        Permanent _permanent = null;
-        ICardEffect _cardEffect = null;
-
-        public IEnumerator Barrier()
-        {
-            if (_permanent != null)
+            if (permanent.TopCard != null)
             {
             {
-                if (_permanent.TopCard != null)
+                CardSource topCard = permanent.TopCard;
+
+                if (topCard.Owner.SecurityCards.Count >= 1)
                 {
                 {
-                    CardSource topCard = _permanent.TopCard;
+                    permanent.ShowDeleteEffect();
+
+                    yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
+                                            player: topCard.Owner,
+                                            destroySecurityCount: 1,
+                                            cardEffect: activateClass,
+                                            fromTop: true).DestroySecurity());
 
 
-                    if (topCard.Owner.SecurityCards.Count >= 1)
-                    {
-                        _permanent.ShowDeleteEffect();
+                    permanent.willBeRemoveField = false;
 
 
-                        yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
-                                                player: topCard.Owner,
-                                                destroySecurityCount: 1,
-                                                cardEffect: _cardEffect,
-                                                fromTop: true).DestroySecurity());
+                    permanent.HideDeleteEffect();
 
 
-                        _permanent.willBeRemoveField = false;
+                    #region log
+                    string log = "";
 
 
-                        _permanent.HideDeleteEffect();
+                    log += $"\nBarrier :";
 
 
-                        #region log
-                        string log = "";
+                    log += $"\n{topCard.BaseENGCardNameFromEntity}({topCard.CardID})";
 
 
-                        log += $"\nBarrier :";
+                    log += "\n";
+
+                    GManager.instance.playLog.AddLogString(log);
+                    #endregion
+                }
+            }
+        }
+    }
+    #endregion
 
 
-                        log += $"\n{topCard.BaseENGCardNameFromEntity}({topCard.CardID})";
+    #region Target 1 Digimon gains [Barrier]
+    public static IEnumerator GainBarrier(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
 
 
-                        log += "\n";
+        CardSource card = activateClass.EffectSourceCard;
 
 
-                        GManager.instance.playLog.AddLogString(log);
-                        #endregion
-                    }
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
                 }
                 }
             }
             }
+
+            return false;
+        }
+
+        ActivateClass retaliation = CardEffectFactory.BarrierEffect(
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            card: targetPermanent.TopCard);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: retaliation,
+            timing: EffectTiming.WhenPermanentWouldBeDeleted);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
         }
         }
     }
     }
     #endregion
     #endregion

+ 1 - 1
Assets/Scripts/CardEffectFactory/KeyWordEffects/Barrier.cs

@@ -7,7 +7,7 @@ using UnityEngine;
 public partial class CardEffectFactory
 public partial class CardEffectFactory
 {
 {
     #region Trigger effect of [Barrier] on oneself
     #region Trigger effect of [Barrier] on oneself
-    public static ActivateClass BarrierSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition)
+    public static ICardEffect BarrierSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition)
     {
     {
         Permanent targetPermanent = card.PermanentOfThisCard();
         Permanent targetPermanent = card.PermanentOfThisCard();