mbunch_kascope пре 1 година
родитељ
комит
8f0048aaa8

+ 106 - 5
Assets/Scripts/CardSource.cs

@@ -2441,6 +2441,61 @@ public class CardSource : MonoBehaviour
     }
     #endregion
 
+    #region whether this card can App Fusion
+    public bool CanPlayAppFusion(bool PayCost)
+    {
+        if (appFusionCondition != null)
+        {
+            if (PayCost)
+            {
+                int cost = appFusionCondition.cost;
+
+                cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { new Permanent(new List<CardSource>()) }, checkAvailability: true);
+
+                if (Owner.MaxMemoryCost < cost)
+                {
+                    return false;
+                }
+            }
+
+            if (Owner.GetBattleAreaDigimons().Count >= 1)
+            {
+                foreach (Permanent digimon in Owner.GetFieldPermanents())
+                {
+                    if (digimon != null)
+                    {
+                        if (!this.CanNotEvolve(digimon))
+                        {
+                            if (appFusionCondition.digimonCondition(digimon))
+                            {
+                                foreach(CardSource linkedCard in digimon.LinkedCards.Map(linked => linked.Source))
+                                {
+                                    if (appFusionCondition.linkedCondition(linkedCard))
+                                    {
+                                        if (PayCost)
+                                        {
+                                            int cost = appFusionCondition.cost;
+
+                                            cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
+
+                                            if (Owner.MaxMemoryCost < cost)
+                                            {
+                                                return false;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
     #region whether target permanent can Burst digivolve into this card
     public bool CanBurstDigivolutionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
     {
@@ -2495,6 +2550,52 @@ public class CardSource : MonoBehaviour
     }
     #endregion
 
+    #region whether target permanent can App Fusion into this card
+    public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
+    {
+        if (targetPermanent != null)
+        {
+            if (targetPermanent.TopCard != null)
+            {
+                if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent))
+                {
+                    if (this.CanPlayAppFusion(PayCost))
+                    {
+                        if (appFusionCondition != null)
+                        {
+                            if (!this.CanNotEvolve(targetPermanent))
+                            {
+                                if (appFusionCondition.digimonCondition(targetPermanent))
+                                {
+                                    foreach (CardSource linkedCard in targetPermanent.LinkedCards.Map(linked => linked.Source))
+                                    {
+                                        if (appFusionCondition.linkedCondition(linkedCard))
+                                        {
+                                            if (PayCost)
+                                            {
+                                                int cost = appFusionCondition.cost;
+
+                                                cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
+
+                                                if (Owner.MaxMemoryCost < cost)
+                                                {
+                                                    return false;
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
     #region Whether this card's digiXrosCondition contains target card 
     public bool IsContainDigiXrosCondition(CardSource cardSource)
     {
@@ -2804,16 +2905,16 @@ public class BurstDigivolutionCondition
 
 public class AppFusionCondition
 {
-    public AppFusionCondition(Func<Permanent, bool> tamerCondition, string selectTamerMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
+    public AppFusionCondition(Func<CardSource, bool> linkedCondition, string selectLinkMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)
     {
-        this.tamerCondition = tamerCondition;
-        this.selectTamerMessage = selectTamerMessage;
+        this.linkedCondition = linkedCondition;
+        this.selectLinkMessage = selectLinkMessage;
         this.digimonCondition = digimonCondition;
         this.selectDigimonMessage = selectDigimonMessage;
         this.cost = cost;
     }
-    public Func<Permanent, bool> tamerCondition { get; private set; } = null;
-    public string selectTamerMessage { get; private set; } = null;
+    public Func<CardSource, bool> linkedCondition { get; private set; } = null;
+    public string selectLinkMessage { get; private set; } = null;
     public Func<Permanent, bool> digimonCondition { get; private set; } = null;
     public string selectDigimonMessage { get; private set; } = null;
 

+ 69 - 1
Assets/Scripts/Effect Examples/Link_Examples.cs

@@ -177,9 +177,77 @@ namespace DCGO.CardEffects.Examples
                     card: card,
                     condition: Condition));
             }
+            #endregion
+
+            #region App Fusion
+            if (timing == EffectTiming.None)
+            {
+                AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
+                addAppFusionConditionClass.SetUpICardEffect($"App Fusion", CanUseCondition, card);
+                addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
+                addAppFusionConditionClass.SetNotShowUI(true);
+                cardEffects.Add(addAppFusionConditionClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return true;
+                }
+
+                AppFusionCondition GetAppFusion(CardSource cardSource)
+                {
+                    if (cardSource == card)
+                    {
+                        bool linkCondition(CardSource source)
+                        {
+                            if (source != null)
+                            {
+                                return true;
+                            }
+
+                            return false;
+                        }
+
+                        bool digimonCondition(Permanent permanent)
+                        {
+                            if (permanent != null)
+                            {
+                                if (permanent.TopCard != null)
+                                {
+                                    if (permanent.TopCard.Owner == card.Owner)
+                                    {
+                                        if (permanent.TopCard.Owner.GetFieldPermanents().Contains(permanent))
+                                        {
+                                            if (!card.CanNotEvolve(permanent))
+                                            {
+                                                if (permanent.TopCard.EqualsCardName("Timemon"))
+                                                {
+                                                    return true;
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+
+                            return false;
+                        }
+
+                        AppFusionCondition AppFusionCondition = new AppFusionCondition(
+                            linkedCondition: linkCondition,
+                            selectLinkMessage: "1 Linked card",
+                            digimonCondition: digimonCondition,
+                            selectDigimonMessage: "1 [Timemon]",
+                            cost: 0);
+
+                        return AppFusionCondition;
+                    }
+
+                    return null;
+                }
+            }
+            #endregion
 
             return cardEffects;
         }
-        #endregion
     }
 }

+ 4 - 1
Assets/Scripts/GManager.cs

@@ -101,9 +101,12 @@ public class GManager : MonoBehaviourPun
     [Header("ジョグレス選択")]
     public SelectJogressEffect selectJogressEffect;
 
-    [Header("バースト進化選択")]
+    [Header("burst evolution selection")]
     public SelectBurstDigivolutionEffect selectBurstDigivolutionEffect;
 
+    [Header("app fusion selection")]
+    public SelectAppFusionEffect selectAppFusionEffect;
+
     [Header("自動処理チェック(割り込み処理)")]
     public AutoProcessing autoProcessing_CutIn;
     [Header("ユーザー選択")]

+ 32 - 51
Assets/Scripts/SelectAppFusionEffect.cs

@@ -22,19 +22,19 @@ public class SelectAppFusionEffect : MonoBehaviour
         _noSelectCoroutine = noSelectCoroutine;
     }
 
-    public void SetUp_SelectTamer
+    public void SetUp_SelectLink
         (CardSource card,
         bool isLocal,
         bool isPayCost,
         bool canNoSelect,
-        Func<Permanent, IEnumerator> endSelectCoroutine_SelectTamer,
+        Func<CardSource, IEnumerator> endSelectCoroutine_SelectLink,
         Func<IEnumerator> noSelectCoroutine)
     {
         _card = card;
         _isLocal = isLocal;
         _isPayCost = isPayCost;
         _canNoSelect = canNoSelect;
-        _endSelectCoroutine_SelectTamer = endSelectCoroutine_SelectTamer;
+        _endSelectCoroutine_SelectLink = endSelectCoroutine_SelectLink;
         _noSelectCoroutine = noSelectCoroutine;
     }
 
@@ -46,7 +46,7 @@ public class SelectAppFusionEffect : MonoBehaviour
     bool _canNoSelect = false;
     Func<IEnumerator> _endSelectCoroutine_Digivolve = null;
     Func<IEnumerator> _endSelectCoroutine_AppFusion = null;
-    Func<Permanent, IEnumerator> _endSelectCoroutine_SelectTamer = null;
+    Func<CardSource, IEnumerator> _endSelectCoroutine_SelectLink = null;
     Func<IEnumerator> _noSelectCoroutine = null;
     public bool TamerBounced { get; private set; } = false;
 
@@ -105,16 +105,16 @@ public class SelectAppFusionEffect : MonoBehaviour
         }
     }
 
-    public IEnumerator SelectTamer()
+    public IEnumerator SelectLink(Permanent targetPermanent)
     {
         bool active = false;
-        SelectPermanentEffect selectPermanentEffect = null;
+        SelectCardEffect selectCardEffect = null;
 
-        if (_card != null)
+        if (_card != null && targetPermanent != null)
         {
             if (_card.CanPlayBurst(_isPayCost))
             {
-                if (_card.burstDigivolutionCondition != null)
+                if (_card.appFusionCondition != null)
                 {
                     if (GManager.instance != null)
                     {
@@ -124,9 +124,9 @@ public class SelectAppFusionEffect : MonoBehaviour
                             {
                                 if (GManager.instance.turnStateMachine.gameContext.ActiveCardList.Count >= 1)
                                 {
-                                    selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+                                    selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
 
-                                    if (selectPermanentEffect != null)
+                                    if (selectCardEffect != null)
                                     {
                                         active = true;
                                     }
@@ -140,68 +140,49 @@ public class SelectAppFusionEffect : MonoBehaviour
 
         if (active)
         {
-            Permanent selectedTamer = null;
+            CardSource selectedLink = null;
 
-            AppFusionCondition burstDigivolutionCondition = _card.appFusionCondition;
+            AppFusionCondition appFusionCondition = _card.appFusionCondition;
 
-            bool CanSelectPermanentCondition(Permanent permanent)
+            bool CanSelectSourceCondition(CardSource link)
             {
-                if (permanent != null)
-                {
-                    if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
-                    {
-                        if (burstDigivolutionCondition.tamerCondition != null)
-                        {
-                            if (burstDigivolutionCondition.tamerCondition(permanent))
-                            {
-                                if (!permanent.CannotReturnToHand(null))
-                                {
-                                    return true;
-                                }
-                            }
-                        }
-                    }
-                }
-
-                return false;
+                return (link != null);
             }
 
-            int maxCount = Math.Min(1, _card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
+            int maxCount = Math.Min(1, targetPermanent.LinkedCards.Count(link => CanSelectSourceCondition(link.Source)));
 
             if (maxCount >= 1)
             {
-                selectPermanentEffect.SetUp(
-                selectPlayer: _card.Owner,
-                canTargetCondition: CanSelectPermanentCondition,
+                selectCardEffect.SetUp(
+                canTargetCondition: CanSelectSourceCondition,
                 canTargetCondition_ByPreSelecetedList: null,
                 canEndSelectCondition: null,
+                canNoSelect: () => _canNoSelect,
+                selectCardCoroutine: SelectCardCoroutine,
+                afterSelectCardCoroutine: null,
+                message: $"Select {appFusionCondition.selectLinkMessage}.",
                 maxCount: maxCount,
-                canNoSelect: _canNoSelect,
                 canEndNotMax: false,
-                selectPermanentCoroutine: SelectPermanentCoroutine,
-                afterSelectPermanentCoroutine: null,
-                mode: SelectPermanentEffect.Mode.Custom,
+                isShowOpponent: true,
+                mode: SelectCardEffect.Mode.Custom,
+                root: SelectCardEffect.Root.Custom,
+                customRootCardList: targetPermanent.LinkedCards.Map(link => link.Source),
+                canLookReverseCard: false,
+                selectPlayer: _card.Owner,
                 cardEffect: null);
 
-                selectPermanentEffect.SetUpCustomMessage($"Select {burstDigivolutionCondition.selectTamerMessage}.", $"The opponent is selecting {burstDigivolutionCondition.selectTamerMessage}.");
-
-                if (this._isLocal)
-                {
-                    selectPermanentEffect.SetIsLocal();
-                }
-
-                yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
 
-                IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                IEnumerator SelectCardCoroutine(CardSource source)
                 {
-                    selectedTamer = permanent;
+                    selectedLink = source;
 
                     yield return null;
                 }
             }
 
             //ƒo�[ƒXƒg�i‰»‚µ‚È‚¢
-            if (selectedTamer == null)
+            if (selectedLink == null)
             {
                 if (_noSelectCoroutine != null)
                 {
@@ -214,7 +195,7 @@ public class SelectAppFusionEffect : MonoBehaviour
             {
                 if (_endSelectCoroutine_AppFusion != null)
                 {
-                    yield return ContinuousController.instance.StartCoroutine(_endSelectCoroutine_SelectTamer(selectedTamer));
+                    yield return ContinuousController.instance.StartCoroutine(_endSelectCoroutine_SelectLink(selectedLink));
                 }
             }
         }

+ 63 - 5
Assets/Scripts/TurnStateMachine.cs

@@ -9,6 +9,7 @@ using UnityEngine;
 //using Hashtable = ExitGames.Client.Photon.Hashtable;
 using UnityEngine.EventSystems;
 using UnityEngine.UI;
+using static UnityEngine.ParticleSystem;
 using static UnityEngine.UIElements.UxmlAttributeDescription;
 public class TurnStateMachine : MonoBehaviourPunCallbacks
 {
@@ -2164,27 +2165,34 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
                                                     bool canNormalDigivolution = handCard.cardSource.CanPlayCardTargetFrame(fieldCardFrame, true, null);
                                                     bool canJogressDigivolution = handCard.cardSource.CanJogressFromTargetPermanent(fieldCardFrame.GetFramePermanent(), true);
                                                     bool canBurstDigivolution = handCard.cardSource.CanBurstDigivolutionFromTargetPermanent(fieldCardFrame.GetFramePermanent(), true);
+                                                    bool canAppFusion = handCard.cardSource.CanAppFusionFromTargetPermanent(fieldCardFrame.GetFramePermanent(), true);
 
                                                     //Only normal evolution possible
-                                                    if (canNormalDigivolution && !canJogressDigivolution && !canBurstDigivolution)
+                                                    if (canNormalDigivolution && !canJogressDigivolution && !canBurstDigivolution && !canAppFusion)
                                                     {
                                                         Digivolution();
                                                     }
 
                                                     //Only jogless is possible
-                                                    else if (!canNormalDigivolution && canJogressDigivolution && !canBurstDigivolution)
+                                                    else if (!canNormalDigivolution && canJogressDigivolution && !canBurstDigivolution && !canAppFusion)
                                                     {
                                                         SelectJogressDigivolutionCards(true);
                                                     }
 
                                                     //Only burst evolution possible
-                                                    else if (!canNormalDigivolution && !canJogressDigivolution && canBurstDigivolution)
+                                                    else if (!canNormalDigivolution && !canJogressDigivolution && canBurstDigivolution && !canAppFusion)
                                                     {
                                                         SelectBurstDigivolutionCards(true);
                                                     }
 
+                                                    //Only app fusion possible
+                                                    else if (!canNormalDigivolution && !canJogressDigivolution && !canBurstDigivolution && canAppFusion)
+                                                    {
+                                                        SelectAppFusionCards(true);
+                                                    }
+
                                                     //Normal evolution and Jogress possible
-                                                    else if (canNormalDigivolution && canJogressDigivolution && !canBurstDigivolution)
+                                                    else if (canNormalDigivolution && canJogressDigivolution && !canBurstDigivolution && !canAppFusion)
                                                     {
                                                         Vector3 Pos = handCard.transform.position;
 
@@ -2331,7 +2339,7 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
                                                     }
                                                     #endregion
 
-                                                    #region バースト進化元とテイマーを選択
+                                                    #region Select the burst evolution source and tamer
                                                     void SelectBurstDigivolutionCards(bool move)
                                                     {
                                                         Vector3 Pos = handCard.transform.position;
@@ -2381,6 +2389,56 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
                                                     }
                                                     #endregion
 
+                                                    #region Select the app fusion source and link card
+                                                    void SelectAppFusionCards(bool move)
+                                                    {
+                                                        Vector3 Pos = handCard.transform.position;
+
+                                                        ResetUI();
+
+                                                        handCard.transform.GetChild(0).gameObject.SetActive(false);
+
+                                                        StartCoroutine(SelectAppFusionTarget());
+
+                                                        IEnumerator SelectAppFusionTarget()
+                                                        {
+                                                            isSync = true;
+
+                                                            if (move)
+                                                            {
+                                                                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().MoveToExecuteCardEffect_SetPosition(handCard.cardSource, Pos));
+                                                                handCard.transform.position = handCard.cardSource.Owner.brainStormObject.BrainStormHandCards[0].transform.position;
+                                                            }
+
+                                                            yield return ContinuousController.instance.StartCoroutine(handCard.cardSource.Owner.brainStormObject.BrainStormCoroutine(handCard.cardSource));
+
+                                                            GManager.instance.selectAppFusionEffect.SetUp_SelectLink
+                                                                (card: handCard.cardSource,
+                                                                isLocal: true,
+                                                                isPayCost: true,
+                                                                canNoSelect: true,
+                                                                endSelectCoroutine_SelectLink: EndSelectCoroutine_SelectLink,
+                                                                noSelectCoroutine: _NoSelectCoroutine);
+
+                                                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectAppFusionEffect.SelectLink(targetPermanent));
+
+                                                            IEnumerator EndSelectCoroutine_SelectLink(CardSource cardSource)
+                                                            {
+                                                                yield return null;
+                                                                //photonView.RPC("SetPlayCard", RpcTarget.All, handCard.cardSource.CardIndex, fieldCardFrame.FrameID, new int[0], permanent.PermanentFrame.FrameID);
+                                                            }
+
+                                                            IEnumerator _NoSelectCoroutine()
+                                                            {
+                                                                yield return null;
+                                                                yield return StartCoroutine(Return());
+                                                            }
+
+                                                            isSync = false;
+                                                        }
+                                                    }
+                                                    #endregion
+
                                                     #region usually evolves
                                                     void Digivolution()
                                                     {