mbunch_kascope 1 год назад
Родитель
Сommit
b417bda261

+ 262 - 0
Assets/Scripts/CardController.cs

@@ -2524,6 +2524,268 @@ public class IPlacePermanentToDigivolutionCards
 }
 }
 #endregion
 #endregion
 
 
+#region Link permanent to another permanent
+public class ILinkPermanentToPermanent
+{
+    public ILinkPermanentToPermanent(
+        List<Permanent[]> permanentArrays,
+        ICardEffect cardEffect)
+    {
+        permanentArrays.Clone().ForEach(permanentArray => _permanentArrays.Add(permanentArray.CloneArray()));
+        _cardEffect = cardEffect;
+    }
+
+    public void SetNotShowCards()
+    {
+        _notShowCards = true;
+    }
+
+    List<Permanent[]> _permanentArrays = new List<Permanent[]>();
+    ICardEffect _cardEffect = null;
+    bool _notShowCards = false;
+    public bool Linked { get; private set; } = false;
+    public IEnumerator LinkPermanent()
+    {
+        if (_permanentArrays.Count != 2)
+        {
+            yield break;
+        }
+
+        List<CardSource> addedLinkCards = new List<CardSource>();
+
+        List<Permanent> removeFieldPermanents = new List<Permanent>();
+
+        foreach (Permanent[] permanentArray in _permanentArrays)
+        {
+            Permanent LinkPermanent = permanentArray[0];
+            Permanent LinkedPermanent = permanentArray[1];
+
+            if (LinkPermanent != null && LinkedPermanent != null)
+            {
+                if (LinkPermanent.TopCard != null && LinkedPermanent.TopCard != null && !LinkedPermanent.IsToken)
+                {
+                    if (_cardEffect != null)
+                    {
+                        if (LinkPermanent.TopCard.CanNotBeAffected(_cardEffect) || LinkedPermanent.TopCard.CanNotBeAffected(_cardEffect))
+                        {
+                            continue;
+                        }
+                    }
+
+                    removeFieldPermanents.Add(LinkPermanent);
+                }
+            }
+        }
+
+        foreach (Permanent permanent in removeFieldPermanents)
+        {
+            permanent.willBeRemoveField = true;
+        }
+
+        if (removeFieldPermanents.Count == 0)
+        {
+            yield break;
+        }
+
+        #region When permanent would remove effect
+        List<SkillInfo> skillInfos = new List<SkillInfo>();
+
+        Hashtable hashtable1 =
+        CardEffectCommons.WhenPermanentWouldRemoveFieldCheckHashtable(
+                removeFieldPermanents,
+                _cardEffect,
+                null);
+
+        #region  "When permanents would remove field" effect
+
+        foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
+        {
+            #region permanents' effects
+            foreach (Permanent permanent1 in player.GetFieldPermanents())
+            {
+                foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenRemoveField))
+                {
+                    if (cardEffect is ActivateICardEffect)
+                    {
+                        if (cardEffect.CanTrigger(hashtable1))
+                        {
+                            skillInfos.Add(new SkillInfo(cardEffect, hashtable1, EffectTiming.WhenRemoveField));
+                        }
+                    }
+                }
+            }
+            #endregion
+
+            #region players' effects
+            foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenRemoveField))
+            {
+                if (cardEffect is ActivateICardEffect)
+                {
+                    if (cardEffect.CanTrigger(hashtable1))
+                    {
+                        skillInfos.Add(new SkillInfo(cardEffect, hashtable1, EffectTiming.WhenRemoveField));
+                    }
+                }
+            }
+            #endregion
+        }
+        #endregion
+
+        if (skillInfos.Count >= 1)
+        {
+            foreach (SkillInfo skillInfo in skillInfos)
+            {
+                GManager.instance.autoProcessing_CutIn.PutStackedSkill(skillInfo);
+            }
+
+            bool showEffect()
+            {
+                if (skillInfos.Count >= 2)
+                {
+                    return true;
+                }
+
+                else if (skillInfos.Count == 1)
+                {
+                    if (skillInfos[0].CardEffect.CanActivate(skillInfos[0].Hashtable))
+                    {
+                        return true;
+                    }
+                }
+
+                return false;
+            }
+
+            if (showEffect())
+            {
+                foreach (Permanent Permanent in removeFieldPermanents)
+                {
+                    if (Permanent != null)
+                    {
+                        if (Permanent.TopCard != null)
+                        {
+                            if (Permanent.willBeRemoveField)
+                            {
+                                if (Permanent.ShowingPermanentCard != null)
+                                {
+                                    if (Permanent.ShowingPermanentCard.WillRemoveFieldObject != null)
+                                    {
+                                        Permanent.ShowingPermanentCard.WillRemoveFieldObject.transform.parent.gameObject.SetActive(true);
+                                        Permanent.ShowingPermanentCard.WillRemoveFieldObject.SetActive(true);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                #region shrink security Digimon display
+                if (GManager.instance.attackProcess.IsAttacking)
+                {
+                    if (GManager.instance.attackProcess.SecurityDigimon != null)
+                    {
+                        if (GManager.instance.GetComponent<Effects>().ShowUseHandCard.gameObject.activeSelf && GManager.instance.GetComponent<Effects>().ShowUseHandCard.cardSource == GManager.instance.attackProcess.SecurityDigimon)
+                        {
+                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().MoveToExecuteCardEffect(GManager.instance.attackProcess.SecurityDigimon));
+                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SecurityDigimon.Owner.brainStormObject.BrainStormCoroutine(GManager.instance.attackProcess.SecurityDigimon));
+                        }
+                    }
+                }
+                #endregion
+            }
+
+            // cut in effect process
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, null));
+
+            foreach (Permanent Permanent in removeFieldPermanents)
+            {
+                if (Permanent != null)
+                {
+                    if (Permanent.TopCard != null)
+                    {
+                        if (Permanent.ShowingPermanentCard != null)
+                        {
+                            if (Permanent.ShowingPermanentCard.WillRemoveFieldObject != null)
+                            {
+                                Permanent.ShowingPermanentCard.WillRemoveFieldObject.SetActive(false);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        #endregion
+
+        foreach (Permanent[] permanentArray in _permanentArrays)
+        {
+            Permanent LinkPermanent = permanentArray[0];
+            Permanent LinkedPermanent = permanentArray[1];
+
+            if (LinkPermanent != null && LinkedPermanent != null)
+            {
+                if (LinkPermanent.TopCard != null && LinkedPermanent.TopCard != null && !LinkedPermanent.IsToken && LinkPermanent.willBeRemoveField)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(LinkPermanent.DiscardEvoRoots());
+
+                    CardSource cardSource = LinkPermanent.TopCard;
+
+                    #region record used effect
+                    if (_cardEffect != null)
+                    {
+                        if (LinkPermanent.TopCard != null)
+                        {
+                            LinkPermanent.PlaceOtherPermanentEffect = _cardEffect;
+                        }
+                    }
+                    #endregion
+
+                    yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveField(
+                        LinkPermanent,
+                        ignoreOverflow: true));
+
+                    yield return ContinuousController.instance.StartCoroutine(LinkedPermanent.AddLinkedCard(cardSource, _cardEffect));
+
+                    cardSource.cEntity_EffectController.InitUseCountThisTurn();
+
+                    addedLinkCards.Add(cardSource);
+
+                    Linked = true;
+                }
+            }
+        }
+
+        #region add log
+        if (addedLinkCards.Count >= 1)
+        {
+            string log = "";
+
+            log += $"Link:";
+
+            foreach (CardSource cardSource in addedLinkCards)
+            {
+                log += $"\n{cardSource.BaseENGCardNameFromEntity}({cardSource.CardID})";
+            }
+
+            log += "\n";
+
+            PlayLog.OnAddLog?.Invoke(log);
+        }
+        #endregion
+
+        #region hide icon
+        if (addedLinkCards.Count >= 1)
+        {
+            if (!_notShowCards)
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(addedLinkCards, "Link Cards", true, true));
+            }
+        }
+
+        #endregion
+    }
+}
+#endregion
+
 #region Place permanents to security
 #region Place permanents to security
 
 
 public class IPutSecurityPermanent
 public class IPutSecurityPermanent

+ 94 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Link.cs

@@ -0,0 +1,94 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectFactory
+{
+    #region Trigger effect of Link
+    public static ActivateClass LinkEffect(CardSource card, Func<bool> condition, Func<Permanent, bool> digimonCondition)
+    {
+        if (card == null) return null;
+        if (!CardEffectCommons.IsExistOnHand(card) || !CardEffectCommons.IsExistOnBattleAreaDigimon(card)) return null;
+        if (CardEffectCommons.HasMatchConditionPermanent(digimonCondition)) return null;
+
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Link", CanUseCondition, card);
+        activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, DataBase.BlastDigivolveEffectDiscription());
+
+        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.IsExistOnHand(card) || CardEffectCommons.IsExistOnBattleAreaDigimon(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 link.", "The opponent is selecting 1 Digimon to link.");
+
+            yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+            IEnumerator SelectPermanentCoroutine(Permanent permanent)
+            {
+                selectedPermanent = permanent;
+
+                yield return null;
+            }
+
+            if (selectedPermanent != null)
+            {
+                if (CardEffectCommons.IsExistOnHand(card))
+                    yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkedCard(card, activateClass));
+                else
+                    yield return ContinuousController.instance.StartCoroutine(new ILinkPermanentToPermanent(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, activateClass).LinkPermanent());
+            }
+        }
+
+        return activateClass;
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Link.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1b84d66e362da6d4784ff76bac269175
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 32 - 6
Assets/Scripts/Permanent.cs

@@ -593,7 +593,7 @@ public class Permanent
     }
     }
     #endregion
     #endregion
 
 
-    #region 退化を受けないか
+    #region Immune From De-Digivolve
     public bool ImmuneFromDeDigivolve()
     public bool ImmuneFromDeDigivolve()
     {
     {
         foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
         foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
@@ -620,15 +620,19 @@ public class Permanent
     }
     }
     #endregion
     #endregion
 
 
-    #region このパーマネントの持つカードリスト
+    #region Card Sources
     public List<CardSource> cardSources = new List<CardSource>();
     public List<CardSource> cardSources = new List<CardSource>();
     #endregion
     #endregion
 
 
-    #region 一番上以外のカード
+    #region Digivolution Cards
     public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
     public List<CardSource> DigivolutionCards => cardSources.Filter(cardSource => cardSource != TopCard);
     #endregion
     #endregion
 
 
-    #region パーマネントのカードリストにカードを追加
+    #region Linked Card
+    public CardSource LinkedCard = null;
+    #endregion
+
+    #region Add Card Source
     public void AddCardSource(CardSource cardSource)
     public void AddCardSource(CardSource cardSource)
     {
     {
         cardSources.Insert(0, cardSource);
         cardSources.Insert(0, cardSource);
@@ -797,7 +801,19 @@ public class Permanent
     }
     }
     #endregion
     #endregion
 
 
-    #region パーマネントのカードリストからカードを除く
+    #region Add Card Source
+    public IEnumerator AddLinkedCard(CardSource cardSource, ICardEffect cardEffect)
+    {
+        yield return null;
+
+        if (LinkedCard != null)
+            RemoveLinkedCard(null);
+
+        LinkedCard = cardSource;
+    }
+    #endregion
+
+    #region RemoveCardSource
     public IEnumerator RemoveCardSource(CardSource cardSource)
     public IEnumerator RemoveCardSource(CardSource cardSource)
     {
     {
         yield return null;
         yield return null;
@@ -806,7 +822,17 @@ public class Permanent
     }
     }
     #endregion
     #endregion
 
 
-    #region このパーマネントの一番上のカード
+    #region Remove Linked Card
+    public IEnumerator RemoveLinkedCard(ICardEffect cardEffect)
+    {
+        //TODO: Add event call if something was removed
+        yield return null;
+
+        LinkedCard = null;
+    }
+    #endregion
+
+    #region Top Card
     public CardSource TopCard
     public CardSource TopCard
     {
     {
         get
         get