Esempio n. 1
0
            public override bool Validate(IMovementContext context)
            {
                var tower  = new RookPiece();
                var bishop = new BishopPiece();

                return(tower.Validate(context) && bishop.Validate(context));
            }
Esempio n. 2
0
        // Use this for initialization
        void Start()
        {
            firstClickX = -1;
            firstClickZ = -1;
            playerTurn  = true;           //TODO for other person place switch; //TODO: also switch spaces of queens for other person

            gameSpaces = new GameObject[][] {
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE],
                new GameObject[GAMESIZE]
            };
            gamePieces = new Piece[][] {
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE],
                new Piece[GAMESIZE]
            };

            bool odd = true;

            for (int z = 0; z < GAMESIZE; z++)
            {
                for (int x = 0; x < GAMESIZE; x++)
                {
                    if (z < 2)
                    {
                        //TODO: Change color depending on team.
                        GameObject tempObject;
                        string     tempString = "Piece" + x + "," + z;
                        Piece      tempPiece;
                        if (z == 1)
                        {
                            tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new PawnPiece(tempString, tempObject, true);
                        }
                        else if (x == 0 || x == GAMESIZE - 1)
                        {
                            tempObject = Instantiate(rook, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new RookPiece(tempString, tempObject, true);
                        }
                        else if (x == 1 || x == GAMESIZE - 2)
                        {
                            tempObject = Instantiate(knight, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new KnightPiece(tempString, tempObject, true);
                        }
                        else if (x == 2 || x == GAMESIZE - 3)
                        {
                            tempObject = Instantiate(bishop, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new BishopPiece(tempString, tempObject, true);
                        }
                        else if (x == 3)
                        {
                            tempObject = Instantiate(queen, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new QueenPiece(tempString, tempObject, true);
                        }
                        else if (x == 4)
                        {
                            tempObject = Instantiate(king, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new KingPiece(tempString, tempObject, true);
                        }
                        else
                        {
                            tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new PawnPiece(tempString, tempObject, true);
                        }
                        Renderer rend = tempPiece.getGameObject().GetComponent <Renderer>();
                        rend.material.color = teamColor;
                        gamePieces[x][z]    = tempPiece;
                    }
                    else if (z >= GAMESIZE - 2)
                    {
                        GameObject tempObject;
                        string     tempString = "Piece" + x + "," + z;
                        Piece      tempPiece;
                        if (z == GAMESIZE - 2)
                        {
                            tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new PawnPiece(tempString, tempObject, false);
                        }
                        else if (x == 0 || x == GAMESIZE - 1)
                        {
                            tempObject = Instantiate(rook, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new RookPiece(tempString, tempObject, false);
                        }
                        else if (x == 1 || x == GAMESIZE - 2)
                        {
                            tempObject = Instantiate(knight, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new KnightPiece(tempString, tempObject, false);
                        }
                        else if (x == 2 || x == GAMESIZE - 3)
                        {
                            tempObject = Instantiate(bishop, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new BishopPiece(tempString, tempObject, false);
                        }
                        else if (x == 3)
                        {
                            tempObject = Instantiate(queen, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new QueenPiece(tempString, tempObject, false);
                        }
                        else if (x == 4)
                        {
                            tempObject = Instantiate(king, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new KingPiece(tempString, tempObject, false);
                        }
                        else
                        {
                            tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                            tempPiece  = new PawnPiece(tempString, tempObject, false);
                        }
                        gamePieces[x][z] = tempPiece;
                    }
                    if (odd)
                    {
                        gameSpaces[x][z] = Instantiate(spaces, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                        gameSpaces[x][z].GetComponent <Renderer>().material.color = teamColor;
                    }
                    else
                    {
                        gameSpaces[x][z] = Instantiate(spaces, new Vector3(x, 0, z), Quaternion.identity) as GameObject;
                        gameSpaces[x][z].GetComponent <Renderer>().material.color = Color.white;
                    }
                    gameSpaces[x][z].transform.name = "Space" + x + "," + z;
                    odd = !odd;
                }
                odd = !odd;
            }
            updateFogOfWarBoard();
        }