Пример #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]);
        }
    }
Пример #2
0
 protected override void Initialized()
 {
     base.Initialized();
     m_eyeVisualPerception = GetComponentInChildren <EyeVisualPerception>();
     if (m_eyeVisualPerception == null)
     {
         Debug.LogError("There is no eye of the character");
     }
     m_coverFinder              = GetComponentInChildren <CoverFinder>();
     m_navMeshAgent             = GetComponent <NavMeshAgent>();
     m_navMeshPath              = new NavMeshPath();
     m_animator.applyRootMotion = false;
     m_currentIndexOfGivenPath  = 0;
     m_mainDestinationPoint     = m_FollowPath.pathTransformPosition[m_currentIndexOfGivenPath].position;
     transform.position         = m_mainDestinationPoint;
     m_currentDestinationPoint  = m_mainDestinationPoint;
     m_navMeshPath              = CalculateNavmeshPath(m_mainDestinationPoint);
     CheckStates();
 }