Exemple #1
0
    public bool MoveToIndex(int[] goalIndexArray)
    {
        int startIndex = PathTerrain.GetPathNodeIndex(transform.position);

        m_planParams = new PathPlanParams_Batch(startIndex, goalIndexArray, PathTerrain);
        return(m_pathAgent.RequestPath(m_planParams));
    }
Exemple #2
0
    public IPathRequestQuery RequestPathPlan(PathPlanParams_Batch pathPlanParams, IPathAgent agent)
    {
        if (!m_bInitialized)
        {
            UnityEngine.Debug.LogError("PathManagerComponent isn't yet fully intialized. Wait until Start() has been called. Can't call RequestPathPlan.");
            return(null);
        }

        if (m_requestPool.Count == 0)
        {
            UnityEngine.Debug.Log("RequestPathPlan failed because it is already servicing the maximum number of requests: " +
                                  m_maxNumberOfPlanners.ToString());
            return(null);
        }

        if (m_pathPlannerPool.AvailableCount == 0)
        {
            UnityEngine.Debug.Log("RequestPathPlan failed because it is already servicing the maximum number of path requests: " +
                                  m_maxNumberOfPlanners.ToString());
            return(null);
        }

        // Clamp the start and goal positions within the terrain space, and make sure they are on the floor.
        //pathPlanParams.UpdateStartAndGoalPos( m_terrain.GetValidPathFloorPos(pathPlanParams.StartPos) );

        // Make sure this agent does not have an active request
        if (m_activeRequests.Count > 0)
        {
            foreach (PathRequest_Batch pathRequest in m_activeRequests)
            {
                if (pathRequest.Agent.GetHashCode() == agent.GetHashCode())
                {
                    System.Diagnostics.Debug.Assert(false, "Each agent can only have one path request at a time.");
                    return(null);
                }
            }
        }

        // Create the new request
        Pool <PathPlanner> .Node pathPlanner = m_pathPlannerPool.Get();
        PathRequest_Batch        request     = m_requestPool.Dequeue();

        request.Set(pathPlanParams, pathPlanner, agent);
        m_activeRequests.AddFirst(request);

        // Start the request
        pathPlanner.Item.StartANewPlan(request.PlanParams.GetCurrentIndex(), request.PlanParams.GetCurrentGoalIndexAndMoveNext());

        return(request);
    }
Exemple #3
0
    public bool RequestPath(PathPlanParams_Batch pathPlanParams)
    {
        if (!m_bInitialized)
        {
            return(false);
        }

        m_pathManager.RemoveRequest(m_query);
        m_query = m_pathManager.RequestPathPlan(pathPlanParams, this);
        if (m_query == null)
        {
            return(false);
        }
        return(true);
    }