Пример #1
0
    public Piece DeclarePiece(Piece.Type type, int x, int y)
    {
        Piece piece = new Piece();

        switch (type)
        {
            case Piece.Type.PAWN:

                piece.gameObject = (GameObject)Instantiate(piecePawn, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.PAWN;

                break;

            case Piece.Type.BISHOP:

                piece.gameObject = (GameObject)Instantiate(pieceBishop, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.BISHOP;

                break;

            case Piece.Type.KNIGHT:

                piece.gameObject = (GameObject)Instantiate(pieceKnight, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.KNIGHT;

                break;

            case Piece.Type.ROOK:

                piece.gameObject = (GameObject)Instantiate(pieceRook, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.ROOK;

                break;

            case Piece.Type.QUEEN:

                piece.gameObject = (GameObject)Instantiate(pieceQueen, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.QUEEN;

                break;

            case Piece.Type.KING:

                piece.gameObject = (GameObject)Instantiate(pieceKing, Vector3.zero, Quaternion.identity);
                piece.type = Piece.Type.KING;

                break;
        }

        piece.SetPositionOneAbove(tiles[x,y].gameObject);

        return piece;
    }