Пример #1
0
    public static BresenhamResults CalculateLine(Vector2Int start, Vector2Int end)
    {
        BresenhamResults results = new BresenhamResults();

        results.path     = new List <CustomTile>();
        results.fullPath = new List <CustomTile>();
        bool beenBlocked = false;

        foreach (Vector2Int spot in GetPointsOnLine(start.x, start.y, end.x, end.y))
        {
            //It's assumed that something that blocks movement blocks this line.
            //TODO: Make sure this assumption actually makes sense
            CustomTile t = Map.current.GetTile(spot);
            if (!beenBlocked)
            {
                results.path.Add(t);
                results.fullPath.Add(t);
            }
            if (t.BlocksMovement())
            {
                beenBlocked = true;
            }
        }
        results.blocked = beenBlocked;
        return(results);
    }
Пример #2
0
    private void DrawBrensham(Vector2Int point)
    {
        BresenhamResults brensham = LOS.GetLineFrom(origin, point);

        //Skip the first one
        foreach (CustomTile tile in brensham.path)
        {
            int x = tile.location.x;
            int y = tile.location.y;
            MarkArea(x, y, true);
        }
    }