• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# behaviac.BehaviorNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中behaviac.BehaviorNode的典型用法代码示例。如果您正苦于以下问题:C# BehaviorNode类的具体用法?C# BehaviorNode怎么用?C# BehaviorNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BehaviorNode类属于behaviac命名空间,在下文中一共展示了BehaviorNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            Sequence sequence = (Sequence)node;
            bool bOk = false;
            int childCount = sequence.GetChildrenCount();
            int i = 0;

            for (; i < childCount; ++i)
            {
                BehaviorNode childNode = sequence.GetChild(i);
                PlannerTask childTask = planner.decomposeNode(childNode, depth);

                if (childTask == null)
                {
                    break;
                }

                //clear the log cache so that the next node can log all properites
                LogManager.Instance.PLanningClearCache();
                seqTask.AddChild(childTask);
            }

            if (i == childCount)
            {
                bOk = true;
            }

            return bOk;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:29,代码来源:Sequence.cs


示例2: decompose

    public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
    {
        Parallel parallel = (Parallel)node;
        bool bOk = false;
        //parallel currently is the same with sequence
        int childCount = parallel.GetChildrenCount();
        int i = 0;

        for (; i < childCount; ++i)
        {
            BehaviorNode childNode = parallel.GetChild(i);
            PlannerTask childTask = planner.decomposeNode(childNode, depth);

            if (childTask == null)
            {
                break;
            }

            seqTask.AddChild(childTask);
        }

        if (i == childCount)
        {
            bOk = true;
        }

        return bOk;
    }
开发者ID:pjkui,项目名称:behaviac,代码行数:28,代码来源:Parallel.cs


示例3: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
            bool bOk = false;
            Debug.Check(taskSubTree != null);
            int depth2 = planner.GetAgent().Variables.Depth;
            using(AgentState currentState = planner.GetAgent().Variables.Push(false))
            {
                //planner.agent.Variables.Log(planner.agent, true);
                taskSubTree.SetTaskParams(planner.GetAgent());

                Task task = taskSubTree.RootTaskNode;

                if (task != null)
                {
                    planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
                    task.Parent.InstantiatePars(planner.GetAgent());

                    PlannerTask childTask = planner.decomposeNode(task, depth);

                    if (childTask != null)
                    {
                        seqTask.AddChild(childTask);
                        bOk = true;
                    }

                    task.Parent.UnInstantiatePars(planner.GetAgent());
                    planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
                    Debug.Check(true);
                }
            }

            Debug.Check(planner.GetAgent().Variables.Depth == depth2);
            return bOk;
        }
开发者ID:pjkui,项目名称:behaviac,代码行数:35,代码来源:Referencebehavior.cs


示例4: UpdateTransitions

        public static bool UpdateTransitions(Agent pAgent, BehaviorNode node, List<Transition> transitions, ref int nextStateId, EBTStatus result)
        {
            bool bTransitioned = false;

            if (transitions != null)
            {
                for (int i = 0; i < transitions.Count; ++i)
                {
                    Transition transition = transitions[i];

                    if (transition.Evaluate(pAgent))
                    {
                        nextStateId = transition.TargetStateId;
                        Debug.Check(nextStateId != -1);

                        //transition actions
                        transition.ApplyEffects(pAgent, Effector.EPhase.E_BOTH);

            #if !BEHAVIAC_RELEASE
                        if (Config.IsLoggingOrSocketing)
                        {
                            BehaviorTask.CHECK_BREAKPOINT(pAgent, node, "transition", EActionResult.EAR_none);
                        }
            #endif
                        bTransitioned = true;

                        break;
                    }
                }
            }

            return bTransitioned;
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:33,代码来源:State.cs


示例5: Init

        public virtual void Init(BehaviorNode node)
        {
            Debug.Check(node != null);

            this.m_node = node;
            this.m_id = this.m_node.GetId();
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:7,代码来源:BehaviorTree_task.cs


示例6: AddChild

        public override void AddChild(BehaviorNode pBehavior)
        {
            Debug.Check(pBehavior is DecoratorWeight);
            DecoratorWeight pDW = (DecoratorWeight)(pBehavior);

            if (pDW != null)
            {
                base.AddChild(pBehavior);
            }
            else
            {
                Debug.Check(false, "only DecoratorWeightTask can be children");
            }
        }
开发者ID:Oswin2014,项目名称:Behavior_Tree-Practice-in-Unity,代码行数:14,代码来源:Selectorprobability.cs


示例7: decompose

        /// <summary>
        /// implement the decompose
        /// </summary>
        /// <param name="task"></param>
        /// <param name="seqTask"></param>
        /// <param name="depth"></param>
        /// <param name="planner"></param>
        /// <returns></returns>
        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            bool bOk = false;
            Task task = (Task)node;
            PlannerTask childTask = planner.decomposeTask((Task)task, depth);

            if (childTask != null)
            {
                seqTask.AddChild(childTask);
                bOk = true;
            }

            return bOk;
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:22,代码来源:Task.cs


示例8: decompose

        public override bool decompose(BehaviorNode branch, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            bool bOk = false;
            int childCount = branch.GetChildrenCount();
            Debug.Check(childCount == 1);
            BehaviorNode childNode = branch.GetChild(0);
            PlannerTask childTask = planner.decomposeNode(childNode, depth);

            if (childTask != null)
            {
                seqTask.AddChild(childTask);
                bOk = true;
            }

            return bOk;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:16,代码来源:Method.cs


示例9: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
            bool bOk = false;
            Debug.Check(taskSubTree != null);
            int depth2 = planner.GetAgent().Variables.Depth;
            using(AgentState currentState = planner.GetAgent().Variables.Push(false))
            {
                Agent pAgent = planner.GetAgent();

                string szTreePath = taskSubTree.GetReferencedTree(pAgent);
                BehaviorTreeTask subTreeTask = Workspace.Instance.CreateBehaviorTreeTask(szTreePath);

                taskSubTree.SetTaskParams(pAgent, subTreeTask);

                Task task = taskSubTree.RootTaskNode(planner.GetAgent());

                if (task != null)
                {
                    planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
                    //task.Parent.InstantiatePars(this.LocalVars);

                    BehaviorTreeTask oldCurrentTreeTask = pAgent.ExcutingTreeTask;
                    pAgent.ExcutingTreeTask = subTreeTask; 
                    PlannerTask childTask = planner.decomposeNode(task, depth);
                    pAgent.ExcutingTreeTask = oldCurrentTreeTask;

                    if (childTask != null)
                    {
                        //taskSubTree.SetTaskParams(planner.GetAgent(), childTask);
                        PlannerTaskReference subTreeRef = (PlannerTaskReference)seqTask;

                        subTreeRef.SubTreeTask = subTreeTask;
                        seqTask.AddChild(childTask);
                        bOk = true;
                    }

                    //task.Parent.UnInstantiatePars(this.LocalVars);
                    planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
                    Debug.Check(true);
                }
            }

            Debug.Check(planner.GetAgent().Variables.Depth == depth2);
            return bOk;
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:46,代码来源:Referencebehavior.cs


示例10: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            DecoratorIterator pForEach = (DecoratorIterator)node;
            bool bOk = false;
            int childCount = pForEach.GetChildrenCount();
            Debug.Check(childCount == 1);
            BehaviorNode childNode = pForEach.GetChild(0);

            bool bGoOn = true;
            int count = 0;
            int index = 0;

            while (bGoOn)
            {
                int depth2 = planner.GetAgent().Variables.Depth;
                using(AgentState currentState = planner.GetAgent().Variables.Push(false))
                {
                    bGoOn = pForEach.IterateIt(planner.GetAgent(), index, ref count);

                    if (bGoOn)
                    {
                        planner.LogPlanForEachBegin(planner.GetAgent(), pForEach, index, count);
                        PlannerTask childTask = planner.decomposeNode(childNode, depth);
                        planner.LogPlanForEachEnd(planner.GetAgent(), pForEach, index, count, childTask != null ? "success" : "failure");

                        if (childTask != null)
                        {
                            Debug.Check(seqTask is PlannerTaskIterator);
                            PlannerTaskIterator pForEachTask = seqTask as PlannerTaskIterator;
                            pForEachTask.Index = index;

                            seqTask.AddChild(childTask);
                            bOk = true;
                            break;
                        }

                        index++;
                    }
                }

                Debug.Check(planner.GetAgent().Variables.Depth == depth2);
            }

            return bOk;
        }
开发者ID:yinlei,项目名称:behaviac,代码行数:45,代码来源:DecoratorIterator.cs


示例11: Attach

        public override void Attach(BehaviorNode pAttachment, bool bIsPrecondition, bool bIsEffector, bool bIsTransition)
        {
            if (bIsTransition)
            {
                Debug.Check(!bIsEffector && !bIsPrecondition);

                if (this.m_transitions == null)
                {
                    this.m_transitions = new List<Transition>();
                }

                Transition pTransition = pAttachment as Transition;
                Debug.Check(pTransition != null);
                this.m_transitions.Add(pTransition);

                return;
            }

            Debug.Check(bIsTransition == false);
            base.Attach(pAttachment, bIsPrecondition, bIsEffector, bIsTransition);
        }
开发者ID:XyzalZhang,项目名称:behaviac,代码行数:21,代码来源:State.cs


示例12: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            Selector sel = (Selector)node;

            bool bOk = false;
            int childCount = sel.GetChildrenCount();
            int i = 0;

            for (; i < childCount; ++i)
            {
                BehaviorNode childNode = sel.GetChild(i);
                PlannerTask childTask = planner.decomposeNode(childNode, depth);

                if (childTask != null)
                {
                    seqTask.AddChild(childTask);
                    bOk = true;
                    break;
                }
            }

            return bOk;
        }
开发者ID:XyzalZhang,项目名称:behaviac,代码行数:23,代码来源:Selector.cs


示例13: GetParentTreeName

        private static string GetParentTreeName(BehaviorNode n)
        {
            string btName = null;

            if (n is ReferencedBehavior)
            {
                n = n.Parent;
            }

            bool bIsTree = false;
            bool bIsRefTree = false;

            while (n != null)
            {
                bIsTree = (n is BehaviorTree);
                bIsRefTree = (n is ReferencedBehavior);

                if (bIsTree || bIsRefTree)
                {
                    break;
                }

                n = n.Parent;
            }

            if (bIsTree)
            {
                BehaviorTree bt = n as BehaviorTree;
                btName = bt.GetName();
            }
            else if (bIsRefTree)
            {
                ReferencedBehavior refTree = n as ReferencedBehavior;
                btName = refTree.ReferencedTree;
            }
            else
            {
                Debug.Check(false);
            }

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


示例14: GetTickInfo

        public static string GetTickInfo(Agent pAgent, BehaviorNode n, string action)
        {
            #if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                if (pAgent != null && pAgent.IsMasked())
                {
                    //BEHAVIAC_PROFILE("GetTickInfo", true);

                    string bClassName = n.GetClassNameString();

                    //filter out intermediate bt, whose class name is empty
                    if (!string.IsNullOrEmpty(bClassName))
                    {
                        string btName = GetParentTreeName(n);

                        string bpstr = "";

                        if (!string.IsNullOrEmpty(btName))
                        {
                            bpstr = string.Format("{0}.xml->", btName);
                        }

                        int nodeId = n.GetId();
                        bpstr += string.Format("{0}[{1}]", bClassName, nodeId);

                        if (!string.IsNullOrEmpty(action))
                        {
                            bpstr += string.Format(":{0}", action);
                        }

                        return bpstr;
                    }
                }
            }

            #endif
            return string.Empty;
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:40,代码来源:BehaviorTree_task.cs


示例15: Init

 //~DecoratorTask()
 //{
 //}
 public override void Init(BehaviorNode node)
 {
     base.Init(node);
     //DecoratorNode pDN = node as DecoratorNode;
 }
开发者ID:wuzhen,项目名称:behaviac,代码行数:8,代码来源:BehaviorTree_task.cs


示例16: decomposeNode

        public PlannerTask decomposeNode(BehaviorNode node, int depth)
        {
            try
            {
                // Ensure that the planner does not get stuck in an infinite loop
                if (depth >= 256)
                {
                    Debug.LogError("Exceeded task nesting depth. Does the graph contain an invalid cycle?");
                    return null;
                }

                LogPlanNodeBegin(this.agent, node);

                int depth1 = this.agent.Variables.Depth;
                PlannerTask taskAdded = null;

                bool isPreconditionOk = node.CheckPreconditions(this.agent, false);

                if (isPreconditionOk)
                {
                    bool bOk = true;
                    taskAdded = PlannerTask.Create(node, this.agent);

                    if (node is Action)
                    {
                        //nothing to do for action
                        Debug.Check(true);
                    }
                    else
                    {
                        Debug.Check(taskAdded is PlannerTaskComplex);
                        PlannerTaskComplex seqTask = taskAdded as PlannerTaskComplex;

                        bOk = this.decomposeComplex(node, seqTask, depth);
                    }

                    if (bOk)
                    {
                        node.ApplyEffects(this.agent, Effector.EPhase.E_SUCCESS);
                    }
                    else
                    {
                        BehaviorTask.DestroyTask(taskAdded);
                        taskAdded = null;
                    }
                }
                else
                {
                    //precondition failed
                    LogPlanNodePreconditionFailed(this.agent, node);
                }

                LogPlanNodeEnd(this.agent, node, taskAdded != null ? "success" : "failure");

                Debug.Check(this.agent.Variables.Depth == depth1);

                return taskAdded;
            }
            catch (Exception ex)
            {
                Debug.Check(false, ex.Message);
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:65,代码来源:Planner.cs


示例17: CHECK_BREAKPOINT

        //CheckBreakpoint should be after log of onenter/onexit/update, as it needs to flush msg to the client
        public static void CHECK_BREAKPOINT(Agent pAgent, BehaviorNode b, string action, EActionResult actionResult)
        {
            #if !BEHAVIAC_RELEASE

            if (Config.IsLoggingOrSocketing)
            {
                string bpstr = GetTickInfo(pAgent, b, action);

                if (!string.IsNullOrEmpty(bpstr))
                {
                    LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_tick);

                    if (Workspace.Instance.CheckBreakpoint(pAgent, b, action, actionResult))
                    {
                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_breaked);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();

                        _MY_BREAKPOINT_BREAK_(pAgent, bpstr, actionResult);

                        LogManager.Instance.Log(pAgent, bpstr, actionResult, LogMode.ELM_continue);
                        LogManager.Instance.Flush(pAgent);
                        SocketUtils.Flush();
                    }
                }
            }

            #endif
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:30,代码来源:BehaviorTree_task.cs


示例18: SetCustomCondition

 public void SetCustomCondition(BehaviorNode node)
 {
     this.m_customCondition = node;
 }
开发者ID:githubNil,项目名称:behaviac,代码行数:4,代码来源:BehaviorTree.cs


示例19: decompose

 public virtual bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
 {
     Debug.Check(false, "Can't step into this line");
     return false;
 }
开发者ID:githubNil,项目名称:behaviac,代码行数:5,代码来源:BehaviorTree.cs


示例20: decompose

        public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
        {
            Debug.Check(false);

            return false;
        }
开发者ID:XyzalZhang,项目名称:behaviac,代码行数:6,代码来源:FSM.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# behaviac.BehaviorTask类代码示例发布时间:2022-05-26
下一篇:
C# net.BaseSocket类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap