示例#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);
        }
示例#2
0
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     if (EditorApplication.isPlaying)
     {
         Recast.CrowdMoveAgent moveAgent = this.target as Recast.CrowdMoveAgent;
         if (moveAgent != null)
         {
             Vector3 vec = moveAgent.GetCurrVec();
             GUILayout.Label("当前速度: " + vec.ToString("f2"));
         }
     }
 }
示例#3
0
        internal void RemoveAgent(CrowdMoveAgent agent)
        {
            if (m_IsAppQuit || agent == null)
            {
                return;
            }

            if (agent == null)
            {
                return;
            }

            if (agent.HasListNode)
            {
                var node = agent.ListNode;
                m_AgentList.Remove(node);
            }

            if (m_Mgr != null)
            {
                m_Mgr.RemoveAgent(agent.Agent);
            }
        }