Ejemplo n.º 1
0
    // Returns the manhattan distance between two tiles
    private int CalculateManhattanDist(Tileable destination, Tileable origin)
    {
        int xDifference = Math.Abs((int)(destination.GetXLocation() - origin.GetXLocation()));
        int yDifference = Math.Abs((int)(destination.GetYLocation() - origin.GetYLocation()));

        return(xDifference + yDifference);
    }
Ejemplo n.º 2
0
    // Must be called before the tile has it's location updated
    private void RecordTileMovement(Tileable itemToMove)
    {
        // Make the tile the item is moving from empty
        int previousItemX = RoundXCoordToInt(itemToMove.GetXLocation());
        int previousItemY = RoundYCoordToPosInt(itemToMove.GetYLocation());
        int newColumn     = RoundXCoordToInt(itemToMove.GetFutureXLocation());
        int newRow        = RoundYCoordToPosInt(itemToMove.GetFutureYLocation());

        gameBoard[previousItemX, previousItemY] = emptyBoardTiles[previousItemX, previousItemY];

        // Give tile new location on gameboard
        gameBoard[newColumn, newRow] = itemToMove;
    }
Ejemplo n.º 3
0
 // Moves a unit to a tile, resets any highlights, checks for end game
 public void MoveUnitToTile(Tileable destination)
 {
     unitToMove.SetLocation(destination.GetXLocation(), destination.GetYLocation(), unitToMove.GetZLocation());
     ResetHighlightedTiles();
     CheckForEndGame();
 }