コード例 #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
 void Awake()
 {
     if (m_Map == null)
     {
         m_Map = this;
     }
 }
コード例 #3
0
 public static NavMeshMap GetInstance()
 {
     if (m_Map == null)
     {
         GameObject gameObj = new GameObject("NavMeshMap", typeof(NavMeshMap));
         m_Map = gameObj.GetComponent <NavMeshMap>();
     }
     return(m_Map);
 }
コード例 #4
0
 void OnDestroy()
 {
     if (m_DefaultFilter != null)
     {
         m_DefaultFilter.RequestDisposal();
         m_DefaultFilter = null;
     }
     Clear();
     m_Map = null;
 }
コード例 #5
0
        private bool Follow(Vector3 pos)
        {
            if (!IsInited || !NavMeshMap.IsVaild)
            {
                return(false);
            }
            NavmeshPoint pt;

            if (!NavMeshMap.GetNavmeshPoint(pos, this.Extends, out pt, GetFilter()))
            {
                return(false);
            }
            return(Follow(pt));
        }
コード例 #6
0
 void Update()
 {
     if (m_Mgr != null)
     {
         float delta = Time.unscaledDeltaTime;
         m_Mgr.Update(delta);
     }
     else
     {
         if (NavMeshMap.IsVaild)
         {
             var mesh = NavMeshMap.GetNavMesh();
             if (mesh != null)
             {
                 this._Init(mesh);
             }
         }
     }
 }
コード例 #7
0
        public static bool LoadMap(byte[] buffer)
        {
            NavMeshMap map = GetInstance();

            return(map.LoadMapFromBuffer(buffer));
        }