DO-79 [Fix] 게임 강종/종료 처리
This commit is contained in:
parent
3051232991
commit
e52ec962ab
@ -34,6 +34,7 @@ public partial class GameLogic : IDisposable
|
|||||||
public int SelectedRow { get; private set; }
|
public int SelectedRow { get; private set; }
|
||||||
public int SelectedCol { get; private set; }
|
public int SelectedCol { get; private set; }
|
||||||
public FioTimer FioTimer { get; private set; }
|
public FioTimer FioTimer { get; private set; }
|
||||||
|
public bool GameInProgress { get; private set; } // 게임 진행 중인지 확인
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -120,10 +121,9 @@ public partial class GameLogic : IDisposable
|
|||||||
Debug.Log("## End Game");
|
Debug.Log("## End Game");
|
||||||
ExecuteOnMainThread(() =>
|
ExecuteOnMainThread(() =>
|
||||||
{
|
{
|
||||||
GameManager.Instance.panelManager.OpenConfirmPanel("연결이 끊어졌습니다.", () =>
|
GameManager.Instance.panelManager.OpenConfirmPanel("상대방이 방을 나갔습니다.", () =>
|
||||||
{
|
{
|
||||||
GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Win);
|
// TODO: 무승부/항복 등 버튼 동작 안하도록 처리
|
||||||
EndGame(Enums.GameResult.Win);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -199,6 +199,7 @@ public partial class GameLogic : IDisposable
|
|||||||
break;
|
break;
|
||||||
case Constants.MultiplayManagerState.ReceiveRevengeRequest:
|
case Constants.MultiplayManagerState.ReceiveRevengeRequest:
|
||||||
Debug.Log("상대방의 재대결 요청이 들어옴");
|
Debug.Log("상대방의 재대결 요청이 들어옴");
|
||||||
|
ChangeGameInProgress(true);
|
||||||
ExecuteOnMainThread(() =>
|
ExecuteOnMainThread(() =>
|
||||||
{
|
{
|
||||||
GameManager.Instance.panelManager.OpenDrawConfirmPanel("상대방의 재대결 요청을\n승낙하시겠습니까?", () =>
|
GameManager.Instance.panelManager.OpenDrawConfirmPanel("상대방의 재대결 요청을\n승낙하시겠습니까?", () =>
|
||||||
@ -276,7 +277,14 @@ public partial class GameLogic : IDisposable
|
|||||||
break;
|
break;
|
||||||
case Constants.MultiplayManagerState.OpponentDisconnected:
|
case Constants.MultiplayManagerState.OpponentDisconnected:
|
||||||
Debug.Log("상대방 강제 종료");
|
Debug.Log("상대방 강제 종료");
|
||||||
// 실제로 실행되지 않음. 상대방 강제 종료 시에는 EndGame으로 처리됨
|
ExecuteOnMainThread(() =>
|
||||||
|
{
|
||||||
|
GameManager.Instance.panelManager.OpenConfirmPanel("연결이 끊어졌습니다.", () =>
|
||||||
|
{
|
||||||
|
GameManager.Instance.panelManager.OpenEffectPanel(Enums.GameResult.Win);
|
||||||
|
EndGame(Enums.GameResult.Win);
|
||||||
|
});
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ReplayManager.Instance.InitReplayData(UserManager.Instance.Nickname,"nicknameB");
|
ReplayManager.Instance.InitReplayData(UserManager.Instance.Nickname,"nicknameB");
|
||||||
@ -339,6 +347,9 @@ public partial class GameLogic : IDisposable
|
|||||||
// 메인스레드에서 게임 시작
|
// 메인스레드에서 게임 시작
|
||||||
private void StartGameOnMainThread()
|
private void StartGameOnMainThread()
|
||||||
{
|
{
|
||||||
|
ChangeGameInProgress(true);
|
||||||
|
Debug.Log("GameInProgress 변경 true");
|
||||||
|
|
||||||
ExecuteOnMainThread(() =>
|
ExecuteOnMainThread(() =>
|
||||||
{
|
{
|
||||||
// 로딩 패널 열려있으면 닫기
|
// 로딩 패널 열려있으면 닫기
|
||||||
@ -551,10 +562,24 @@ public partial class GameLogic : IDisposable
|
|||||||
private void TimerUnpause() => FioTimer.StartTimer();
|
private void TimerUnpause() => FioTimer.StartTimer();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void ChangeGameInProgress(bool inProgress)
|
||||||
|
{
|
||||||
|
if (GameInProgress == inProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GameInProgress = inProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
MultiPlayManager?.LeaveRoom(_roomId);
|
MultiPlayManager?.LeaveRoom(_roomId);
|
||||||
MultiPlayManager?.Dispose();
|
MultiPlayManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ForceQuit()
|
||||||
|
{
|
||||||
|
MultiPlayManager?.ForceQuit(_roomId);
|
||||||
|
MultiPlayManager?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,11 @@ public class GameManager : Singleton<GameManager>
|
|||||||
private void OnApplicationQuit()
|
private void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
Debug.Log("앱 종료 감지: 소켓 연결 정리 중...");
|
Debug.Log("앱 종료 감지: 소켓 연결 정리 중...");
|
||||||
_gameLogic?.Dispose();
|
|
||||||
|
if(_gameLogic.GameInProgress)
|
||||||
|
_gameLogic?.ForceQuit();
|
||||||
|
else
|
||||||
|
_gameLogic?.Dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
public partial class GameLogic
|
using UnityEngine;
|
||||||
|
|
||||||
|
public partial class GameLogic
|
||||||
{
|
{
|
||||||
// 돌 카운터 증가 함수
|
// 돌 카운터 증가 함수
|
||||||
public void CountStoneCounter() => _totalStoneCounter++;
|
public void CountStoneCounter() => _totalStoneCounter++;
|
||||||
@ -85,5 +87,7 @@
|
|||||||
SetState(null);
|
SetState(null);
|
||||||
ReplayManager.Instance.SaveReplayDataResult(result);
|
ReplayManager.Instance.SaveReplayDataResult(result);
|
||||||
//TODO: 게임 종료 후 행동 구현
|
//TODO: 게임 종료 후 행동 구현
|
||||||
|
ChangeGameInProgress(false);
|
||||||
|
Debug.Log("GameInProgress 변경 false");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -218,6 +218,18 @@ public class MultiplayManager : IDisposable
|
|||||||
_roomId = null; // 방 나가면 roomId 초기화
|
_roomId = null; // 방 나가면 roomId 초기화
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ForceQuit(string roomId)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_roomId))
|
||||||
|
{
|
||||||
|
Debug.LogError("Disconnect 호출 실패: _roomId가 설정되지 않음");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_socket.Emit("disconnect", new { roomId = _roomId });
|
||||||
|
_roomId = null; // 방 나가면 roomId 초기화
|
||||||
|
}
|
||||||
|
|
||||||
public void RequestSurrender()
|
public void RequestSurrender()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_roomId))
|
if (string.IsNullOrEmpty(_roomId))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user