Ejemplo n.º 1
0
    public void Start()
    {
        Vector3 position = transform.position;

        foreach (PathfindingLayer layer in layers)
        {
            PathfindingGrid grid = new PathfindingGrid(width, height, tileSize);

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    Vector2 origin = new Vector2(x * tileSize.x + position.x, (y - height) * tileSize.y + position.y);
                    if (Physics2D.OverlapArea(origin, origin + tileSize, layer.collisionMask) == null)
                    {
                        grid.MarkPassible(x, y);
                    }
                }
            }
            grid.BuildIndex();
            grids[layer.name] = grid;
        }

        if (grids.ContainsKey(PathingTypes.Walking) && grids.ContainsKey(PathingTypes.Flying))
        {
            coverOptions = CoverFinder.FindCover(grids[PathingTypes.Walking], grids[PathingTypes.Flying]);
        }
    }