Degullmok-client/Assets/Script/Renju/RenjuDetector.cs
fiore 7541e9195e DO-31 Feat: 렌주 룰 삼삼 금지 감지 클래스 작성
- 렌주룰 공통 클래스 생성
- 삼삼 금수 감지 클래스 생성
2025-03-14 23:14:04 +09:00

38 lines
1.0 KiB
C#

using UnityEngine;
public class RenjuDetector
{
// 방향 배열 (가로, 세로, 대각선)
private protected Vector2Int[] directions =
{
new Vector2Int(1, 0), // 가로
new Vector2Int(0, 1), // 세로
new Vector2Int(1, 1), // 대각선 (우하향)
new Vector2Int(1, -1) // 대각선 (우상향)
};
// 15*15 보드 사이즈
private protected int _boardSize = 15;
/// <summary>
/// 좌표가 보드 범위 내에 있는지 확인
/// </summary>
private protected bool IsValidPosition(int row, int col)
{
var inBoardSizeRow = row >= 0 && row < _boardSize;
var inBoardSizeCol = col >= 0 && col < _boardSize;
return inBoardSizeRow && inBoardSizeCol;
}
/// <summary>
/// 해당 위치가 비어있는지 확인
/// </summary>
private protected bool IsEmptyPosition(Enums.PlayerType[,] board, int row, int col)
{
if (!IsValidPosition(row, col)) return false;
return board[row, col] == Enums.PlayerType.None;
}
}