Ejemplo n.º 1
0
        /// <summary>
        /// 初始化代理器
        /// </summary>
        public virtual void InitProxy()
        {
            AgentProxyTypeInfo agentTypeInfo = BehaviorTreeManager.Instance.GetRegistedAgentType(ProxyType);

            if (agentTypeInfo == null)
            {
                Debug.LogError($"行为主体未注册 AgentName :{ProxyType}");
                return;
            }

            if (!agentTypeInfo.IsLua)
            {
                Type type = BehaviorTreeManager.Instance.GetAgentType(agentTypeInfo.AgentName);
                Proxy = Activator.CreateInstance(type) as AgentCsProxy;
            }
            else
            {
                Proxy = new AgentLuaProxy();
            }

            if (Proxy == null)
            {
                Debug.LogError($"错误!!找不到行为主体代理器 ClassType:{ProxyType}");
                return;
            }

            Proxy.SetAgent(this, agentTypeInfo.AgentName);
            Proxy?.OnAwake();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取Agent代理
        /// </summary>
        /// <param name="agentName"></param>
        /// <returns></returns>
        public AgentProxyTypeInfo GetRegistedAgentType(string agentName)
        {
            AgentProxyTypeInfo agentTypeInfo = null;

            RegistedLuaAgentProxyTypeDic.TryGetValue(agentName, out agentTypeInfo);
            if (agentTypeInfo != null)
            {
                return(agentTypeInfo);
            }

            RegistedCsAgentProxyTypeDic.TryGetValue(agentName, out agentTypeInfo);
            return(agentTypeInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 注册luaAgent代理
        /// </summary>
        /// <param name="classType"></param>
        public void RegisterLuaAgentProxy(string classType)
        {
            if (RegistedLuaAgentProxyTypeDic.ContainsKey(classType))
            {
                Debug.LogError($"错误:Lua重复注册行为主体 ClassType:{classType}");
                return;
            }

            AgentProxyTypeInfo agentTypeInfo = new AgentProxyTypeInfo
            {
                AgentName = classType,
                IsLua     = true,
            };

            RegistedLuaAgentProxyTypeDic.Add(classType, agentTypeInfo);
        }