예제 #1
0
    public List <Vector3Int> ShowPath(Child child, Vector2Int start, Vector2Int finish)
    {
        bool              foundFinish = false;
        int               i           = 0;
        Vector2Int        moveOffset  = Vector2Int.zero;
        Vector2Int        pos         = start;
        List <Vector3Int> coloredPath = new List <Vector3Int>();

        while (!foundFinish && i < child.path.Count)
        {
            moveOffset = GAController.DetermineOffset(child.path[i], moveOffset);
            pos       += moveOffset;
            if (labGrid.grid[pos.x, pos.y] == 1)
            {
                break;
            }
            Vector3Int tilePos = new Vector3Int(pos.x, pos.y, 0);
            tileMap.SetColor(tilePos, Color.blue);
            coloredPath.Add(tilePos);
            if (pos.x == finish.x && pos.y == finish.y)
            {
                foundFinish = true;
            }
            i++;
        }
        return(coloredPath);
    }