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(() =>