public void BindBehaviour(YuAIBehaviorBase behaviour)
 {
     BindingBehaviour        = behaviour;
     NodeType                = behaviour.BehaviourDes;
     CurState                = behaviour.CurState;
     behaviour.OnStateChange = SetState;
 }
        /// <summary>
        /// 移除一个指定的子行为
        /// </summary>
        /// <param name="child"></param>
        public void RemoveChild(YuAIBehaviorBase child)
        {
            if (childendBehaviors.Contains(child))
            {
                childendBehaviors.Remove(child);
            }
            else
            {
#if UNITY_EDITOR
                Debug.LogError("错误,无法删除复合行为子行为,因为无法找到此行为:" +
                               child.GetType());
#endif
            }
        }
Exemple #3
0
        /// <summary>
        /// 结束行为创建
        /// </summary>
        /// <returns></returns>
        public YuAIBehaviorTree End()
        {
            while (behaviorNodes.Count > 0)
            {
                behaviorNodes.Pop();
            }
            YuAIBehaviorTree tree = new YuAIBehaviorTree(rootBehavior);

            //初始化行为树创建器
            unitEntity   = null;
            rootBehavior = null;

            return(tree);
        }
Exemple #4
0
        public void BindBehaviourTree(YuAIBehaviorBase rootTreeBehaviour, BehaviorTreeBaseNode BehaviourNode)
        {
            var currentBehaviour  = rootTreeBehaviour;
            var childrenBehaviour = currentBehaviour.GetChildren();

            if (childrenBehaviour != null)
            {
                foreach (var child in childrenBehaviour)
                {
                    var childNode = new BehaviorTreeBaseNode();
                    BindBehaviourTree(child, childNode);
                    childNode.BindBehaviour(child);
                    BehaviourNode.childNodes.Add(childNode);
                }
            }
        }
Exemple #5
0
            new Stack <YuAIBehaviorBase>();    //行为栈

        //添加一个行为到栈
        private void AddBehavior(YuAIBehaviorBase behavior)
        {
            if (unitEntity == null)
            {
#if UNITY_EDITOR
                Debug.LogError("错误:未设置AI主体");
#endif
            }

            if (rootBehavior == null)
            {
                rootBehavior = behavior;
            }
            else
            {
                //栈顶的行为,尝试添加新行为为子子行为
                behaviorNodes.Peek().AddChild(behavior);
            }

            behaviorNodes.Push(behavior);
        }
        public override void AddChild(YuAIBehaviorBase child)
        {
#if UNITY_EDITOR
            Debug.LogWarning("这是一个AI动作,不具备子节点:YuAIActionPatrol");
#endif
        }
 /// <summary>
 /// 如果此行为是保护子行为的,则添加一个子行为
 /// (只能有一个子行为,则覆盖)
 /// </summary>
 /// <param name="child"></param>
 public abstract void AddChild(YuAIBehaviorBase child);
 public override void AddChild(YuAIBehaviorBase child)
 {
     childendBehaviors.Add(child);
 }
Exemple #9
0
 public override void AddChild(YuAIBehaviorBase child)
 {
 }
 public override void Release()
 {
     child.Release();
     child = null;
 }
 public override void AddChild(YuAIBehaviorBase child)
 {
     this.child = child;
 }