DO-41 [Feat] 무승부 기능 추가

This commit is contained in:
Lim0_C 2025-03-20 14:12:54 +09:00
parent a418cb1a3e
commit 0c4f59b9e5
2 changed files with 145 additions and 10 deletions

View File

@ -8175,6 +8175,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1118625358}
- component: {fileID: 1118625360}
- component: {fileID: 1118625359}
m_Layer: 0
m_Name: GameManager
m_TagString: Untagged
@ -8197,6 +8199,116 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1118625359
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118625357}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35a4c6d5d3a97b444b968e68ec8bb9f7, type: 3}
m_Name:
m_EditorClassIdentifier:
panelManagerPrefab: {fileID: 3475740041361426276, guid: 085ca07ca90c92545b2594bd13412701, type: 3}
audioManagerPrefab: {fileID: 2946408323859178723, guid: e829818dce39a5d4383e061111bed871, type: 3}
--- !u!82 &1118625360
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1118625357}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1001 &1121996003
PrefabInstance:
m_ObjectHideFlags: 0
@ -17421,7 +17533,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7155909258766834886, guid: b1a31da84076a534cae7cb20a7913a93, type: 3}
propertyPath: m_Name
value: '[Canvas] Game UI'
value: Canvas
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []

View File

@ -213,7 +213,6 @@ public class GameLogic : MonoBehaviour
//TODO: 기보 매니저에게 플레이어 닉네임 넘겨주기
ReplayManager.Instance.InitReplayData("PlayerA","nicknameB");
switch (gameType)
{
case Enums.GameType.SinglePlay:
@ -229,6 +228,7 @@ public class GameLogic : MonoBehaviour
break;
}
}
//착수 버튼 클릭시 호출되는 함수
public void OnConfirm()
{
@ -327,7 +327,6 @@ public class GameLogic : MonoBehaviour
public void EndGame()
{
SetState(null);
}
//승리 확인 함수
@ -391,25 +390,49 @@ public class GameLogic : MonoBehaviour
public bool CheckGameDraw(Enums.PlayerType[,] board)
{
List<(int, int)> validMoves = new List<(int, int)>();
if (CheckIsFull(board)) return true; // 빈 칸이 없으면 무승부
bool playerAHasChance = CheckFiveChance(board, Enums.PlayerType.PlayerA);
bool playerBHasChance = CheckFiveChance(board, Enums.PlayerType.PlayerB);
return !(playerAHasChance || playerBHasChance); // 둘 다 기회가 없으면 무승부
}
private bool CheckFiveChance(Enums.PlayerType[,] board, Enums.PlayerType player)
{
var tempBoard = (Enums.PlayerType[,])board.Clone();
int size = board.GetLength(0);
for (int row = 0; row < size; row++)
{
for (int col = 0; col < size; col++)
{
if (board[row, col] == Enums.PlayerType.None)
if (tempBoard[row, col] != Enums.PlayerType.None) continue;
tempBoard[row, col] = player;
foreach (var dir in _directions)
{
validMoves.Add((row, col));
}
}
}
if (validMoves.Count == 0) return true;
var (count, _) = CountStones(tempBoard, row, col, dir, player);
// 자기 자신 포함하여 5개 이상일 시 true 반환
if (count + 1 >= WIN_COUNT)
return true;
}
}
}
return false;
}
#region Renju Rule Detector
private static bool CheckIsFull(Enums.PlayerType[,] board)
{
int size = board.GetLength(0);
for (int row = 0; row < size; row++)
{
for (int col = 0; col < size; col++)
{
if (board[row, col] == Enums.PlayerType.None) return false;
}
}
return true;
}
#region Renju Rule Detector
// 금수 위치 업데이트 및 표시
private void UpdateForbiddenMoves()
{