示例#1
0
        //--------------------------------------------Crowd调用相关方法----------------------------------------------------------------//

        //如果不在crowd里面就把agent加入到crowd里面去
        public CrowdAgent AddToCrowd(Vector3 position)
        {
            if (navGroup.crowd == null)
            {
                return(null);
            }
            if (crowdAgent == null)
            {
                crowdAgent = navGroup.crowd.AddAgent(position, crowdConfig);
            }
            else
            {
                if (crowdAgent.Position != position)
                {
                    RemoveFromCrowd();
                    crowdAgent = navGroup.crowd.AddAgent(position, crowdConfig);
                }
                else if ((flags | NavFlag.CrowdConfigUpdated) != 0)
                {
                    crowdAgent.SetConfig(crowdConfig);
                }
            }

            flags &= ~NavFlag.CrowdConfigUpdated;
            return(crowdAgent);
        }
示例#2
0
 //设置道路资源,目前来看是一个必要的过程
 //主要是为了操作group
 public void SetCorridorAssets(bool enabled)
 {
     if (enabled)
     {
         if (corridor == null)
         {
             corridor = agentGroup.GetCorridor(position, navGroup.query, navGroup.filter);
         }
         flags |= NavFlag.CorridorInUse;
     }
     else
     {
         agentGroup.ReturnCorridor(corridor);
         corridor = null;
         flags   &= ~NavFlag.CorridorInUse;
     }
 }
示例#3
0
        public void SetPathAssets(bool enabled)
        {
            if (enabled)
            {
                if (path == null)
                {
                    path = agentGroup.GetPath();
                }

                flags |= NavFlag.PathInUse;
            }
            else
            {
                agentGroup.ReturnPath(path);

                path   = null;
                flags &= ~NavFlag.PathInUse;
            }
        }