From b43fb6a726ba55d1267322789b8f6c35adad67ab Mon Sep 17 00:00:00 2001 From: Lim0_C Date: Mon, 17 Mar 2025 15:08:52 +0900 Subject: [PATCH] =?UTF-8?q?DO-33=20[Feat]=20Timer=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/LYC/GameCopyLYC.unity | 111 ++++++++++++++++++++++++++++++ Assets/Script/Game/GameLogic.cs | 34 +++++++-- Assets/Script/Game/GameManager.cs | 7 +- 3 files changed, 146 insertions(+), 6 deletions(-) diff --git a/Assets/LYC/GameCopyLYC.unity b/Assets/LYC/GameCopyLYC.unity index 63a21de..39015d5 100644 --- a/Assets/LYC/GameCopyLYC.unity +++ b/Assets/LYC/GameCopyLYC.unity @@ -6147,6 +6147,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9726acf6f82a3644ba31eda5ef496991, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &832166178 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + m_PrefabInstance: {fileID: 1468824283} + m_PrefabAsset: {fileID: 0} --- !u!1001 &846962871 PrefabInstance: m_ObjectHideFlags: 0 @@ -10812,6 +10817,111 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9726acf6f82a3644ba31eda5ef496991, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1001 &1468824283 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 4044003808638558126} + m_Modifications: + - target: {fileID: 4527645627922892802, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_Name + value: Retry Button + objectReference: {fileID: 0} + - target: {fileID: 5432505654977179684, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 679766977} + - target: {fileID: 5432505654977179684, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: RetryGame + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_Pivot.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_Pivot.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchorMin.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_SizeDelta.x + value: 228 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_SizeDelta.y + value: 125.899994 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchoredPosition.x + value: -50 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_AnchoredPosition.y + value: -100 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6675599954136940932, guid: 67fa853934a50654381442493bf1bb7b, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 67fa853934a50654381442493bf1bb7b, type: 3} --- !u!1001 &1469317351 PrefabInstance: m_ObjectHideFlags: 0 @@ -18359,6 +18469,7 @@ RectTransform: m_Children: - {fileID: 4020956125928089309} - {fileID: 5290633646021932} + - {fileID: 832166178} m_Father: {fileID: 6113787613455091453} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index f4a9e0e..e47a007 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -12,6 +12,9 @@ public abstract class BasePlayerState public void ProcessMove(GameLogic gameLogic, Enums.PlayerType playerType, int row, int col) { + + gameLogic.fioTimer.PauseTimer(); + gameLogic.SetNewBoardValue(playerType, row, col); //TODO: 승리확인 if (gameLogic.CheckGameWin(playerType, row, col)) @@ -39,6 +42,8 @@ public class PlayerState : BasePlayerState public override void OnEnter(GameLogic gameLogic) { + gameLogic.fioTimer.StartTimer(); + gameLogic.currentTurn = _playerType; gameLogic.stoneController.OnStoneClickedDelegate = (row, col) => { @@ -48,6 +53,7 @@ public class PlayerState : BasePlayerState public override void OnExit(GameLogic gameLogic) { + gameLogic.fioTimer.InitTimer(); gameLogic.stoneController.OnStoneClickedDelegate = null; } @@ -73,12 +79,13 @@ public class AIState: BasePlayerState { public override void OnEnter(GameLogic gameLogic) { + gameLogic.fioTimer.StartTimer(); //TODO: AI이식 } public override void OnExit(GameLogic gameLogic) { - + gameLogic.fioTimer.InitTimer(); } public override void HandleMove(GameLogic gameLogic, int row, int col) @@ -95,12 +102,12 @@ public class MultiPlayerState: BasePlayerState { public override void OnEnter(GameLogic gameLogic) { - + gameLogic.fioTimer.StartTimer(); } public override void OnExit(GameLogic gameLogic) { - + gameLogic.fioTimer.InitTimer(); } public override void HandleMove(GameLogic gameLogic, int row, int col) @@ -123,6 +130,7 @@ public class GameLogic : MonoBehaviour public BasePlayerState firstPlayerState; public BasePlayerState secondPlayerState; private BasePlayerState _currentPlayerState; + public FioTimer fioTimer; private const int WIN_COUNT = 5; //선택된 좌표 @@ -140,16 +148,34 @@ public class GameLogic : MonoBehaviour new int[] {1, -1} // 대각선 ↙ ↗ }; - public GameLogic(StoneController stoneController, Enums.GameType gameType) + public GameLogic(StoneController stoneController, Enums.GameType gameType, FioTimer fioTimer) { //보드 초기화 _board = new Enums.PlayerType[15, 15]; this.stoneController = stoneController; this.gameType = gameType; + selectedRow = -1; selectedCol = -1; _lastRow = -1; _lastCol = -1; + //timer 초기화 + this.fioTimer = fioTimer; + this.fioTimer.InitTimer(); + //timer 시간초과시 진행 함수 + this.fioTimer.OnTimeout = () => + { + if (currentTurn == Enums.PlayerType.PlayerA) + { + GameManager.Instance.OpenConfirmPanel($"Game Over: {PlayerType.PlayerB} Win",() =>{}); + EndGame(); + } + else if (currentTurn == Enums.PlayerType.PlayerB) + { + GameManager.Instance.OpenConfirmPanel($"Game Over: {PlayerType.PlayerA} Win",() =>{}); + EndGame(); + } + }; switch (gameType) { diff --git a/Assets/Script/Game/GameManager.cs b/Assets/Script/Game/GameManager.cs index 2fe806a..ecc609e 100644 --- a/Assets/Script/Game/GameManager.cs +++ b/Assets/Script/Game/GameManager.cs @@ -19,6 +19,7 @@ public class GameManager : Singleton private UserManager _userManager; // UserManager 인스턴스 관리 private CoinsPanelController _coinsPanel; + private Enums.GameType _gameType; private GameLogic _gameLogic; private StoneController _stoneController; @@ -49,7 +50,8 @@ public class GameManager : Singleton _canvas = canvas.GetComponent(); _stoneController = GameObject.FindObjectOfType(); _stoneController.InitStones(); - _gameLogic = new GameLogic(_stoneController, _gameType); + var fioTimer = FindObjectOfType(); + _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); } private void TryAutoSignin() @@ -142,7 +144,8 @@ public class GameManager : Singleton { _stoneController = GameObject.FindObjectOfType(); _stoneController.InitStones(); - _gameLogic = new GameLogic(_stoneController, _gameType); + var fioTimer = FindObjectOfType(); + _gameLogic = new GameLogic(_stoneController, _gameType, fioTimer); } _canvas = GameObject.Find("Canvas").GetComponent(); }