Răsfoiți Sursa

Added Player Selection Queue

BennAbbot 3 luni în urmă
părinte
comite
bc93ac0b90

+ 22 - 14
Assets/Scripts/Script/MultipleSkills.cs

@@ -1,10 +1,11 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using Photon;
+using Photon;
 using Photon.Pun;
 using System;
+using System.Collections;
+using System.Collections.Generic;
 using System.Linq;
+using UnityEditor.Experimental.GraphView;
+using UnityEngine;
 
 public class MultipleSkills : MonoBehaviourPunCallbacks
 {
@@ -63,7 +64,6 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
         IsUsing = false;
     }
 
-    bool _endSelect = false;
     int _skillIndex;
 
     bool IsCutinEffect(bool CheckNewTriggredSkill_mainStack) => !CheckNewTriggredSkill_mainStack && _autoProcessing != GManager.instance.autoProcessing;
@@ -252,7 +252,7 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
                                 }
                             }
 
-                            photonView.RPC("SetTargetSkill", RpcTarget.All, skillIndex);
+                            photonView.RPC("SetTargetSkill", RpcTarget.All, player.PlayerID, skillIndex);
                         }
 
                         else
@@ -260,7 +260,7 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
                             #region AI
                             if (GManager.instance.IsAI)
                             {
-                                SetTargetSkill(0);
+                                SetTargetSkill(player.PlayerID, 0);
                             }
                             #endregion
                         }
@@ -309,7 +309,7 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
                                 skillIndex = AutomaticOrder.GetSkillIndexAutomaticOrder(skillInfos_active);
                             }
 
-                            photonView.RPC("SetTargetSkill", RpcTarget.All, skillIndex);
+                            photonView.RPC("SetTargetSkill", RpcTarget.All, player.PlayerID, skillIndex);
                         }
 
                         else
@@ -322,14 +322,16 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
                             #region AI
                             if (GManager.instance.IsAI)
                             {
-                                SetTargetSkill(0);
+                                SetTargetSkill(player.PlayerID, 0);
                             }
                             #endregion
                         }
                     }
 
-                    yield return new WaitWhile(() => !_endSelect);
-                    _endSelect = false;
+                    yield return new WaitUntil(() => player.HasPlayerSelection());
+
+                    ValueSelection valueSelection = player.DequeuePlayerSelection<ValueSelection>();
+                    _skillIndex = valueSelection != null ? valueSelection.ValueAsInt() : 0;
 
                     GManager.instance.commandText.CloseCommandText();
                     yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
@@ -427,9 +429,15 @@ public class MultipleSkills : MonoBehaviourPunCallbacks
     }
 
     [PunRPC]
-    public void SetTargetSkill(int skillIndex)
+    public void SetTargetSkill(int playerID, int skillIndex)
     {
-        _skillIndex = skillIndex;
-        _endSelect = true;
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(skillIndex));
     }
 }

+ 23 - 15
Assets/Scripts/Script/OptionalSkill.cs

@@ -1,20 +1,22 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
 using Photon;
 using Photon.Pun;
-using System.Linq;
+using Photon.Realtime;
 using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
 public class OptionalSkill : MonoBehaviourPunCallbacks
 {
     public string waitingText { get; set; } = "The opponent is considering whether to use the effect.";
-    bool _endSelect = false;
+
     bool _useOptional = false;
     public IEnumerator SelectOptional(ICardEffect cardEffect, Hashtable hash)
     {
         List<string> _YesNoTexts = new List<string>() { "Use", "Not use" };
 
-        _endSelect = false;
+        Player player = cardEffect.EffectSourceCard.Owner;
+
         _useOptional = false;
 
         string _Message;
@@ -90,10 +92,10 @@ public class OptionalSkill : MonoBehaviourPunCallbacks
 
             List<Command_SelectCommand> commands = new List<Command_SelectCommand>()
             {
-                new Command_SelectCommand(_YesNoTexts[0] ,() => photonView.RPC("SetUseOptional",RpcTarget.All,true),0),
+                new Command_SelectCommand(_YesNoTexts[0] ,() => photonView.RPC("SetUseOptional",RpcTarget.All, player.PlayerID, true),0),
             };
 
-            GManager.instance.BackButton.OpenSelectCommandButton(_YesNoTexts[1], () => { photonView.RPC("SetUseOptional", RpcTarget.All, false); }, 0);
+            GManager.instance.BackButton.OpenSelectCommandButton(_YesNoTexts[1], () => { photonView.RPC("SetUseOptional", RpcTarget.All, player.PlayerID, false); }, 0);
 
             GManager.instance.selectCommandPanel.SetUpCommandButton(commands);
         }
@@ -109,13 +111,13 @@ public class OptionalSkill : MonoBehaviourPunCallbacks
 
             if (GManager.instance.IsAI)
             {
-                _endSelect = true;
-                _useOptional = RandomUtility.IsSucceedProbability(0.9f);
+                SetUseOptional(player.PlayerID, RandomUtility.IsSucceedProbability(0.9f));
             }
         }
 
-        yield return new WaitWhile(() => !_endSelect);
-        _endSelect = false;
+        yield return new WaitUntil(() => player.HasPlayerSelection());
+        ValueSelection valueSelection = player.DequeuePlayerSelection<ValueSelection>();
+        _useOptional = valueSelection != null ? valueSelection.ValueAsBool() : false;
 
         GManager.instance.selectCommandPanel.Off();
 
@@ -131,9 +133,15 @@ public class OptionalSkill : MonoBehaviourPunCallbacks
     }
 
     [PunRPC]
-    public void SetUseOptional(bool useOptional)
+    public void SetUseOptional(int playerID, bool useOptional)
     {
-        _useOptional = useOptional;
-        _endSelect = true;
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(useOptional));
     }
 }

+ 26 - 0
Assets/Scripts/Script/Player.cs

@@ -189,6 +189,32 @@ public class Player : MonoBehaviour
 
     #endregion
 
+    #region Selection Queue
+    Queue<IPlayerSelection> _playerSelectionQueue = new Queue<IPlayerSelection>();
+
+    public void QueuePlayerSelection(IPlayerSelection selection)
+    {
+        _playerSelectionQueue.Enqueue(selection);
+    }
+
+    public T DequeuePlayerSelection<T>() where T : class, IPlayerSelection
+    {
+        IPlayerSelection playerSelection = _playerSelectionQueue.Dequeue();
+        if (playerSelection is not T)
+        {
+            Debug.LogWarning("Unexpected Player Selection", this);
+            return null;
+        }
+
+        return playerSelection as T;
+    }
+
+    public bool HasPlayerSelection()
+    {
+        return _playerSelectionQueue.Count > 0;
+    }
+    #endregion
+
     #region セキュリティアタックの座標
     public Vector3 SecurityAttackLocalCanvasPosition;
     #endregion

+ 9 - 0
Assets/Scripts/Script/PlayerSelection/CardSelection.cs

@@ -0,0 +1,9 @@
+public class CardSelection : IPlayerSelection
+{
+    public int[] CardIDList { get; private set; }
+
+    public CardSelection(int[] cardIDList)
+    {
+        CardIDList = cardIDList;
+    }
+}

+ 6 - 0
Assets/Scripts/Script/PlayerSelection/IPlayerSelection.cs

@@ -0,0 +1,6 @@
+using UnityEngine;
+
+public interface IPlayerSelection
+{
+
+}

+ 11 - 0
Assets/Scripts/Script/PlayerSelection/PermanentSelection.cs

@@ -0,0 +1,11 @@
+public class PermanentSelection : IPlayerSelection
+{
+    public bool[] IsTurnPlayerList { get; private set; }
+    public int[] PermanentIDList { get; private set; }
+
+    public PermanentSelection(bool[] isTurnPlayerList, int[] permanentIDList)
+    {
+        IsTurnPlayerList = isTurnPlayerList;
+        PermanentIDList = permanentIDList;
+    }
+}

+ 24 - 0
Assets/Scripts/Script/PlayerSelection/ValueSelection.cs

@@ -0,0 +1,24 @@
+public class ValueSelection : IPlayerSelection
+{
+    public int _value;
+
+    public ValueSelection(int value)
+    {
+        _value = value;
+    }
+
+    public ValueSelection(bool value)
+    {
+        _value = value ? 1 : 0;
+    }
+
+    public int ValueAsInt()
+    {
+        return _value;
+    }
+
+    public bool ValueAsBool()
+    {
+        return _value != 0;
+    }
+}

+ 0 - 10
Assets/Scripts/Script/SelectAssemblyClass.cs

@@ -350,15 +350,5 @@ public class SelectAssemblyClass : MonoBehaviourPunCallbacks
     }
     #endregion
 
-    int _targetIndex = 0;
-    bool _endSelect = false;
-
     bool _endSelectAssembly = false;
-
-    [PunRPC]
-    public void SetTargetAssemblysIndex(int targetIndex)
-    {
-        this._targetIndex = targetIndex;
-        _endSelect = true;
-    }
 }

+ 61 - 54
Assets/Scripts/Script/SelectAttackEffect.cs

@@ -7,6 +7,9 @@ using UnityEngine;
 
 public class SelectAttackEffect : MonoBehaviourPunCallbacks
 {
+    const int SecurityIndex = -1;
+    const int NopIndex = -2;
+
     public void SetUp
         (
         Permanent attacker,
@@ -67,8 +70,6 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
     bool _isVortex = false;
     bool _noSelect = false;
 
-    bool _endSelect = false;
-
     string _customMessage = null;
     string _customMessage_Enemy = null;
 
@@ -219,6 +220,8 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
 
             GManager.instance.turnStateMachine.IsSelecting = true;
 
+            Player attackOwner = _attacker?.TopCard != null ? _attacker.TopCard.Owner : null;
+
             if (_attacker != null)
             {
                 if (_attacker.TopCard != null)
@@ -352,7 +355,7 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
                                 {
                                     if (_canSelectNotAttack)
                                     {
-                                        GManager.instance.BackButton.OpenSelectCommandButton("Not Attack", () => { photonView.RPC("SetNotAttack", RpcTarget.All); }, 0);
+                                        GManager.instance.BackButton.OpenSelectCommandButton("Not Attack", () => { photonView.RPC("SetAttackTarget", RpcTarget.All, attackOwner.PlayerID, false, NopIndex); }, 0);
                                     }
 
                                     GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
@@ -380,21 +383,19 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
                                     }
                                 }
 
-                                bool isPlayer = true;
                                 bool isTurnPlayer = false;
-                                int PermanentIndex = -1;
+                                int PermanentIndex = SecurityIndex;
 
                                 if (selectedPermanent != null)
                                 {
                                     if (selectedPermanent.TopCard != null)
                                     {
-                                        isPlayer = false;
                                         isTurnPlayer = selectedPermanent.TopCard.Owner == GManager.instance.turnStateMachine.gameContext.TurnPlayer;
                                         PermanentIndex = selectedPermanent.TopCard.Owner.GetFieldPermanents().IndexOf(selectedPermanent);
                                     }
                                 }
 
-                                photonView.RPC("SetAttackTarget", RpcTarget.All, isPlayer, isTurnPlayer, PermanentIndex);
+                                photonView.RPC("SetAttackTarget", RpcTarget.All, attackOwner.PlayerID, isTurnPlayer, PermanentIndex);
 
                                 GManager.instance.BackButton.CloseSelectCommandButton();
                             }
@@ -441,21 +442,19 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
                                     }
                                 }
 
-                                bool isPlayer = true;
                                 bool isTurnPlayer = false;
-                                int PermanentIndex = -1;
+                                int PermanentIndex = SecurityIndex;
 
                                 if (selectedPermanent != null)
                                 {
                                     if (selectedPermanent.TopCard != null)
                                     {
-                                        isPlayer = false;
                                         isTurnPlayer = selectedPermanent.TopCard.Owner == GManager.instance.turnStateMachine.gameContext.TurnPlayer;
                                         PermanentIndex = selectedPermanent.TopCard.Owner.GetFieldPermanents().IndexOf(selectedPermanent);
                                     }
                                 }
 
-                                SetAttackTarget(isPlayer, isTurnPlayer, PermanentIndex);
+                                SetAttackTarget(attackOwner.PlayerID, isTurnPlayer, PermanentIndex);
                             }
                             #endregion
                         }
@@ -464,8 +463,49 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
             }
 
             //Wait until selection ends
-            yield return new WaitWhile(() => !_endSelect);
-            _endSelect = false;
+            yield return new WaitUntil(() => attackOwner.HasPlayerSelection());
+
+            _defender = null;
+            bool isTargetTurnPlayer = false;
+            int targetIndex = SecurityIndex;
+
+            PermanentSelection permanentSelection = attackOwner.DequeuePlayerSelection<PermanentSelection>();
+
+            if (permanentSelection != null)
+            {
+                if (permanentSelection.IsTurnPlayerList != null && permanentSelection.IsTurnPlayerList.Length > 0 &&
+                        permanentSelection.PermanentIDList != null && permanentSelection.PermanentIDList.Length > 0)
+                {
+                    isTargetTurnPlayer = permanentSelection.IsTurnPlayerList[0];
+                    targetIndex = permanentSelection.PermanentIDList[0];
+                }
+
+                _noSelect = targetIndex == NopIndex;
+
+                if (_noSelect)
+                {
+                    GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
+                }
+                else if (targetIndex != SecurityIndex)
+                {
+                    Player player = null;
+
+                    if (isTargetTurnPlayer)
+                    {
+                        player = GManager.instance.turnStateMachine.gameContext.TurnPlayer;
+                    }
+
+                    else
+                    {
+                        player = GManager.instance.turnStateMachine.gameContext.NonTurnPlayer;
+                    }
+
+                    if (targetIndex >= 0 && targetIndex < player.GetFieldPermanents().Count)
+                    {
+                        _defender = player.GetFieldPermanents()[targetIndex];
+                    }
+                }
+            }
 
             #region Clean up visual selections and UI
             foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
@@ -512,52 +552,19 @@ public class SelectAttackEffect : MonoBehaviourPunCallbacks
 
     #region ‘I‘ðŒˆ’è
     [PunRPC]
-    public void SetAttackTarget(bool isPlayer, bool isTurnPlayer, int PermanentIndex)
+    public void SetAttackTarget(int playerID, bool isTurnPlayer, int permanentIndex)
     {
-        _defender = null;
-
-        if (!isPlayer)
-        {
-            Player player = null;
-
-            if (isTurnPlayer)
-            {
-                player = GManager.instance.turnStateMachine.gameContext.TurnPlayer;
-            }
+        bool[] isTurnPlayerList = new bool[] { isTurnPlayer };
+        int[] permanentIndexList = new int[] { permanentIndex };
 
-            else
-            {
-                player = GManager.instance.turnStateMachine.gameContext.NonTurnPlayer;
-            }
-
-            Permanent permanent = null;
-
-            if (0 <= PermanentIndex && PermanentIndex <= player.GetFieldPermanents().Count - 1)
-            {
-                permanent = player.GetFieldPermanents()[PermanentIndex];
-            }
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
 
-            if (permanent != null)
-            {
-                _defender = permanent;
-            }
+        if (selectionPlayer == null)
+        {
+            return;
         }
 
-        _endSelect = true;
-    }
-    #endregion
-
-    #region ‘I‘ð‚µ‚È‚¢
-    [PunRPC]
-    public void SetNotAttack()
-    {
-        GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
-
-        _defender = null;
-
-        _noSelect = true;
-
-        _endSelect = true;
+        selectionPlayer.QueuePlayerSelection(new PermanentSelection(isTurnPlayerList, permanentIndexList));
     }
     #endregion
 }

+ 33 - 27
Assets/Scripts/Script/SelectCardEffect.cs

@@ -60,8 +60,6 @@ public class SelectCardEffect : MonoBehaviourPunCallbacks
         _skillInfos = new List<SkillInfo>();
 
         _afterSelectIndexCoroutine = null;
-
-        _endSelect = false;
     }
 
     public void SetIsLocal()
@@ -211,7 +209,6 @@ public class SelectCardEffect : MonoBehaviourPunCallbacks
     }
 
     Root _root;
-    bool _endSelect = false;
     bool _isDeckBottom = false;
     bool _isDeckTop = false;
 
@@ -576,8 +573,7 @@ public class SelectCardEffect : MonoBehaviourPunCallbacks
                         _slectedInexesInList.Add(selectedIndex);
                     }
 
-                    photonView.RPC("SetTargetIndicies", RpcTarget.All, _slectedInexesInList.ToArray());
-                    photonView.RPC("SetTargetCard", RpcTarget.All, targetCardIDs.ToArray());
+                    photonView.RPC("SetTargetCardAndIndicies", RpcTarget.All, _selectPlayer.PlayerID, targetCardIDs.ToArray(), _slectedInexesInList.ToArray());
                 }
             }
             else
@@ -645,25 +641,45 @@ public class SelectCardEffect : MonoBehaviourPunCallbacks
 
                         if (GManager.instance.IsAI)
                         {
-                            SetTargetCard(CardIDs.ToArray());
+                            SetTargetCardAndIndicies(_selectPlayer.PlayerID, CardIDs.ToArray(), null);
                         }
                         else
                         {
-                            photonView.RPC("SetTargetCard", RpcTarget.All, CardIDs.ToArray());
+                            photonView.RPC("SetTargetCardAndIndicies", RpcTarget.All, _selectPlayer.PlayerID, CardIDs.ToArray(), null);
                         }
 
                         break;
                     }
                 }
+            }
 
-                if (GManager.instance.IsAI)
+            yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+
+            CardSelection cardSelection = _selectPlayer.DequeuePlayerSelection<CardSelection>();
+
+            if (cardSelection != null && cardSelection.CardIDList != null)
+            {
+                _targetCards = new List<CardSource>();
+
+                foreach (int cardID in cardSelection.CardIDList)
                 {
-                    _endSelect = true;
+                    _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[cardID]);
                 }
             }
 
-            yield return new WaitWhile(() => !_endSelect);
-            _endSelect = false;
+            yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+
+            CardSelection indiciesSelection = _selectPlayer.DequeuePlayerSelection<CardSelection>();
+
+            if (indiciesSelection != null && indiciesSelection.CardIDList != null)
+            {
+                _slectedInexesInList = new List<int>();
+
+                foreach (int index in indiciesSelection.CardIDList)
+                {
+                    _slectedInexesInList.Add(index);
+                }
+            }
 
             GManager.instance.commandText.CloseCommandText();
             yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
@@ -991,26 +1007,16 @@ public class SelectCardEffect : MonoBehaviourPunCallbacks
     }
 
     [PunRPC]
-    public void SetTargetCard(int[] CardIDs)
+    public void SetTargetCardAndIndicies(int playerID, int[] CardIDs, int[] Indicies)
     {
-        _targetCards = new List<CardSource>();
+        Player player = GManager.instance.GetPlayerFromID(playerID);
 
-        foreach (int CardID in CardIDs)
+        if (!player)
         {
-            _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[CardID]);
+            return;
         }
 
-        _endSelect = true;
-    }
-
-    [PunRPC]
-    public void SetTargetIndicies(int[] CardIDs)
-    {
-        _slectedInexesInList = new List<int>();
-
-        foreach (int index in CardIDs)
-        {
-            _slectedInexesInList.Add(index);
-        }
+        player.QueuePlayerSelection(new CardSelection(CardIDs));
+        player.QueuePlayerSelection(new CardSelection(Indicies));
     }
 }

+ 17 - 10
Assets/Scripts/Script/SelectCountEffect.cs

@@ -60,7 +60,6 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
     Func<int, IEnumerator> _selectCountCoroutine = null;
     List<int> _candidates = new List<int>();
     int _selectedCount = 0;
-    bool _endSelect = false;
     bool _preferMin = true;
     bool _notDoSync = false;
     bool _isDigivolutionCost = false;
@@ -120,7 +119,7 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
             {
                 if (candidates.Count == 1)
                 {
-                    SetCount(candidates[0]);
+                    SetCount(_selectPlayer.PlayerID, candidates[0]);
                 }
 
                 else
@@ -131,7 +130,7 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
                         || (_isDigivolutionCost && ContinuousController.instance.autoMinDigivolutionCost && _preferMin))
                         {
                             int preferedNumber = _preferMin ? candidates.Min() : candidates.Max();
-                            photonView.RPC("SetCount", RpcTarget.All, preferedNumber);
+                            photonView.RPC("SetCount", RpcTarget.All, _selectPlayer.PlayerID, preferedNumber);
                         }
 
                         else
@@ -149,7 +148,7 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
 
                                 string text = $"{k}";
 
-                                command_SelectCommands.Add(new Command_SelectCommand(text, () => photonView.RPC("SetCount", RpcTarget.All, k), 0));
+                                command_SelectCommands.Add(new Command_SelectCommand(text, () => photonView.RPC("SetCount", RpcTarget.All, _selectPlayer.PlayerID, k), 0));
                             }
 
                             GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
@@ -162,7 +161,7 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
                         if (GManager.instance.IsAI)
                         {
                             int preferedNumber = _preferMin ? candidates.Min() : candidates.Max();
-                            SetCount(preferedNumber);
+                            SetCount(_selectPlayer.PlayerID, preferedNumber);
                         }
                         #endregion
 
@@ -173,8 +172,10 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
                     }
                 }
 
-                yield return new WaitWhile(() => !_endSelect);
-                _endSelect = false;
+                yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+
+                ValueSelection valueSelection = _selectPlayer.DequeuePlayerSelection<ValueSelection>();
+                _selectedCount = valueSelection != null ? valueSelection.ValueAsInt() : 0;
 
                 GManager.instance.commandText.CloseCommandText();
                 yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
@@ -196,9 +197,15 @@ public class SelectCountEffect : MonoBehaviourPunCallbacks
     }
 
     [PunRPC]
-    public void SetCount(int selectedCount)
+    public void SetCount(int playerID, int selectedCount)
     {
-        _selectedCount = selectedCount;
-        _endSelect = true;
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(selectedCount));
     }
 }

+ 3 - 15
Assets/Scripts/Script/SelectDNACondition.cs

@@ -25,14 +25,12 @@ public class SelectDNACondition : MonoBehaviourPunCallbacks
     Func<int, IEnumerator> _selectDNACoroutine = null;
     List<int> _candidates = new List<int>();
     public int _selectedCount = 0;
-    public bool _endSelect = false;
     bool _notDoSync = false;
     bool _isDigivolutionCost = false;
 
     public void ResetSelectDNAConditionClass()
     {
         _selectedCount = 0;
-        _endSelect = false;
     }
 
     public IEnumerator Activate()
@@ -42,11 +40,11 @@ public class SelectDNACondition : MonoBehaviourPunCallbacks
             //yield return GManager.instance.photonWaitController.StartWait("SelectDNACondition");
         }
 
-        if(_targetDNA.jogressCondition.Count > 1)
+        if (_targetDNA.jogressCondition.Count > 1)
         {
             if (_targetDNA.jogressCondition.Count == 1)
             {
-                SetDNACondition(0);
+                _selectedCount = 0;
             }
             else
             {
@@ -74,13 +72,10 @@ public class SelectDNACondition : MonoBehaviourPunCallbacks
 
                 yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
 
-                GManager.instance.photonView.RPC("SetDNACondition", RpcTarget.All, GManager.instance.userSelectionManager.SelectedIntValue);
+                _selectedCount = GManager.instance.userSelectionManager.SelectedIntValue;
             }
         }
 
-        yield return new WaitWhile(() => !_endSelect);
-        _endSelect = false;
-
         GManager.instance.commandText.CloseCommandText();
         yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
 
@@ -89,11 +84,4 @@ public class SelectDNACondition : MonoBehaviourPunCallbacks
             yield return ContinuousController.instance.StartCoroutine(_selectDNACoroutine(_selectedCount));
         }
     }
-
-    [PunRPC]
-    public void SetDNACondition(int selectedCount)
-    {
-        _selectedCount = selectedCount;
-        _endSelect = true;
-    }
 }

+ 16 - 9
Assets/Scripts/Script/SelectDigiXrosClass.cs

@@ -466,7 +466,7 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
 
                     else if (canSelectActions.Count == 2 && digiXrosCondition.CanTargetCondition_ByPreSelecetedList == null && !element.skipAllIfNoSelect)
                     {
-                        SetTargetDigiXrossIndex(actions.IndexOf(canSelectActions[0]));
+                        SetTargetDigiXrossIndex(card.Owner.PlayerID, actions.IndexOf(canSelectActions[0]));
                     }
 
                     else
@@ -508,7 +508,7 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
                                         break;
                                 }
 
-                                command_SelectCommands.Add(new Command_SelectCommand(message, () => photonView.RPC("SetTargetDigiXrossIndex", RpcTarget.All, k), spriteIndex));
+                                command_SelectCommands.Add(new Command_SelectCommand(message, () => photonView.RPC("SetTargetDigiXrossIndex", RpcTarget.All, card.Owner.PlayerID, k), spriteIndex));
                             }
 
                             GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
@@ -530,14 +530,16 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
                                     indexes.Add(k);
                                 }
 
-                                SetTargetDigiXrossIndex(UnityEngine.Random.Range(0, indexes.Count));
+                                SetTargetDigiXrossIndex(card.Owner.PlayerID, UnityEngine.Random.Range(0, indexes.Count));
                             }
                             #endregion
                         }
                     }
 
-                    yield return new WaitWhile(() => !_endSelect);
-                    _endSelect = false;
+                    yield return new WaitUntil(() => card.Owner.HasPlayerSelection());
+
+                    ValueSelection seletion = card.Owner.DequeuePlayerSelection<ValueSelection>();
+                    _targetIndex = seletion != null ? seletion.ValueAsInt() : 0;
 
                     GManager.instance.commandText.CloseCommandText();
                     yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
@@ -1007,15 +1009,20 @@ public class SelectDigiXrosClass : MonoBehaviourPunCallbacks
     #endregion
 
     int _targetIndex = 0;
-    bool _endSelect = false;
 
     bool _endSelectDigiXros = false;
 
     [PunRPC]
-    public void SetTargetDigiXrossIndex(int targetIndex)
+    public void SetTargetDigiXrossIndex(int playerID, int targetIndex)
     {
-        this._targetIndex = targetIndex;
-        _endSelect = true;
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(targetIndex));
     }
 }
 

+ 39 - 38
Assets/Scripts/Script/SelectHandEffect.cs

@@ -138,8 +138,6 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
     //No Selection Flag
     bool _noSelect = false;
 
-    bool _endSelect = false;
-
     string _customMessage_ShowCard = null;
     string _customMessage = null;
     string _customMessage_Enemy = null;
@@ -359,12 +357,12 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
 
                     if (!_isLocal)
                     {
-                        photonView.RPC("SetTargetHandCards", RpcTarget.All, CardIDs.ToArray());
+                        photonView.RPC("SetTargetHandCards", RpcTarget.All, _selectPlayer.PlayerID, CardIDs.ToArray());
                     }
 
                     else
                     {
-                        SetTargetHandCards(CardIDs.ToArray());
+                        SetTargetHandCards(_selectPlayer.PlayerID, CardIDs.ToArray());
                     }
 
                     GManager.instance.BackButton.CloseSelectCommandButton();
@@ -452,12 +450,12 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
                             {
                                 if (!_isLocal)
                                 {
-                                    photonView.RPC("SetNoSelectHand", RpcTarget.All);
+                                    photonView.RPC("SetTargetHandCards", RpcTarget.All, _selectPlayer.PlayerID, null);
                                 }
 
                                 else
                                 {
-                                    SetNoSelectHand();
+                                    SetTargetHandCards(_selectPlayer.PlayerID, null);
                                 }
                             }
                         }
@@ -505,6 +503,8 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
                         {
                             IList<int> indexList = Enumerable.Range(0, ValidCards.Count).ToList();
 
+                            List<int> CardIDs = null;
+
                             if (ValidCards.Count >= maxCount)
                             {
                                 for (int i = 0; i < 1000; i++)
@@ -520,28 +520,27 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
 
                                     if (CanEndSelect(GetCards))
                                     {
-                                        List<int> CardIDs = new List<int>();
+                                        CardIDs = new List<int>();
 
                                         foreach (CardSource cardSource in GetCards)
                                         {
                                             CardIDs.Add(cardSource.CardIndex);
                                         }
 
-                                        SetTargetHandCards(CardIDs.ToArray());
                                         break;
                                     }
                                 }
                             }
-                        }
 
-                        _endSelect = true;
+                            SetTargetHandCards(_selectPlayer.PlayerID, CardIDs != null ? CardIDs.ToArray() : null);
+                        }  
                     }
 
                     else
                     {
                         IList<int> indexList = Enumerable.Range(0, ValidCards.Count).ToList();
 
-                        _noSelect = true;
+                        List<int> CardIDs = null;
 
                         if (ValidCards.Count >= _maxCount)
                         {
@@ -558,20 +557,19 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
 
                                 if (CanEndSelect(GetCards))
                                 {
-                                    List<int> CardIDs = new List<int>();
+                                    CardIDs = new List<int>();
 
                                     foreach (CardSource cardSource in GetCards)
                                     {
                                         CardIDs.Add(cardSource.CardIndex);
                                     }
 
-                                    SetTargetHandCards(CardIDs.ToArray());
                                     break;
                                 }
                             }
                         }
 
-                        _endSelect = true;
+                        SetTargetHandCards(_selectPlayer.PlayerID, CardIDs != null ? CardIDs.ToArray() : null);
 
                     }
                 }
@@ -601,8 +599,27 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
             #endregion
 
             //Wait for selection to be completed
-            yield return new WaitWhile(() => !_endSelect);
-            _endSelect = false;
+            yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+            CardSelection cardSeletion = _selectPlayer.DequeuePlayerSelection<CardSelection>();
+
+            _targetCards = new List<CardSource>();
+
+            if (cardSeletion != null)
+            {
+                _noSelect = cardSeletion.CardIDList == null;
+
+                if (!_noSelect)
+                {
+                    foreach (int CardID in cardSeletion.CardIDList)
+                    {
+                        _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[CardID]);
+                    }
+                }
+                else
+                {
+                    GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
+                }
+            }
 
             #region Reset
             foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
@@ -912,34 +929,18 @@ public class SelectHandEffect : MonoBehaviourPunCallbacks
 
     }
 
-    #region �J�[�h�I��������
+    #region ƒJ[ƒh‘I‘ð‚ðŒˆ’è
     [PunRPC]
-    public void SetTargetHandCards(int[] CardIDs)
+    public void SetTargetHandCards(int playerID, int[] CardIDs)
     {
-        _targetCards = new List<CardSource>();
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
 
-        foreach (int CardID in CardIDs)
+        if (selectionPlayer == null)
         {
-            _targetCards.Add(GManager.instance.turnStateMachine.gameContext.ActiveCardList[CardID]);
+            return;
         }
 
-        _noSelect = false;
-
-        _endSelect = true;
-    }
-    #endregion
-
-    #region �����I�����Ȃ�
-    [PunRPC]
-    public void SetNoSelectHand()
-    {
-        GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
-
-        _targetCards = new List<CardSource>();
-
-        _noSelect = true;
-
-        _endSelect = true;
+        selectionPlayer.QueuePlayerSelection(new CardSelection(CardIDs));
     }
     #endregion
 }

+ 46 - 44
Assets/Scripts/Script/SelectPermanentEffect.cs

@@ -143,8 +143,6 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
     //No Selection Flag
     public bool _noSelect = false;
 
-    bool _endSelect = false;
-
     string _customMessage = null;
     string _customMessage_Enemy = null;
 
@@ -565,12 +563,12 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
                                 {
                                     if (!_isLocal)
                                     {
-                                        photonView.RPC("SetNoSelectChara", RpcTarget.All);
+                                        photonView.RPC("SetTargetFrames", RpcTarget.All, _selectPlayer.PlayerID, null, null);
                                     }
 
                                     else
                                     {
-                                        SetNoSelectChara();
+                                        SetTargetFrames(_selectPlayer.PlayerID, null, null);
                                     }
                                 }
                             }
@@ -605,12 +603,12 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
 
                     if (!_isLocal)
                     {
-                        photonView.RPC("SetTargetFrames", RpcTarget.All, isTurnPlayer.ToArray(), CharaIndex.ToArray());
+                        photonView.RPC("SetTargetFrames", RpcTarget.All, _selectPlayer.PlayerID, isTurnPlayer.ToArray(), CharaIndex.ToArray());
                     }
 
                     else
                     {
-                        SetTargetFrames(isTurnPlayer.ToArray(), CharaIndex.ToArray());
+                        SetTargetFrames(_selectPlayer.PlayerID, isTurnPlayer.ToArray(), CharaIndex.ToArray());
                     }
 
                     GManager.instance.BackButton.CloseSelectCommandButton();
@@ -683,19 +681,51 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
                                 }
                             }
 
-                            SetTargetFrames(isTurnPlayer.ToArray(), UnitIDs.ToArray());
+                            SetTargetFrames(_selectPlayer.PlayerID, isTurnPlayer.ToArray(), UnitIDs.ToArray());
                             break;
                         }
                     }
-
-                    _endSelect = true;
                 }
                 #endregion
             }
 
             //Wait until selection is complete
-                        yield return new WaitWhile(() => !_endSelect);
-            _endSelect = false;
+            yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+            PermanentSelection permanentSelection = _selectPlayer.DequeuePlayerSelection<PermanentSelection>();
+
+            if (permanentSelection != null)
+            {
+                _targetPermanents = new List<Permanent>();
+
+                if (permanentSelection.IsTurnPlayerList != null && permanentSelection.PermanentIDList != null)
+                {
+                    for (int i = 0; i < permanentSelection.IsTurnPlayerList.Length; i++)
+                    {
+                        Player player = null;
+
+                        if (permanentSelection.IsTurnPlayerList[i])
+                        {
+                            player = GManager.instance.turnStateMachine.gameContext.TurnPlayer;
+                        }
+
+                        else
+                        {
+                            player = GManager.instance.turnStateMachine.gameContext.NonTurnPlayer;
+                        }
+
+                        Permanent chara = player.GetFieldPermanents()[permanentSelection.PermanentIDList[i]];
+
+                        _targetPermanents.Add(chara);
+                    }
+
+                    _noSelect = false;
+                }
+                else
+                {
+                    GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
+                    _noSelect = true;
+                }
+            }
 
             #region reset
             foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
@@ -1015,44 +1045,16 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
 
     #region 選択決定
     [PunRPC]
-    public void SetTargetFrames(bool[] isTurnPlayer, int[] UnitIndex)
+    public void SetTargetFrames(int playerID, bool[] isTurnPlayer, int[] UnitIndex)
     {
-        _targetPermanents = new List<Permanent>();
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
 
-        for (int i = 0; i < isTurnPlayer.Length; i++)
+        if (selectionPlayer == null)
         {
-            Player player = null;
-
-            if (isTurnPlayer[i])
-            {
-                player = GManager.instance.turnStateMachine.gameContext.TurnPlayer;
-            }
-
-            else
-            {
-                player = GManager.instance.turnStateMachine.gameContext.NonTurnPlayer;
-            }
-
-            Permanent chara = player.GetFieldPermanents()[UnitIndex[i]];
-
-            _targetPermanents.Add(chara);
+            return;
         }
 
-        _endSelect = true;
-    }
-    #endregion
-
-    #region 選択しない
-    [PunRPC]
-    public void SetNoSelectChara()
-    {
-        GManager.instance.selectCommandPanel.CloseSelectCommandPanel();
-
-        _targetPermanents = new List<Permanent>();
-
-        _noSelect = true;
-
-        _endSelect = true;
+        selectionPlayer.QueuePlayerSelection(new PermanentSelection(isTurnPlayer, UnitIndex));
     }
     #endregion
 }

+ 58 - 11
Assets/Scripts/Script/UserSelectionManager.cs

@@ -13,44 +13,86 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
     public int SelectedIntValue => _selectedIntValue;
     public bool SelectedBoolValue => _selectedBoolValue;
 
+    Player _selectPlayer;
+
     [PunRPC]
+    public void SetIntForPlayer(int playerID, int value)
+    {
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(value));
+    }
+
     public void SetInt(int value)
     {
         _selectedIntValue = value;
         _endSelect = true;
     }
 
-    protected void SetInt_RPC(int value)
+    protected void SetInt_RPC(int playerID, int value)
     {
-        photonView.RPC("SetInt", RpcTarget.All, value);
+        photonView.RPC("SetIntForPlayer", RpcTarget.All, playerID, value);
     }
 
     [PunRPC]
+    public void SetBoolForPlayer(int playerID, bool value)
+    {
+        Player selectionPlayer = GManager.instance.GetPlayerFromID(playerID);
+
+        if (selectionPlayer == null)
+        {
+            return;
+        }
+
+        selectionPlayer.QueuePlayerSelection(new ValueSelection(value));
+    }
+
     public void SetBool(bool value)
     {
         _selectedIntValue = getIntFromBool(value);
         _endSelect = true;
     }
 
-    protected void SetBool_RPC(bool value)
+    protected void SetBool_RPC(int playerID, bool value)
     {
-        photonView.RPC("SetBool", RpcTarget.All, value);
+        photonView.RPC("SetBoolForPlayer", RpcTarget.All, playerID, value);
     }
 
     internal int getIntFromBool(bool value)
     {
-        return value ? 0 : 1;
+        return value ? 1 : 0;
     }
 
     internal bool getBoolFromInt(int value)
     {
-        return value == 0;
+        return value != 0;
     }
 
     public IEnumerator WaitForEndSelect()
     {
-        yield return new WaitWhile(() => !_endSelect);
+        if (_selectPlayer != null)
+        {
+            yield return new WaitUntil(() => _selectPlayer.HasPlayerSelection());
+
+            ValueSelection valueSeletion = _selectPlayer.DequeuePlayerSelection<ValueSelection>();
+
+            if (valueSeletion != null)
+            {
+                _selectedIntValue = valueSeletion.ValueAsInt();
+            }
+        }
+        else
+        {
+            yield return new WaitWhile(() => !_endSelect);
+        }
+
         _endSelect = false;
+        _selectPlayer = null;
 
         GManager.instance.commandText.CloseCommandText();
         yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
@@ -60,6 +102,7 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
     {
         _endSelect = false;
         _selectedIntValue = 0;
+        _selectPlayer = selectPlayer;
 
         if (selectPlayer.isYou)
         {
@@ -69,7 +112,7 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
 
             foreach (SelectionElement<int> selectionElement in selectionElements)
             {
-                command_SelectCommands.Add(new Command_SelectCommand(selectionElement.Message, () => SetInt_RPC(selectionElement.Value), selectionElement.SpriteIndex));
+                command_SelectCommands.Add(new Command_SelectCommand(selectionElement.Message, () => SetInt_RPC(selectPlayer.PlayerID, selectionElement.Value), selectionElement.SpriteIndex));
             }
 
             GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);
@@ -91,12 +134,12 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
 
                 if (canSelectValue.Count >= 1)
                 {
-                    SetInt(canSelectValue[UnityEngine.Random.Range(0, canSelectValue.Count)]);
+                    SetInt_RPC(selectPlayer.PlayerID, canSelectValue[UnityEngine.Random.Range(0, canSelectValue.Count)]);
                 }
 
                 else
                 {
-                    SetInt(0);
+                    SetInt_RPC(selectPlayer.PlayerID, 0);
                 }
             }
             #endregion
@@ -105,6 +148,10 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
 
     public void SetBoolSelection(List<SelectionElement<bool>> selectionElements, Player selectPlayer, string selectPlayerMessage, string notSelectPlayerMessage)
     {
+        _endSelect = false;
+        _selectedIntValue = 0;
+        _selectPlayer = selectPlayer;
+
         if (selectPlayer.isYou)
         {
             GManager.instance.commandText.OpenCommandText(selectPlayerMessage);
@@ -113,7 +160,7 @@ public class UserSelectionManager : MonoBehaviourPunCallbacks
 
             foreach (SelectionElement<bool> selectionElement in selectionElements)
             {
-                command_SelectCommands.Add(new Command_SelectCommand(selectionElement.Message, () => SetBool_RPC(selectionElement.Value), selectionElement.SpriteIndex));
+                command_SelectCommands.Add(new Command_SelectCommand(selectionElement.Message, () => SetBool_RPC(selectPlayer.PlayerID, selectionElement.Value), selectionElement.SpriteIndex));
             }
 
             GManager.instance.selectCommandPanel.SetUpCommandButton(command_SelectCommands);