Exemplo n.º 1
0
        internal bool AddAgent(CrowdMoveAgent agent)
        {
            if (m_IsAppQuit || agent == null || m_Mgr == null)
            {
                return(false);
            }
            var          param = agent.GetParams();
            var          pt    = agent.transform.position;
            NavmeshPoint pp;
            Vector3      extends = agent.Extends;

            if (!NavMeshMap.GetNavmeshPoint(pt, extends, out pp, agent.GetFilter()))
            {
                return(false);
            }
            agent.transform.position = pp.point;
            CrowdAgent a = m_Mgr.AddAgent(pp.point, param);

            agent._SetAgent(a);
            agent._SetId(NewGlobalId());
            var node = agent.ListNode;
            var list = node.List;

            if (list != m_AgentList)
            {
                if (list != null)
                {
                    list.Remove(node);
                }
                m_AgentList.AddLast(node);
            }
            return(true);
        }
Exemplo n.º 2
0
    private NavStatus generateNavPath(NavmeshPoint start, NavmeshPoint end)
    {
        if (mCrowdAgent == null)
        {
            mCrowdAgent = mCrowdManager.AddAgent(start.point, mCrowdAgentParams);
            mCrowdAgent.RequestMoveTarget(end);
        }
        else
        {
            if (mCrowdAgent.Position != end.point)
            {
                mCrowdManager.RemoveAgent(mCrowdAgent);
                mCrowdAgent = mCrowdManager.AddAgent(start.point, mCrowdAgentParams);
                mCrowdAgent.RequestMoveTarget(end);
            }
        }

        //return status;
        return(NavStatus.Sucess);
    }