コード例 #1
0
        private List <Vector2> King(int xPos, int zPos)
        {
            List <Vector2> result = new List <Vector2>();

            #region King
            ChessPieceInformation[,] board = boardManager.GetBoard();

            // 위
            try
            {
                for (int i = xPos - 1; i <= xPos + 1; i++)
                {
                    ChessPieceInformation manager = board[i, zPos + 1];
                    Vector2 tempResult            = new Vector2(i, zPos + 1);
                    if (manager.PieceName == DataManager.PieceName.None)
                    {
                        result.Add(tempResult);
                    }
                    else
                    {
                        if (currentTeam != manager.Team)
                        {
                            result.Add(tempResult);
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException) { /* do nothing */ }

            // 중간
            try
            {
                for (int i = xPos - 1; i <= xPos + 1; i++)
                {
                    ChessPieceInformation manager = board[i, zPos];
                    Vector2 tempResult            = new Vector2(i, zPos);
                    if (i == xPos)
                    {
                        continue;
                    }

                    if (manager.PieceName == DataManager.PieceName.None)
                    {
                        result.Add(tempResult);
                    }
                    else
                    {
                        if (currentTeam != manager.Team)
                        {
                            result.Add(tempResult);
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException) { /* do nothing */ }

            // 아래
            try
            {
                for (int i = xPos - 1; i <= xPos + 1; i++)
                {
                    ChessPieceInformation manager = board[i, zPos - 1];
                    Vector2 tempResult            = new Vector2(i, zPos - 1);
                    if (manager.PieceName == DataManager.PieceName.None)
                    {
                        result.Add(tempResult);
                    }
                    else
                    {
                        if (currentTeam != manager.Team)
                        {
                            result.Add(tempResult);
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException) { /* do nothing */ }
            #endregion
            return(result);
        }
コード例 #2
0
 private void Start()
 {
     boardStateManager = GetManager <BoardStateManager>();
     board             = boardStateManager.GetBoard();
 }