DO-33 [Style] GameLogic 코드 정리

타임아웃 무명함수를 밖으로 뺌 게임이 끝나면 리플레이 저장 함수 호출 추가
This commit is contained in:
Lim0_C 2025-03-18 17:03:19 +09:00
parent 3d6655e6e3
commit f488359af9
3 changed files with 26 additions and 23 deletions

View File

@ -170,7 +170,7 @@ MonoBehaviour:
signinPanel: {fileID: 925522282249935710, guid: e14c9b2925f0ddb4192af743e5cc166a, type: 3} signinPanel: {fileID: 925522282249935710, guid: e14c9b2925f0ddb4192af743e5cc166a, type: 3}
signupPanel: {fileID: 3181524094944658765, guid: 8827fe7caa3145e40b1369cc42f8697d, type: 3} signupPanel: {fileID: 3181524094944658765, guid: 8827fe7caa3145e40b1369cc42f8697d, type: 3}
settingsPanel: {fileID: 0} settingsPanel: {fileID: 0}
confirmPanel: {fileID: 0} confirmPanel: {fileID: 8145365568262946399, guid: 76f1fe6b5243faf4f9b8caee7312d336, type: 3}
rankingPanel: {fileID: 0} rankingPanel: {fileID: 0}
shopPanel: {fileID: 0} shopPanel: {fileID: 0}
giboPanel: {fileID: 0} giboPanel: {fileID: 0}

View File

@ -170,22 +170,7 @@ public class GameLogic : MonoBehaviour
{ {
this.fioTimer = fioTimer; this.fioTimer = fioTimer;
this.fioTimer.InitTimer(); this.fioTimer.InitTimer();
//timer 시간초과시 진행 함수 this.fioTimer.OnTimeout = OnTimeout;
this.fioTimer.OnTimeout = () =>
{
if (currentTurn == Enums.PlayerType.PlayerA)
{
GameManager.Instance.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerB} Win",
() =>{});
EndGame();
}
else if (currentTurn == Enums.PlayerType.PlayerB)
{
GameManager.Instance.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerA} Win",
() =>{});
EndGame();
}
};
} }
//TODO: 기보 매니저에게 플레이어 닉네임 넘겨주기 //TODO: 기보 매니저에게 플레이어 닉네임 넘겨주기
@ -206,6 +191,24 @@ public class GameLogic : MonoBehaviour
break; break;
} }
} }
//타임아웃 시 할 행동
private void OnTimeout()
{
if (currentTurn == Enums.PlayerType.PlayerA)
{
GameManager.Instance.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerB} Win",
() =>{});
EndGame();
}
else if (currentTurn == Enums.PlayerType.PlayerB)
{
GameManager.Instance.OpenConfirmPanel($"Game Over: {Enums.PlayerType.PlayerA} Win",
() =>{});
EndGame();
}
}
//착수 버튼 클릭시 호출되는 함수 //착수 버튼 클릭시 호출되는 함수
public void OnConfirm() public void OnConfirm()
{ {
@ -298,7 +301,7 @@ public class GameLogic : MonoBehaviour
public void EndGame() public void EndGame()
{ {
SetState(null); SetState(null);
ReplayManager.Instance.SaveReplayData(currentTurn);
} }
//승리 확인 함수 //승리 확인 함수

View File

@ -49,11 +49,11 @@ public class GameManager : Singleton<GameManager>
// TryAutoSignin(); // TryAutoSignin();
//게임 씬에서 확인하기 위한 임시 코드 //게임 씬에서 확인하기 위한 임시 코드
_canvas = canvas.GetComponent<Canvas>(); // _canvas = canvas.GetComponent<Canvas>();
_stoneController = GameObject.FindObjectOfType<StoneController>(); // _stoneController = GameObject.FindObjectOfType<StoneController>();
_stoneController.InitStones(); // _stoneController.InitStones();
var fioTimer = FindObjectOfType<FioTimer>(); // var fioTimer = FindObjectOfType<FioTimer>();
_gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); // _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer);
} }
private void TryAutoSignin() private void TryAutoSignin()