static bool IsClippingCorner(Tile curr, Tile neigh)
    {
        // If the movement from curr to neigh is diagonal (e.g. N-E)
        // Then check to make sure we aren't clipping (e.g. N and E are both walkable)

        int dX = curr.TileX - neigh.TileX;
        int dY = curr.TileY - neigh.TileY;

        if (Mathf.Abs(dX) + Mathf.Abs(dY) == 2)
        {
            // We are diagonal

            if (CurrentMap.GetTile(curr.TileX - dX, curr.TileY).GetMovementCost() == 0)
            {
                // East or West is unwalkable, therefore this would be a clipped movement.
                return(true);
            }

            if (CurrentMap.GetTile(curr.TileX, curr.TileY - dY).GetMovementCost() == 0)
            {
                // North or South is unwalkable, therefore this would be a clipped movement.
                return(true);
            }

            // If we reach here, we are diagonal, but not clipping
        }

        // If we are here, we are either not clipping, or not diagonal
        return(false);
    }
Ejemplo n.º 2
0
    public List <Tile> GetTilesInRange(Tile tile, int range)
    {
        List <Tile> tilesInRange = new List <Tile>();
        Tile        temp;

        for (int i = tile.TileX - range; i < tile.TileX + range; i++)
        {
            for (int j = tile.TileY - range; j < tile.TileY + range; j++)
            {
                //Starting in the bottom left

                temp = currentMap.GetTile(i, j);
                if (temp != null)
                {
                    tilesInRange.Add(temp);
                }
            }
        }

        return(tilesInRange);
    }