public ChanceRunning(float probability, Func <float> randomFunction, BehaviorComponent behavior)
 {
     this.probability    = probability;
     this.randomFunction = randomFunction;
     AssignBehaviors(new[] { behavior });
     Name = "ChanceRunning";
 }
예제 #2
0
 public void Init(BehaviorComponent root)
 {
     Root                = root;
     History             = new List <BehaviorComponent>();
     AlterableComponents = new Dictionary <string, Alterable>();
     SetupHistoryCallBackAndAlterable(Root);
 }
예제 #3
0
 public BehaviorTree(BehaviorComponent root)
 {
     _Root = root;
     _Root.behaviorTree = this;
     m_blackboardData   = new UBlackboardData();
     m_inputParam       = new InsParam();
 }
예제 #4
0
        public BehaviorTree(BehaviorComponent root)
        {
			_Root = root;
            _Root.behaviorTree = this;
            m_blackboardData = new UBlackboardData();
            m_inputParam = new InsParam();
		}
예제 #5
0
        protected List <BehaviorComponent> m_childBehaviorsList;     // 孩子节点

        // 添加子节点
        public override void addChild(BehaviorComponent child)
        {
            if (m_childBehaviorsList == null)
            {
                m_childBehaviorsList = new List <BehaviorComponent>();
            }

            m_childBehaviorsList.Add(child);
        }
예제 #6
0
        protected List<BehaviorComponent> m_childBehaviorsList;     // 孩子节点

        // 添加子节点
        public override void addChild(BehaviorComponent child)
        {
            if(m_childBehaviorsList == null)
            {
                m_childBehaviorsList = new List<BehaviorComponent>();
            }

            m_childBehaviorsList.Add(child);
        }
예제 #7
0
        public void OnCalled(BehaviorComponent called, BehaviorReturnCode result)
        {
            this.AddToCalled(called);

            // Check if we just called the root node, so are done with the tree.
            if (!this.isInvokingFinalizer && this.calling.Count > 0 && this.calling[0] == called)
            {
                this.ProcessFinalizers(this.calling[0]);
            }
        }
예제 #8
0
 public void buildComp(string type, BehaviorComponent comp, SecurityElement xmlElem)
 {
     if (string.IsNullOrEmpty(type))
     {
         buildDefault(comp, xmlElem);
     }
     else
     {
         m_id2BuildDic[type](comp, xmlElem);
     }
 }
예제 #9
0
 public void buildComp(string type, BehaviorComponent comp, SecurityElement xmlElem)
 {
     if (string.IsNullOrEmpty(type))
     {
         buildDefault(comp, xmlElem);
     }
     else
     {
         m_id2BuildDic[type](comp, xmlElem);
     }
 }
예제 #10
0
 public Alterable(BehaviorComponent behavior, string id)
 {
     Name = "Atlerable";
     ID   = id;
     if (behavior is Alterable)
     {
         Debug.LogError("Cannot have Alterable BehaviorComponent child of Alterable");
         return;
     }
     AssignBehaviors(new[] { behavior });
 }
예제 #11
0
        public BehaviorComponent UpdateBehaviors(BehaviorComponent behavior)
        {
            if (behavior is Alterable)
            {
                Debug.LogError("Cannot have Alterable Decorator as Child of Alterable");
                return(this);
            }
#if UNITY_EDITOR
            behaviors = new[] { (BehaviorComponent)behavior.Clone() };
#else
            behaviors = new[] { behavior };
#endif
            //BehaviorTree.RefreshBehaviorTree();
            return(this);
        }
예제 #12
0
 private void ProcessFinalizers(BehaviorComponent rootNode)
 {
     if (this.OldContext == null)
     {
         return;
     }
     foreach (var onNotCalledBehavior in this.OldContext.onNotCalledBehaviors)
     {
         if (!this.HasBeenCalled(onNotCalledBehavior))
         {
             this.isInvokingFinalizer = true;
             onNotCalledBehavior.InvokeFinalizer(this);
             this.isInvokingFinalizer = false;
         }
     }
 }
예제 #13
0
 public void SetupHistoryCallBackAndAlterable(BehaviorComponent behaviorComponent)
 {
     behaviorComponent.AddToHistory = AddToHistory;
     if (behaviorComponent is Alterable)
     {
         Alterable alterable = (Alterable)behaviorComponent;
         alterable.BehaviorTree = this;
         AlterableComponents.Add(alterable.ID, alterable);
     }
     if (behaviorComponent.Behaviors != null)
     {
         for (int i = 0; i < behaviorComponent.Behaviors.Length; i++)
         {
             BehaviorComponent behavior = behaviorComponent.Behaviors[i];
             behavior.AddToHistory = AddToHistory;
             if (behavior.Behaviors != null)
             {
                 SetupHistoryCallBackAndAlterable(behavior);
             }
         }
     }
 }
예제 #14
0
        protected void depthTraverse(Stack<BehaviorComponent> stack, BehaviorComponent parentNode, SecurityElement btNode)
        {
            ArrayList btCmtNodeList = btNode.Children;
            BehaviorComponent btCmt;
            string type = "";

            if (btCmtNodeList != null)
            {
                stack.Push(parentNode);
                foreach (SecurityElement node in btCmtNodeList)
                {
                    if (m_id2CreateDic.ContainsKey(node.Tag))
                    {
                        UtilXml.getXmlAttrStr(node, "type", ref type);
                        btCmt = m_id2CreateDic[node.Tag].createComp(type);
                        btCmt.behaviorTree = parentNode.behaviorTree;
                        parentNode.addChild(btCmt);
                        m_id2CreateDic[node.Tag].buildComp(type, btCmt, node);
                        depthTraverse(stack, btCmt, node);
                    }
                }
                stack.Pop();
            }
        }
예제 #15
0
        protected void depthTraverse(Stack <BehaviorComponent> stack, BehaviorComponent parentNode, SecurityElement btNode)
        {
            ArrayList         btCmtNodeList = btNode.Children;
            BehaviorComponent btCmt;
            string            type = "";

            if (btCmtNodeList != null)
            {
                stack.Push(parentNode);
                foreach (SecurityElement node in btCmtNodeList)
                {
                    if (m_id2CreateDic.ContainsKey(node.Tag))
                    {
                        UtilXml.getXmlAttrStr(node, "type", ref type);
                        btCmt = m_id2CreateDic[node.Tag].createComp(type);
                        btCmt.behaviorTree = parentNode.behaviorTree;
                        parentNode.addChild(btCmt);
                        m_id2CreateDic[node.Tag].buildComp(type, btCmt, node);
                        depthTraverse(stack, btCmt, node);
                    }
                }
                stack.Pop();
            }
        }
예제 #16
0
 public override void addChild(BehaviorComponent child)
 {
     base.addChild(child);
     _selLength = (short)m_childBehaviorsList.Count;
 }
예제 #17
0
 /// <summary>
 /// executes the behavior after a given amount of time in miliseconds has passed
 /// </summary>
 /// <param name="elapsedTimeFunction">function that returns elapsed time</param>
 /// <param name="timeToWait">maximum time to wait before executing behavior</param>
 /// <param name="behavior">behavior to run</param>
 public Timer(Func<int> elapsedTimeFunction, int timeToWait, BehaviorComponent behavior)
 {
     _ElapsedTimeFunction = elapsedTimeFunction;
     m_childBehavior = behavior;
     _WaitTime = timeToWait;
 }
예제 #18
0
 public void buildActionFollow(BehaviorComponent btCmt, SecurityElement btNode)
 {
 }
예제 #19
0
        public void buildActionFollow(BehaviorComponent btCmt, SecurityElement btNode)
        {

        }
예제 #20
0
 public void buildActionWander(BehaviorComponent btCmt, SecurityElement btNode)
 {
 }
예제 #21
0
 public override void addChild(BehaviorComponent child)
 {
     base.addChild(child);
     _selLength = (short)m_childBehaviorsList.Count;
 }
예제 #22
0
 virtual protected void buildDefault(BehaviorComponent comp, SecurityElement xmlElem)
 {
     
 }
예제 #23
0
        public void buildConditionIdle(BehaviorComponent btCmt, SecurityElement btNode)
        {

        }
예제 #24
0
 /// <summary>
 /// executes the behavior every time again
 /// </summary>
 /// <param name="timeToWait">maximum time to wait before executing behavior</param>
 /// <param name="behavior">behavior to run</param>
 public RepeatUntilFail(BehaviorComponent behavior)
 {
     m_childBehavior = behavior;
 }
예제 #25
0
        public UtilityPair(UtilityVector vector, BehaviorComponent behavior)
        {
			this.vector = vector;
			this.behavior = behavior;
        }
예제 #26
0
 virtual protected void buildDefault(BehaviorComponent comp, SecurityElement xmlElem)
 {
 }
예제 #27
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="root"></param>
 public BehaviorTree(IndexSelector root)
 {
     _Root = root;
     m_inputParam = new InsParam();
     m_blackboardData = new UBlackboardData();
 }
예제 #28
0
 public BehaviorNode(BehaviorComponent behaviorComponent, Vector2 position)
 {
     BehaviorComponent      = behaviorComponent;
     Position               = position;
     BehaviorComponent.Node = this;
 }
예제 #29
0
 public void buildActionAttackAll(BehaviorComponent btCmt, SecurityElement btNode)
 {
 }
예제 #30
0
        // 添加子节点
        public virtual void addChild(BehaviorComponent child)
        {

        }
예제 #31
0
 override protected void buildDefault(BehaviorComponent btCmt, SecurityElement btNode)
 {
 }
예제 #32
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="root"></param>
 public BehaviorTree(IndexSelector root)
 {
     _Root            = root;
     m_inputParam     = new InsParam();
     m_blackboardData = new UBlackboardData();
 }
예제 #33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="root"></param>
 public Behavior(IndexSelector root)
 {
     _Root = root;
 }
예제 #34
0
        public void buildActionWander(BehaviorComponent btCmt, SecurityElement btNode)
        {

        }
예제 #35
0
 /// <summary>
 /// returns a success even when the decorated component failed
 /// </summary>
 /// <param name="behavior">behavior to run</param>
 public Succeeder(BehaviorComponent behavior)
 {
     m_childBehavior = behavior;
 }
예제 #36
0
        public void buildActionAttackAll(BehaviorComponent btCmt, SecurityElement btNode)
        {

        }
예제 #37
0
 /// <summary>
 /// randomly executes the behavior
 /// </summary>
 /// <param name="probability">probability of execution</param>
 /// <param name="randomFunction">function that determines probability to execute</param>
 /// <param name="behavior">behavior to execute</param>
 public RandomDecorator(float probability, Func <float> randomFunction, BehaviorComponent behavior)
 {
     _Probability    = probability;
     _RandomFunction = randomFunction;
     m_childBehavior = behavior;
 }
예제 #38
0
 public BehaviorTree(BehaviorComponent root)
 {
     Init(root);
 }
예제 #39
0
 /// <summary>
 /// executes the behavior based on a counter
 /// -each time Counter is called the counter increments by 1
 /// -Counter executes the behavior when it reaches the supplied maxCount
 /// </summary>
 /// <param name="maxCount">max number to count to</param>
 /// <param name="behavior">behavior to run</param>
 public Counter(int maxCount, BehaviorComponent behavior)
 {
     _MaxCount = maxCount;
     m_childBehavior = behavior;
 }
예제 #40
0
 // TODO: consider moving these into a Behavior.Editor history object
 private void AddToHistory(BehaviorComponent behaviorComponent)
 {
     History.Add(behaviorComponent);
 }
예제 #41
0
 private void AddToCalled(BehaviorComponent behavior)
 {
     this.called.Add(behavior);
 }
예제 #42
0
 public Timer(float timeToWait, BehaviorComponent behavior)
 {
     AssignBehaviors(new[] { behavior });
     waitTime = timeToWait;
     Name     = "Timer";
 }
예제 #43
0
 public bool HasBeenCalled(BehaviorComponent behavior)
 {
     return(this.called.Contains(behavior));
 }
예제 #44
0
        override protected void buildDefault(BehaviorComponent btCmt, SecurityElement btNode)
        {

        }
예제 #45
0
 public bool IsCalling(BehaviorComponent behavior)
 {
     return(this.calling.Contains(behavior));
 }
예제 #46
0
 public void buildConditionIdle(BehaviorComponent btCmt, SecurityElement btNode)
 {
 }
예제 #47
0
 public void OnAboutToCall(BehaviorComponent caller)
 {
     this.AddToCalling(caller);
     this.callCount++;
 }
예제 #48
0
 public Behavior(BehaviorComponent root)
 {
     _Root = root;
 }
예제 #49
0
 /// <summary>
 /// executes the behavior every time again
 /// </summary>
 /// <param name="timeToWait">maximum time to wait before executing behavior</param>
 /// <param name="behavior">behavior to run</param>
 public Repeater(BehaviorComponent behavior)
 {
     m_childBehavior = behavior;
 }