From 54fece46ca0cd05384f69917e2daee5962a35e1c Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Thu, 27 Mar 2025 13:50:57 +0900 Subject: [PATCH 1/3] =?UTF-8?q?DO-70=20[Feat]=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=EC=95=84=EC=9B=83=2030=EC=B4=88=20=EB=A9=80=ED=8B=B0=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Common/Constants.cs | 3 +- Assets/Script/Game/GameLogic.cs | 48 +++++++++++++++++++++----- Assets/Script/Game/MultiplayManager.cs | 25 ++++++++++++++ 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/Assets/Script/Common/Constants.cs b/Assets/Script/Common/Constants.cs index 328ac54..a15f242 100644 --- a/Assets/Script/Common/Constants.cs +++ b/Assets/Script/Common/Constants.cs @@ -18,6 +18,7 @@ ExitRoom, // 자신이 방을 빠져 나왔을 때 EndGame, // 상대방이 접속을 끊거나 방을 나갔을 때 DoSurrender, // 상대방이 항복했을 때 - SurrenderConfirmed // 항복 요청이 성공적으로 전송되었을 때 + SurrenderConfirmed, // 항복 요청이 성공적으로 전송되었을 때 + ReceiveTimeout // 상대방이 타임 아웃일 때 }; } \ No newline at end of file diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index fb5afb7..5ce6e83 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -177,7 +177,7 @@ public class MultiPlayerState: BasePlayerState gameLogic.UpdateForbiddenMoves(); #endregion - // gameLogic.currentTurn = _playerType; + gameLogic.currentTurn = _playerType; // gameLogic.stoneController.OnStoneClickedDelegate = (row, col) => // { // HandleMove(gameLogic, row, col); @@ -278,17 +278,39 @@ public class GameLogic : MonoBehaviour //timer 시간초과시 진행 함수 this.fioTimer.OnTimeout = () => { - if (currentTurn == Enums.PlayerType.PlayerA) + if (gameType == Enums.GameType.MultiPlay) { - GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerB} Win", - () =>{}); - EndGame(Enums.GameResult.Lose); + // 현재 턴의 플레이어가 로컬(유저)인지 확인 + bool isCurrentPlayerLocal = (currentTurn == Enums.PlayerType.PlayerA && firstPlayerState is PlayerState) || + (currentTurn == Enums.PlayerType.PlayerB && secondPlayerState is PlayerState); + + if (isCurrentPlayerLocal) // 내가 타임 오버일 때 + { + _multiplayManager?.SendTimeout(); + GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Lose); + EndGame(Enums.GameResult.Lose); + } + else // 로컬에서 자신의 타이머 기준으로 상대방이 타임 오버일 때 + { + // TODO: 컨펌 패널 OK 버튼 삭제? + GameManager.Instance.panelManager.OpenConfirmPanel("상대방의 응답을 기다리는 중입니다", + () => { } ); + } } - else if (currentTurn == Enums.PlayerType.PlayerB) + else { - GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerA} Win", - () =>{}); - EndGame(Enums.GameResult.Win); + if (currentTurn == Enums.PlayerType.PlayerA) + { + GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerB} Win", + () => { }); + EndGame(Enums.GameResult.Lose); + } + else if (currentTurn == Enums.PlayerType.PlayerB) + { + GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerA} Win", + () => { }); + EndGame(Enums.GameResult.Win); + } } }; } @@ -462,6 +484,14 @@ public class GameLogic : MonoBehaviour EndGame(Enums.GameResult.Lose); }); break; + case Constants.MultiplayManagerState.ReceiveTimeout: + Debug.Log("상대방이 타임 아웃 됨"); + UnityMainThreadDispatcher.Instance().Enqueue(() => + { + GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Win); + EndGame(Enums.GameResult.Win); + }); + break; } ReplayManager.Instance.InitReplayData(UserManager.Instance.Nickname,"nicknameB"); diff --git a/Assets/Script/Game/MultiplayManager.cs b/Assets/Script/Game/MultiplayManager.cs index c5a8eab..445dfa5 100644 --- a/Assets/Script/Game/MultiplayManager.cs +++ b/Assets/Script/Game/MultiplayManager.cs @@ -90,6 +90,7 @@ public class MultiplayManager : IDisposable _socket.On("doOpponent", DoOpponent); _socket.On("doSurrender", DoSurrender); _socket.On("surrenderConfirmed", SurrenderConfirmed); + _socket.On("receiveTimeout", ReceiveTimeout); _socket.Connect(); } @@ -218,6 +219,30 @@ public class MultiplayManager : IDisposable _onMultiplayStateChanged?.Invoke(Constants.MultiplayManagerState.SurrenderConfirmed, data.message); } + /// + /// 타임 아웃 요청 + /// + public void SendTimeout() + { + if (string.IsNullOrEmpty(_roomId)) + { + Debug.LogError("LeaveRoom 호출 실패: _roomId가 설정되지 않음"); + return; + } + _socket.Emit("sendTimeout",new { roomId = _roomId }); + } + + /// + /// 타임 아웃 수신 + /// + /// + private void ReceiveTimeout(SocketIOResponse response) + { + var data = response.GetValue(); + + _onMultiplayStateChanged?.Invoke(Constants.MultiplayManagerState.ReceiveTimeout, data.message); + } + public void Dispose() { if (_socket != null) From 9ffb563353a4d9b9b095b9a26c99f0dc484de7ac Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Thu, 27 Mar 2025 13:57:35 +0900 Subject: [PATCH 2/3] =?UTF-8?q?DO-70=20[Feat]=20=EC=8B=B1=EA=B8=80?= =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=20=EB=B3=80=ED=99=98=20=EC=8B=9C=20?= =?UTF-8?q?=EC=8B=B1=EA=B8=80=ED=94=8C=EB=A0=88=EC=9D=B4=EB=A1=9C=20?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=ED=83=80=EC=9E=85=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 5ce6e83..55e2602 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -522,6 +522,7 @@ public class GameLogic : MonoBehaviour // 기존 멀티플레이 상태 초기화 _multiplayManager = null; _roomId = null; + gameType = Enums.GameType.SinglePlay; // 싱글 플레이 상태로 변경 firstPlayerState = new PlayerState(true); From fb7a3c40a1ea845c0be2b6a4e2f8aea330b54c09 Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:08:52 +0900 Subject: [PATCH 3/3] =?UTF-8?q?DO-70=20[Feat]=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=ED=95=98=EC=97=AC=20=EC=8B=B1?= =?UTF-8?q?=EA=B8=80=20=ED=94=8C=EB=A0=88=EC=9D=B4=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 41 +++++++++++---------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 55e2602..61f7e79 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -278,39 +278,24 @@ public class GameLogic : MonoBehaviour //timer 시간초과시 진행 함수 this.fioTimer.OnTimeout = () => { - if (gameType == Enums.GameType.MultiPlay) - { - // 현재 턴의 플레이어가 로컬(유저)인지 확인 - bool isCurrentPlayerLocal = (currentTurn == Enums.PlayerType.PlayerA && firstPlayerState is PlayerState) || - (currentTurn == Enums.PlayerType.PlayerB && secondPlayerState is PlayerState); + // 현재 턴의 플레이어가 로컬(유저)인지 확인 + bool isCurrentPlayerLocal = (currentTurn == Enums.PlayerType.PlayerA && firstPlayerState is PlayerState) || + (currentTurn == Enums.PlayerType.PlayerB && secondPlayerState is PlayerState); - if (isCurrentPlayerLocal) // 내가 타임 오버일 때 + if (isCurrentPlayerLocal) // 내가 타임 오버일 때 + { + if (this.gameType == Enums.GameType.MultiPlay) // 멀티플레이인 경우 { _multiplayManager?.SendTimeout(); - GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Lose); - EndGame(Enums.GameResult.Lose); - } - else // 로컬에서 자신의 타이머 기준으로 상대방이 타임 오버일 때 - { - // TODO: 컨펌 패널 OK 버튼 삭제? - GameManager.Instance.panelManager.OpenConfirmPanel("상대방의 응답을 기다리는 중입니다", - () => { } ); } + GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Lose); + EndGame(Enums.GameResult.Lose); } - else + else // 로컬에서 자신의 타이머 기준으로 상대방이 타임 오버일 때 { - if (currentTurn == Enums.PlayerType.PlayerA) - { - GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerB} Win", - () => { }); - EndGame(Enums.GameResult.Lose); - } - else if (currentTurn == Enums.PlayerType.PlayerB) - { - GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerA} Win", - () => { }); - EndGame(Enums.GameResult.Win); - } + // TODO: 컨펌 패널 OK 버튼 삭제? + GameManager.Instance.panelManager.OpenConfirmPanel("상대방의 응답을 기다리는 중입니다", + () => { } ); } }; } @@ -522,7 +507,7 @@ public class GameLogic : MonoBehaviour // 기존 멀티플레이 상태 초기화 _multiplayManager = null; _roomId = null; - gameType = Enums.GameType.SinglePlay; + this.gameType = Enums.GameType.SinglePlay; // 싱글 플레이 상태로 변경 firstPlayerState = new PlayerState(true);