Ejemplo n.º 1
0
 public UnitPiece GetUnit(Point tile)
 {
     if (mapManager.IsWithinBounds(tile))
     {
         return(unitGrid[tile.x, tile.y]);
     }
     return(null);
 }
Ejemplo n.º 2
0
    public static List <Point> GetVectorTiles(CombatMap map, Point position, Point[] vectors, int maxRange, int minRange = 0)
    {
        List <Point> tiles = new List <Point>();

        foreach (Point vector in vectors)
        {
            for (int i = minRange; i <= maxRange; i++)
            {
                Point tile = position + vector * i;
                if (map.IsWithinBounds(tile))
                {
                    tiles.Add(tile);
                }
            }
        }

        return(tiles);
    }
Ejemplo n.º 3
0
    public static List <Point> GetSquareTiles(CombatMap map, Point position, int maxRange, int minRange = 0)
    {
        List <Point> tiles = new List <Point>();

        for (int x = -maxRange; x <= maxRange; x++)
        {
            for (int y = -maxRange; y <= maxRange; y++)
            {
                // Skip while inside minRange
                if (Mathf.Abs(x) + Mathf.Abs(y) < minRange)
                {
                    continue;
                }
                // Center on owner and check if tile is within bounds
                Point tile = position + new Point(x, y);
                if (map.IsWithinBounds(tile))
                {
                    tiles.Add(tile);
                }
            }
        }

        return(tiles);
    }
Ejemplo n.º 4
0
    public static List <Point> GetDistanceTiles(CombatMap map, Point position, int maxRange, int minRange = 0)
    {
        List <Point> tiles = new List <Point>();

        for (int x = -maxRange; x <= maxRange; x++)
        {
            for (int y = -maxRange; y <= maxRange; y++)
            {
                int distance = Mathf.Abs(x) + Mathf.Abs(y);
                if (distance < minRange || distance > maxRange)
                {
                    continue;
                }

                Point tile = new Point(x + position.x, y + position.y);
                if (map.IsWithinBounds(tile))
                {
                    tiles.Add(tile);
                }
            }
        }

        return(tiles);
    }