Răsfoiți Sursa

double dna conditions

mbunch_kascope 1 an în urmă
părinte
comite
710af3ef7b

+ 20 - 1
Assets/CardEffect/BT17/Red/BT17_095.cs

@@ -289,7 +289,26 @@ namespace DCGO.CardEffects.BT17
 
                         if (selectedLevel7 != null)
                         {
-                            JogressConditionElement[] elements = (JogressConditionElement[])selectedLevel7.jogressCondition.elements.Clone();
+                            JogressCondition dnaCondition = selectedLevel7.jogressCondition[0];
+
+                            if(selectedLevel7.jogressCondition.Count > 1)
+                            {
+                                #region select DNA condition
+                                SelectDNACondition selectDNACondition = new SelectDNACondition();
+                                selectDNACondition.SetUp(selectedLevel7.Owner, selectedLevel7, SelectDNA);
+
+                                yield return ContinuousController.instance.StartCoroutine(selectDNACondition.Activate());
+
+                                IEnumerator SelectDNA(int dnaSelection)
+                                {
+                                    dnaCondition = selectedLevel7.jogressCondition[dnaSelection];
+
+                                    yield return null;
+                                }
+                                #endregion
+                            }
+
+                            JogressConditionElement[] elements = (JogressConditionElement[])dnaCondition.elements.Clone();
 
                             for (int i = 0; i < elements.Length; i++)
                             {

+ 21 - 1
Assets/CardEffect/EX6/White/EX6_072.cs

@@ -48,6 +48,7 @@ namespace DCGO.CardEffects.EX6
             if (timing == EffectTiming.OptionSkill)
             {
                 CardSource selectedLevel7 = null;
+                JogressCondition selectedDNACondition = null; 
                 List<Permanent> allowedPermanents = new List<Permanent>();
                 List<CardSource> allowedCards = new List<CardSource>();
 
@@ -88,7 +89,7 @@ namespace DCGO.CardEffects.EX6
 
                 void FilterAllowableSelections(Permanent selectedPermanent = null) 
                 {
-                    JogressConditionElement[] elements = (JogressConditionElement[])selectedLevel7.jogressCondition.elements.Clone();
+                    JogressConditionElement[] elements = (JogressConditionElement[])selectedDNACondition.elements.Clone();
 
                     allowedPermanents = new List<Permanent>();
                     allowedCards = new List<CardSource>();
@@ -172,6 +173,25 @@ namespace DCGO.CardEffects.EX6
 
                     if(selectedLevel7 != null)
                     {
+                        selectedDNACondition = selectedLevel7.jogressCondition[0];
+
+                        if (selectedLevel7.jogressCondition.Count > 1)
+                        {
+                            #region select DNA condition
+                            SelectDNACondition selectDNACondition = new SelectDNACondition();
+                            selectDNACondition.SetUp(selectedLevel7.Owner, selectedLevel7, SelectDNA);
+
+                            yield return ContinuousController.instance.StartCoroutine(selectDNACondition.Activate());
+
+                            IEnumerator SelectDNA(int dnaSelection)
+                            {
+                                selectedDNACondition = selectedLevel7.jogressCondition[dnaSelection];
+
+                                yield return null;
+                            }
+                            #endregion
+                        }
+
                         FilterAllowableSelections();
 
                         #region Selecting Field Permanent for DNA

+ 19 - 2
Assets/Scripts/CardController.cs

@@ -572,6 +572,22 @@ public class PlayCardClass
 
             #endregion
 
+            #region select DNA condition
+            int baseDNA = -1;
+
+            SelectDNACondition selectDNACondition = new SelectDNACondition();
+            selectDNACondition.SetUp(card.Owner, card, SelectDNA);
+
+            yield return ContinuousController.instance.StartCoroutine(selectDNACondition.Activate());
+
+            IEnumerator SelectDNA(int dnaSelection)
+            {
+                baseDNA = dnaSelection;
+
+                yield return null;
+            }
+            #endregion
+
             #region HashTable Setting
 
             Hashtable hashtable = CardEffectCommons.WouldEnterFieldHashtable(
@@ -681,7 +697,7 @@ public class PlayCardClass
                 {
                     if (card.jogressCondition != null)
                     {
-                        int cost = card.GetPayingCostWithBaseCost(card.jogressCondition.cost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
+                        int cost = card.GetPayingCostWithBaseCost(card.jogressCondition[baseDNA].cost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
 
                         GManager.instance.memoryObject.ShowMemoryPredictionLine(card.Owner.ExpectedMemory(cost));
                     }
@@ -776,13 +792,14 @@ public class PlayCardClass
                 if (!isJogress)
                 {
                     Cost = card.GetPayingCostWithBaseCost(baseCost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
+                    Cost = card.GetPayingCostWithBaseCost(baseCost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
                 }
 
                 else
                 {
                     if (card.jogressCondition != null)
                     {
-                        Cost = card.GetPayingCostWithBaseCost(card.jogressCondition.cost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
+                        Cost = card.GetPayingCostWithBaseCost(card.jogressCondition[baseDNA].cost, Root, targetPermanents, checkAvailability: false, FixedCost: _fixedCost);
                     }
                 }
 

+ 5 - 3
Assets/Scripts/CardSource.cs

@@ -1662,11 +1662,13 @@ public class CardSource : MonoBehaviour
 
         if (jogressCondition != null)
         {
-            foreach (JogressConditionElement element in jogressCondition.elements)
-                checkStrings.Add(element.SelectMessage);
+            foreach(JogressCondition jogress in jogressCondition)
+            {
+                foreach (JogressConditionElement element in jogress.elements)
+                    checkStrings.Add(element.SelectMessage);
+            }
         }
 
-
         foreach (string checkString in checkStrings)
         {
             if (!string.IsNullOrEmpty(checkString))

+ 95 - 0
Assets/Scripts/SelectDNACondition.cs

@@ -0,0 +1,95 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using Photon.Pun;
+using System;
+using System.Linq;
+
+
+public class SelectDNACondition : MonoBehaviourPunCallbacks
+{
+    public void SetUp
+        (Player SelectPlayer,
+        CardSource targetDNA,
+        Func<int, IEnumerator> SelectDNACoroutine)
+    {
+        _selectPlayer = SelectPlayer;
+        _targetDNA = targetDNA;
+        _selectDNACoroutine = SelectDNACoroutine;
+        _notDoSync = false;
+        _isDigivolutionCost = false;
+    }
+
+    Player _selectPlayer = null;
+    CardSource _targetDNA = null;
+    Func<int, IEnumerator> _selectDNACoroutine = null;
+    List<int> _candidates = new List<int>();
+    int _selectedCount = 0;
+    bool _endSelect = false;
+    bool _notDoSync = false;
+    bool _isDigivolutionCost = false;
+
+    public IEnumerator Activate()
+    {
+        if (!_notDoSync)
+        {
+            yield return GManager.instance.photonWaitController.StartWait("SelectDNACondition");
+        }
+
+        if(_targetDNA.jogressCondition.Count > 1)
+        {
+            if (_targetDNA.jogressCondition.Count == 1)
+            {
+                SetDNACondition(0);
+            }
+            else
+            {
+                List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
+
+                for (int i = 0; i < _targetDNA.jogressCondition.Count; i++)
+                {
+                    string message = $"";
+
+                    for (int e = 0; e < _targetDNA.jogressCondition[i].elements.Length; e++)
+                    {
+                        message += $"{_targetDNA.jogressCondition[i].elements[e].SelectMessage}";
+
+                        if (e < _targetDNA.jogressCondition[i].elements.Length - 1)
+                            message += " + ";
+                    }
+
+                    selectionElements.Add(new(message: $"{message}", value: i, spriteIndex: 0));
+                }
+
+                string selectPlayerMessage = "Which DNA do you want?";
+                string notSelectPlayerMessage = "The opponent is choosing from which DNA to do.";
+
+                GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
+                    selectPlayer: _targetDNA.Owner, selectPlayerMessage: selectPlayerMessage,
+                    notSelectPlayerMessage: notSelectPlayerMessage);
+
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
+
+                photonView.RPC("SetCount", RpcTarget.All, GManager.instance.userSelectionManager.SelectedIntValue);
+            }
+        }
+
+        yield return new WaitWhile(() => !_endSelect);
+        _endSelect = false;
+
+        GManager.instance.commandText.CloseCommandText();
+        yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
+
+        if (_selectDNACoroutine != null)
+        {
+            yield return ContinuousController.instance.StartCoroutine(_selectDNACoroutine(_selectedCount));
+        }
+    }
+
+    [PunRPC]
+    public void SetDNACondition(int selectedCount)
+    {
+        _selectedCount = selectedCount;
+        _endSelect = true;
+    }
+}

+ 11 - 0
Assets/Scripts/SelectDNACondition.cs.meta

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

+ 39 - 16
Assets/Scripts/SelectJogressEffect.cs

@@ -147,23 +147,26 @@ public class SelectJogressEffect : MonoBehaviour
             {
                 if (_card.jogressCondition != null)
                 {
-                    if (_card.jogressCondition.elements != null)
+                    foreach(JogressCondition dnaCondition in _card.jogressCondition)
                     {
-                        if (_card.jogressCondition.elements.Length == 2)
+                        if(dnaCondition != null)
                         {
-                            if (GManager.instance != null)
+                            if(dnaCondition.elements.Length == 2)
                             {
-                                if (GManager.instance.turnStateMachine != null)
+                                if (GManager.instance != null)
                                 {
-                                    if (GManager.instance.turnStateMachine.gameContext != null)
+                                    if (GManager.instance.turnStateMachine != null)
                                     {
-                                        if (GManager.instance.turnStateMachine.gameContext.ActiveCardList.Count >= 1)
+                                        if (GManager.instance.turnStateMachine.gameContext != null)
                                         {
-                                            selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
-
-                                            if (selectPermanentEffect != null)
+                                            if (GManager.instance.turnStateMachine.gameContext.ActiveCardList.Count >= 1)
                                             {
-                                                active = true;
+                                                selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                                                if (selectPermanentEffect != null)
+                                                {
+                                                    active = true;
+                                                }
                                             }
                                         }
                                     }
@@ -178,10 +181,30 @@ public class SelectJogressEffect : MonoBehaviour
         if (active)
         {
             List<Permanent> selectedEvoRoots = new List<Permanent>();
+            JogressCondition selectedDNA = _card.jogressCondition[0];
+
+            if(_card.jogressCondition.Count > 1)
+            {
+                #region select DNA condition
+                SelectDNACondition selectDNACondition = new SelectDNACondition();
+                selectDNACondition.SetUp(_card.Owner, _card, SelectDNA);
+
+                yield return ContinuousController.instance.StartCoroutine(selectDNACondition.Activate());
+
+                IEnumerator SelectDNA(int dnaSelection)
+                {
+                    selectedDNA = _card.jogressCondition[dnaSelection];
+
+                    yield return null;
+                }
+                #endregion
+            }
+
+            
 
-            for (int i = 0; i < _card.jogressCondition.elements.Length; i++)
+            for (int i = 0; i < selectedDNA.elements.Length; i++)
             {
-                JogressConditionElement element = _card.jogressCondition.elements[i];
+                JogressConditionElement element = selectedDNA.elements[i];
 
                 bool CanSelectPermanentCondition(Permanent permanent)
                 {
@@ -212,7 +235,7 @@ public class SelectJogressEffect : MonoBehaviour
 
                                                             else
                                                             {
-                                                                JogressConditionElement element1 = _card.jogressCondition.elements[1];
+                                                                JogressConditionElement element1 = selectedDNA.elements[1];
 
                                                                 if (_card.Owner.GetBattleAreaDigimons().Count((permanent1) => permanent1 != permanent && element1.EvoRootCondition(permanent1) && _customPermanentConditions[0](permanent1)) == 0)
                                                                 {
@@ -264,7 +287,7 @@ public class SelectJogressEffect : MonoBehaviour
                                                     {
                                                         if (_customPermanentConditions[0](permanent) || _customPermanentConditions[1](permanent))
                                                         {
-                                                            JogressConditionElement element1 = _card.jogressCondition.elements[1];
+                                                            JogressConditionElement element1 = selectedDNA.elements[1];
 
                                                             if (_customPermanentConditions[0](permanent))
                                                             {
@@ -303,7 +326,7 @@ public class SelectJogressEffect : MonoBehaviour
                                         List<Permanent> nextCandidates = _card.Owner.GetBattleAreaDigimons()
                                             .Filter(permanent1 => permanent1 != permanent);
 
-                                        if (nextCandidates.Count(_card.jogressCondition.elements[1].EvoRootCondition) == 0)
+                                        if (nextCandidates.Count(selectedDNA.elements[1].EvoRootCondition) == 0)
                                         {
                                             return false;
                                         }
@@ -371,7 +394,7 @@ public class SelectJogressEffect : MonoBehaviour
             }
 
             //do not jogress
-            if (selectedEvoRoots.Count != _card.jogressCondition.elements.Length)
+            if (selectedEvoRoots.Count != selectedDNA.elements.Length)
             {
                 if (_noSelectCoroutine != null)
                 {

+ 2 - 1
Assets/Scripts/TurnStateMachine.cs

@@ -2963,7 +2963,8 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
 
                 if (canJogress)
                 {
-                    payingCosts.Add(cardSource.GetPayingCostWithBaseCost(cardSource.jogressCondition.cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: false));
+                    foreach(JogressCondition dnaCondition in cardSource.jogressCondition)
+                        payingCosts.Add(cardSource.GetPayingCostWithBaseCost(dnaCondition.cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: false));
                 }
 
                 if (canBurst)