コード例 #1
0
 public UnitPiece GetUnit(Point tile)
 {
     if (mapManager.IsWithinBounds(tile))
     {
         return(unitGrid[tile.x, tile.y]);
     }
     return(null);
 }
コード例 #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);
    }
コード例 #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);
    }
コード例 #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);
    }