Esempio n. 1
0
        public Material GetMaterial(PieceScript.Type pieceType, PieceScript.Team team)
        {
            switch (pieceType)
            {
            case PieceScript.Type.Pawn:
                return(team == PieceScript.Team.White ? white_pawn : black_pawn);

            case PieceScript.Type.Rook:
                return(team == PieceScript.Team.White ? white_rook : black_rook);

            case PieceScript.Type.Bishop:
                return(team == PieceScript.Team.White ? white_bishop : black_bishop);

            case PieceScript.Type.Knight:
                return(team == PieceScript.Team.White ? white_knight : black_knight);

            case PieceScript.Type.Queen:
                return(team == PieceScript.Team.White ? white_queen : black_queen);

            case PieceScript.Type.King:
                return(team == PieceScript.Team.White ? white_king : black_king);

            case PieceScript.Type.BLOCK:
                return(BLOCK);

            default:
                return(null);
            }
        }
Esempio n. 2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     currentTurn = PieceScript.Team.White;
 }
Esempio n. 3
0
    /// <summary>
    /// Spawn a piece and put it on the square
    /// </summary>
    /// <param name="type"> which type of piece should be spawned </param>
    /// <param name="team"> which team the spawned piece should be on </param>
    public void SpawnPiece(PieceScript.Type type, PieceScript.Team team)
    {
        GameObject startingPiece = GameObject.Instantiate(GameManager.Instance.basePiecePrefab, new Vector3(position.x, position.y, -1), Quaternion.Euler(0, 0, 180));

        linkedPiece = startingPiece.GetComponent <PieceScript>();
        linkedPiece.SetSquare(this);
        linkedPiece.name = (team + " " + type);
        linkedPiece.type = type;
        linkedPiece.team = team;
        linkedPiece.SetMaterial(type, team);
        BoardManager.Instance.RegisterPiece(linkedPiece);
    }
Esempio n. 4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        switch (playerTeam)
        {
        case PieceScript.Team.White:
            aiTeam = PieceScript.Team.Black;
            break;

        case PieceScript.Team.Black:
            aiTeam = PieceScript.Team.White;
            break;
        }
    }
Esempio n. 5
0
    //public functions

    /// <summary>
    /// Gets the indexes of all of the pieces on the team.
    /// </summary>
    /// <param name="board"> the board with all of the pieces on it </param>
    /// <param name="team"> the team to find the indexes for </param>
    /// <returns> all of the team indexes </returns>
    public static List <int> GetTeamPieceIndexes(char[] board, PieceScript.Team team)
    {
        List <int> pieces = new List <int>();

        for (int i = 0; i < board.Length; i++)
        {
            if (board[i] == '\0')
            {
                continue;
            }

            if ((team == GameManager.Instance.playerTeam && char.IsUpper(board[i])) ||
                (team == GameManager.Instance.aiTeam && char.IsLower(board[i])))
            {
                pieces.Add(i);
            }
        }
        return(pieces);
    }
Esempio n. 6
0
 public void EndTurn()
 {
     turnCounter++;
     currentTurn = (currentTurn == PieceScript.Team.White) ? PieceScript.Team.Black : PieceScript.Team.White;
 }