diff --git a/Assets/LYC/GameCopyLYC.unity b/Assets/LYC/GameCopyLYC.unity index 19e0448..406f480 100644 --- a/Assets/LYC/GameCopyLYC.unity +++ b/Assets/LYC/GameCopyLYC.unity @@ -6020,6 +6020,50 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9726acf6f82a3644ba31eda5ef496991, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &820078853 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 820078855} + - component: {fileID: 820078854} + m_Layer: 0 + m_Name: OmokAI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &820078854 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 820078853} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 576baa0fe98d40608bf48109ba5ed788, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &820078855 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 820078853} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 540, y: 1760, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &831992430 PrefabInstance: m_ObjectHideFlags: 0 @@ -17550,3 +17594,4 @@ SceneRoots: - {fileID: 307507522} - {fileID: 1632066875} - {fileID: 1118625358} + - {fileID: 820078855} diff --git a/Assets/Script/Common/Constants.cs b/Assets/Script/Common/Constants.cs index 9cd5c76..8fae832 100644 --- a/Assets/Script/Common/Constants.cs +++ b/Assets/Script/Common/Constants.cs @@ -4,4 +4,7 @@ public const string GameServerURL = "ws://localhost:3000"; public const int BoardSize = 15; public const int ReplayMaxRecordSize = 10; + public const int WIN_COUNT = 5; + //무승부 확인을 위한 최소 착수 수 + public const int MinCountForDrawCheck = 150; } \ No newline at end of file diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 5ced4d7..28b2d2f 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -24,17 +24,23 @@ public abstract class BasePlayerState } else { - if (gameLogic.CheckGameDraw(gameLogic.GetBoard())) + if (gameLogic.TotalStoneCounter >= Constants.MinCountForDrawCheck) { - GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: Draw",() =>{}); - gameLogic.EndGame(); + if (gameLogic.CheckGameDraw()) + { + GameManager.Instance.panelManager.OpenConfirmPanel($"Game Over: Draw",() =>{}); + gameLogic.EndGame(); + } + else + { + HandleNextTurn(gameLogic); + } } else { HandleNextTurn(gameLogic); } } - } } @@ -145,7 +151,7 @@ public class GameLogic : MonoBehaviour public Enums.PlayerType currentTurn; public Enums.GameType gameType; //총 착수된 돌 카운터 - private int _totalStoneCounter = 0; + public int _totalStoneCounter; public int TotalStoneCounter{get{return _totalStoneCounter;}} public BasePlayerState firstPlayerState; @@ -154,9 +160,6 @@ public class GameLogic : MonoBehaviour //타이머 public FioTimer fioTimer; - private const int WIN_COUNT = 5; - //무승부 확인을 위한 최소 착수 수 - private const int MinCountForDrawCheck = 150; //선택된 좌표 public int selectedRow; public int selectedCol; @@ -186,6 +189,7 @@ public class GameLogic : MonoBehaviour _board = new Enums.PlayerType[15, 15]; this.stoneController = stoneController; this.gameType = gameType; + _totalStoneCounter = 0; selectedRow = -1; selectedCol = -1; @@ -354,7 +358,7 @@ public class GameLogic : MonoBehaviour var (count, _) = CountStones(_board, row, col, dir, player); // 자기 자신 포함하여 5개 이상일 시 true 반환 - if (count + 1 >= WIN_COUNT) + if (count + 1 >= Constants.WIN_COUNT) return true; } @@ -405,12 +409,11 @@ public class GameLogic : MonoBehaviour return _board; } //무승부 확인 - public bool CheckGameDraw(Enums.PlayerType[,] board) + public bool CheckGameDraw() { - if (_totalStoneCounter < MinCountForDrawCheck) return false; //최소 착수 수보다 작으면 false 리턴 - if (CheckIsFull(board)) return true; // 빈 칸이 없으면 무승부 - bool playerAHasChance = CheckFiveChance(board, Enums.PlayerType.PlayerA); - bool playerBHasChance = CheckFiveChance(board, Enums.PlayerType.PlayerB); + if (CheckIsFull(_board)) return true; // 빈 칸이 없으면 무승부 + bool playerAHasChance = CheckFiveChance(_board, Enums.PlayerType.PlayerA); + bool playerBHasChance = CheckFiveChance(_board, Enums.PlayerType.PlayerB); return !(playerAHasChance || playerBHasChance); // 둘 다 기회가 없으면 무승부 } @@ -430,7 +433,7 @@ public class GameLogic : MonoBehaviour var (count, _) = CountStones(tempBoard, row, col, dir, player); // 자기 자신 포함하여 5개 이상일 시 true 반환 - if (count + 1 >= WIN_COUNT) return true; + if (count + 1 >= Constants.WIN_COUNT) return true; } } }