Beispiel #1
0
    public override void moveGamePiece(Vector2 direction, int speed)
    {
        for (int i = 0; i < speed; i++)
        {
            Vector2   destCoords  = coordinates + direction;
            GameSpace destination = board.getTile(destCoords);

            // Check that the destination tile exists on the GameBoard
            if (destination != null && !pawnStat.isDead())
            {
                // Then check that tile to see if it is occupied by another GamePiece
                if (destination.isOccupied())
                {
                    collide(destination.getOccupant());
                }
                else
                {
                    // If the tile is empty and valid, pass the pawn to the next tile
                    occupiedTile.passOccupant();
                    occupiedTile = board.getTile(coordinates + direction);
                    occupiedTile.recieveOccupant(gameObject.GetComponent <GamePiece>());
                    coordinates += direction;
                }
            }
        }
    }
Beispiel #2
0
    public void setSelectedGameSpace(GameSpace s)
    {
        previousGameSpace = selectedGameSpace;
        selectedGameSpace = s;

        gameBoard.dimAllSpaces();



        if (s.getOccupant() != null)
        {
            pawn = s.getOccupant();
            redPanel.setSelectedPawn(pawn);

            validMoves = gameBoard.getValidMoves(pawn.getMoves());
            gameBoard.highlightGameSpaces(validMoves);
        }
        else if (previousGameSpace.isOccupied())
        {
            foreach (Vector2 v in validMoves)
            {
                if (v == selectedGameSpace.getCoordinates())
                {
                    //pawn.moveGamePiece(selectedGameSpace.getCoordinates() - previousGameSpace.getCoordinates(), );
                }
            }
        }
    }