From cdf197b358a3123ab29d96c35dc4615e428ba1f1 Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Wed, 26 Mar 2025 13:48:27 +0900 Subject: [PATCH 1/3] =?UTF-8?q?DO-62=20[Fix]=20=EC=B0=A9=EC=88=98=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 4a710d8..dc0debe 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -12,6 +12,10 @@ public abstract class BasePlayerState public abstract void OnExit(GameLogic gameLogic); public abstract void HandleMove(GameLogic gameLogic, int row, int col); public abstract void HandleNextTurn(GameLogic gameLogic); + + protected string _roomId; + protected bool _isMultiplay; + protected MultiplayManager _multiplayManager; public void ProcessMove(GameLogic gameLogic, Enums.PlayerType playerType, int row, int col) { @@ -20,6 +24,12 @@ public abstract class BasePlayerState gameLogic.SetNewBoardValue(playerType, row, col); gameLogic.CountStoneCounter(); + if (_isMultiplay) + { + Debug.Log("row: " + row + "col: " + col); + _multiplayManager.SendPlayerMove(_roomId, new Vector2Int(row, col)); + } + if (gameLogic.CheckGameWin(playerType, row, col)) { var gameResult = playerType == Enums.PlayerType.PlayerA? Enums.GameResult.Win:Enums.GameResult.Lose; @@ -53,10 +63,6 @@ public class PlayerState : BasePlayerState private Enums.PlayerType _playerType; private bool _isFirstPlayer; - private MultiplayManager _multiplayManager; - private string _roomId; - private bool _isMultiplay; - public PlayerState(bool isFirstPlayer) { _isFirstPlayer = isFirstPlayer; @@ -108,11 +114,6 @@ public class PlayerState : BasePlayerState public override void HandleMove(GameLogic gameLogic, int row, int col) { gameLogic.SetStoneSelectedState(row, col); - if (_isMultiplay) - { - Debug.Log("row: " + row + "col: " + col); - _multiplayManager.SendPlayerMove(_roomId, new Vector2Int(row, col)); - } } public override void HandleNextTurn(GameLogic gameLogic) From 4ef5a83cc6d6e39f8f4eccd48a9cd800dd694bdf Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Wed, 26 Mar 2025 15:01:17 +0900 Subject: [PATCH 2/3] =?UTF-8?q?DO-62=20[Feat]=20=EC=84=A0=ED=9B=84?= =?UTF-8?q?=EA=B3=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 41 +++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index dc0debe..32cdf40 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -26,7 +26,6 @@ public abstract class BasePlayerState if (_isMultiplay) { - Debug.Log("row: " + row + "col: " + col); _multiplayManager.SendPlayerMove(_roomId, new Vector2Int(row, col)); } @@ -73,6 +72,7 @@ public class PlayerState : BasePlayerState public PlayerState(bool isFirstPlayer, MultiplayManager multiplayManager, JoinRoomData data) : this(isFirstPlayer) { + _isFirstPlayer = isFirstPlayer; _multiplayManager = multiplayManager; _roomId = data.roomId; _isMultiplay = true; @@ -81,6 +81,7 @@ public class PlayerState : BasePlayerState public PlayerState(bool isFirstPlayer, MultiplayManager multiplayManager, string roomId) : this(isFirstPlayer) { + _isFirstPlayer = isFirstPlayer; _multiplayManager = multiplayManager; _roomId = roomId; _isMultiplay = true; @@ -341,13 +342,21 @@ public class GameLogic : MonoBehaviour return; } - // TODO: 선공, 후공 처리 - if (joinRoomData.isBlack) - { - } + // 선공, 후공 처리 + bool isFirstPlayer = joinRoomData.isBlack; - firstPlayerState = new MultiPlayerState(true, _multiplayManager); - secondPlayerState = new PlayerState(false, _multiplayManager, joinRoomData); + if (isFirstPlayer) + { + Debug.Log("해당 플레이어가 선공 입니다"); + firstPlayerState = new PlayerState(true, _multiplayManager, joinRoomData.roomId); + secondPlayerState = new MultiPlayerState(false, _multiplayManager); + } + else + { + Debug.Log("해당 플레이어가 후공 입니다"); + firstPlayerState = new MultiPlayerState(true, _multiplayManager); + secondPlayerState = new PlayerState(false, _multiplayManager, joinRoomData); + } // 메인 스레드에서 실행 - UI 업데이트는 메인 스레드에서 실행 필요 UnityMainThreadDispatcher.Instance().Enqueue(() => @@ -379,13 +388,21 @@ public class GameLogic : MonoBehaviour Debug.Log("Start Game 응답값이 null 입니다"); return; } - - // TODO: 선공, 후공 처리 - if (startGameData.isBlack) + // 선공, 후공 처리 + isFirstPlayer = startGameData.isBlack; + + if (isFirstPlayer) { + Debug.Log("해당 플레이어가 선공 입니다"); + firstPlayerState = new PlayerState(true, _multiplayManager, _roomId); + secondPlayerState = new MultiPlayerState(false, _multiplayManager); + } + else + { + Debug.Log("해당 플레이어가 후공 입니다"); + firstPlayerState = new MultiPlayerState(true, _multiplayManager); + secondPlayerState = new PlayerState(false, _multiplayManager, _roomId); } - firstPlayerState = new PlayerState(true, _multiplayManager, _roomId); - secondPlayerState = new MultiPlayerState(false, _multiplayManager); // 메인 스레드에서 실행 - UI 업데이트는 메인 스레드에서 실행 필요 UnityMainThreadDispatcher.Instance().Enqueue(() => From 7ec639084e77b9edba0148b3642ffd6f4be3a5c0 Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Wed, 26 Mar 2025 15:04:25 +0900 Subject: [PATCH 3/3] =?UTF-8?q?DO-62=20[Style]=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=A4=91=EB=B3=B5=20PlayerState=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 32cdf40..497eb19 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -69,15 +69,6 @@ public class PlayerState : BasePlayerState _isMultiplay = false; } - public PlayerState(bool isFirstPlayer, MultiplayManager multiplayManager, JoinRoomData data) - : this(isFirstPlayer) - { - _isFirstPlayer = isFirstPlayer; - _multiplayManager = multiplayManager; - _roomId = data.roomId; - _isMultiplay = true; - } - public PlayerState(bool isFirstPlayer, MultiplayManager multiplayManager, string roomId) : this(isFirstPlayer) { @@ -355,7 +346,7 @@ public class GameLogic : MonoBehaviour { Debug.Log("해당 플레이어가 후공 입니다"); firstPlayerState = new MultiPlayerState(true, _multiplayManager); - secondPlayerState = new PlayerState(false, _multiplayManager, joinRoomData); + secondPlayerState = new PlayerState(false, _multiplayManager, joinRoomData.roomId); } // 메인 스레드에서 실행 - UI 업데이트는 메인 스레드에서 실행 필요