当前位置: 首页>>代码示例>>C#>>正文


C# Agent.GetClassTypeName方法代码示例

本文整理汇总了C#中Agent.GetClassTypeName方法的典型用法代码示例。如果您正苦于以下问题:C# Agent.GetClassTypeName方法的具体用法?C# Agent.GetClassTypeName怎么用?C# Agent.GetClassTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent.GetClassTypeName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Log

        //property
        public  void Log(Agent pAgent, string typeName, string varName, string value)
        {
#if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                //BEHAVIAC_PROFILE("LogManager.Instance.LogVar");

                if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked())
                {
                    string agentClassName = pAgent.GetClassTypeName();
                    agentClassName = agentClassName.Replace(".", "::");

                    string agentInstanceName = pAgent.GetName();
                    if (!string.IsNullOrEmpty(agentInstanceName))
                        agentInstanceName = agentInstanceName.Replace(".", "::");

                    //[property]WorldState.World WorldState.time.276854364
                    //[property]Ship.Ship_1 GameObject.HP.100
                    //[property]Ship.Ship_1 GameObject.age.0
                    //[property]Ship.Ship_1 GameObject.speed.0.000000
                    string buffer;

                    buffer = string.Format("[property]{0}#{1} {2}->{3}\n", agentClassName, agentInstanceName, varName, value);

                    bool bOutput = true;

#if BEHAVIAC_USE_HTN
                    if (pAgent.PlanningTop >= 0)
                    {
                        string agentFullName = string.Format("{0}#{1}", agentClassName, agentInstanceName);

                        Dictionary<string, string> p = null;

                        if (!_planningLoggedProperties.ContainsKey(agentFullName))
                        {
                            p = new Dictionary<string, string>();
                            _planningLoggedProperties.Add(agentFullName, p);
                        }
                        else
                        {
                            p = _planningLoggedProperties[agentFullName];
                        }

                        if (p.ContainsKey(varName))
                        {
                            if (p[varName] == value)
                            {
                                bOutput = false;
                            }
                            else
                            {
                                p[varName] = value;
                            }
                        }
                        else
                        {
                            p.Add(varName, value);
                        }
                    }
#endif//
                    if (bOutput)
                    {
                        Output(pAgent, buffer);
                    }
                }
            }

#endif
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:71,代码来源:LogManager.cs

示例2: exec

        public EBTStatus exec(Agent pAgent, EBTStatus childStatus)
        {
            #if !BEHAVIAC_RELEASE
            Debug.Check(this.m_node == null || this.m_node.IsValid(pAgent, this),
                        string.Format("Agent In BT:{0} while the Agent used for: {1}", this.m_node.GetAgentType(), pAgent.GetClassTypeName()));
            #endif//#if !BEHAVIAC_RELEASE
            bool bEnterResult = false;

            if (this.m_status == EBTStatus.BT_RUNNING)
            {
                bEnterResult = true;
            }
            else
            {
                //reset it to invalid when it was success/failure
                this.m_status = EBTStatus.BT_INVALID;
                bEnterResult = this.onenter_action(pAgent);
            }

            if (bEnterResult)
            {
            #if !BEHAVIAC_RELEASE

                if (Config.IsLoggingOrSocketing)
                {
                    string btStr = BehaviorTask.GetTickInfo(pAgent, this, "update");

                    //empty btStr is for internal BehaviorTreeTask
                    if (!string.IsNullOrEmpty(btStr))
                    {
                        LogManager.Instance.Log(pAgent, btStr, EActionResult.EAR_none, LogMode.ELM_tick);
                    }
                }

            #endif
                bool bValid = this.CheckParentUpdatePreconditions(pAgent);

                if (bValid)
                {
                    this.m_status = this.update_current(pAgent, childStatus);
                }
                else
                {
                    this.m_status = EBTStatus.BT_FAILURE;

                    if (this.GetCurrentTask() != null)
                    {
                        this.update_current(pAgent, EBTStatus.BT_FAILURE);
                    }
                }

                if (this.m_status != EBTStatus.BT_RUNNING)
                {
                    //clear it

                    this.onexit_action(pAgent, this.m_status);

                    //this node is possibly ticked by its parent or by the topBranch who records it as currrent node
                    //so, we can't here reset the topBranch's current node
                }
                else
                {
                    BranchTask tree = this.GetTopManageBranchTask();

                    if (tree != null)
                    {
                        tree.SetCurrentTask(this);
                    }
                }
            }
            else
            {
                this.m_status = EBTStatus.BT_FAILURE;
            }

            return this.m_status;
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:77,代码来源:BehaviorTree_task.cs

示例3: LogPlanEnd

        private void LogPlanEnd(Agent a, Task root)
        {
#if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string agentClassName = a.GetClassTypeName();
                string agentInstanceName = a.GetName();

                agentClassName = agentClassName.Replace(".", "::");
                agentInstanceName = agentInstanceName.Replace(".", "::");

                string ni = BehaviorTask.GetTickInfo(a, root, null);
                string buffer = string.Format("[plan_end]{0}#{1} {2}\n", agentClassName, agentInstanceName, ni);

                LogManager.Instance.Log(buffer);
            }

#endif
        }
开发者ID:675492062,项目名称:behaviac,代码行数:20,代码来源:Planner.cs

示例4: LogPlanBegin

        private void LogPlanBegin(Agent a, Task root)
        {
#if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string agentClassName = a.GetClassTypeName();
                string agentInstanceName = a.GetName();

                agentClassName = agentClassName.Replace(".", "::");
                agentInstanceName = agentInstanceName.Replace(".", "::");

                string ni = BehaviorTask.GetTickInfo(a, root, "plan");
                int count = Workspace.Instance.GetActionCount(ni) + 1;
                string buffer = string.Format("[plan_begin]{0}#{1} {2} {3}\n", agentClassName, agentInstanceName, ni, count);

                LogManager.Instance.Log(buffer);

                a.Variables.Log(a, true);
            }

#endif
        }
开发者ID:675492062,项目名称:behaviac,代码行数:23,代码来源:Planner.cs

示例5: exec

        public EBTStatus exec(Agent pAgent)
        {
            #if !BEHAVIAC_RELEASE
            Debug.Check(this.m_node == null || this.m_node.IsValid(pAgent, this),
                string.Format("Agent In BT:{0} while the Agent used for: {1}", this.m_node.GetAgentType(), pAgent.GetClassTypeName()));
            #endif//#if !BEHAVIAC_RELEASE

            bool bEnterResult = false;
            if (this.m_status == EBTStatus.BT_RUNNING)
            {
                bEnterResult = true;
            }
            else
            {
                //reset it to invalid when it was success/failure
                this.m_status = EBTStatus.BT_INVALID;

                bEnterResult = this.onenter_action(pAgent);

                //for continue ticking task, to set it as the cached current task
                bool bIsContinueTicking = this.isContinueTicking();
                if (bIsContinueTicking)
                {
                    BranchTask pBranch = this.GetParentBranch();

                    if (pBranch != null && pBranch != this)
                    {
                        //if 'this' is a tree, don't set it into it parent's current node
                        Debug.Check(!(this is BehaviorTreeTask));

                        pBranch.SetCurrentTask(this);
                    }
                }
            }

            if(bEnterResult)
            {
            #if !BEHAVIAC_RELEASE
                if (Config.IsLoggingOrSocketing)
                {
                    string btStr = BehaviorTask.GetTickInfo(pAgent, this, "update");
                    //empty btStr is for internal BehaviorTreeTask
                    if (!string.IsNullOrEmpty(btStr))
                    {
                        LogManager.Log(pAgent, btStr, EActionResult.EAR_none, LogMode.ELM_tick);
                    }
                }
            #endif

                bool bEnded = false;
                EBTStatus returnStatus = this.GetReturnStatus();
                if (returnStatus == EBTStatus.BT_INVALID)
                {
                    this.m_status = this.update(pAgent, EBTStatus.BT_RUNNING);
                }
                else
                {
                    this.m_status = returnStatus;
                    bEnded = true;
                }

                if (this.m_status != EBTStatus.BT_RUNNING)
                {
                    //clear it
                    bool bIsContinueTicking = this.isContinueTicking();
                    if (bIsContinueTicking)
                    {
                        BranchTask pBranch = this.GetParentBranch();

                        if (pBranch != null && pBranch != this)
                        {
                            //if 'this' is a tree, don't set it into it parent's current node
                            Debug.Check(!(this is BehaviorTreeTask));

                            pBranch.SetCurrentTask(null);
                        }
                    }

                    if (!bEnded)
                    {
                        this.onexit_action(pAgent, this.m_status);
                    }
                }
            }
            else
            {
                this.m_status = EBTStatus.BT_FAILURE;
            }

            EBTStatus currentStatus = this.m_status;
            if (this.m_status != EBTStatus.BT_RUNNING && this.NeedRestart())
            {
                //reset it to invalid when it needs restarting
                //don't need to reset the sub tree
                this.m_status = EBTStatus.BT_INVALID;
                this.SetReturnStatus(EBTStatus.BT_INVALID);
            }

            return currentStatus;
        }
开发者ID:Oswin2014,项目名称:Behavior_Tree-Practice-in-Unity,代码行数:100,代码来源:BehaviorTree_task.cs

示例6: Log

        //property
        public static void Log(Agent pAgent, string typeName, string varName, string value)
        {
            #if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                //BEHAVIAC_PROFILE("LogManager.LogVar");

                if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked())
                {
                    string agentClassName = pAgent.GetClassTypeName();
                    string agentInstanceName = pAgent.GetName();

                    agentClassName = agentClassName.Replace(".", "::");
                    agentInstanceName = agentInstanceName.Replace(".", "::");

                    //[property]WorldState.World WorldState.time.276854364
                    //[property]Ship.Ship_1 GameObject.HP.100
                    //[property]Ship.Ship_1 GameObject.age.0
                    //[property]Ship.Ship_1 GameObject.speed.0.000000
                    string buffer;

                    bool bIsPar = Utils.IsParVar(varName);

                    if (bIsPar)
                    {
                        string tn = typeName;
                        //filter out "signed "
                        tn.Replace("signed ", "");

                        buffer = string.Format("[property]{0}#{1} {2} {3}->{4}\n", agentClassName, agentInstanceName, tn, varName, value);
                    }
                    else
                    {
                        buffer = string.Format("[property]{0}#{1} {2}->{3}\n", agentClassName, agentInstanceName, varName, value);
                    }

                    Output(pAgent, buffer);
                    SocketUtils.SendText(buffer);
                }
            }
            #endif
        }
开发者ID:nusus,项目名称:behaviac,代码行数:43,代码来源:LogManager.cs


注:本文中的Agent.GetClassTypeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。