コード例 #1
0
 /// <summary>
 /// Runs the child node with the given probability chance between 0 and 1
 /// </summary>
 /// <param name="probability">Between 0 and 1</param>
 public BehaviourRandom(float probability) : base("Random", NodeType.DECORATOR)
 {
     m_probability = probability;
     OnStarted.AddListener(OnStarted_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
コード例 #2
0
 /// <summary>
 /// Overrides the child node's result
 /// </summary>
 /// <param name="result">The result to override the child node's result</param>
 public BehaviourResultOverrider(bool result) : base("ResultOverrider", NodeType.DECORATOR)
 {
     m_result = result;
     OnStarted.AddListener(OnStarted_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
コード例 #3
0
 /// <summary>
 /// Inverts the child node result.
 /// </summary>
 /// <param name="child">The child node</param>
 public BehaviourInverter(BehaviourNode child) : base("Inverter", NodeType.DECORATOR)
 {
     AddChild(child);
     OnStarted.AddListener(OnStarted_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
コード例 #4
0
 public BehaviourSequenceSelectBase(string name, bool isRandom) : base(name, NodeType.COMPOSITE)
 {
     IsRandom = isRandom;
     OnStarted.AddListener(OnStarted_Listener);
     OnStartedSilent.AddListener(OnStartedSilent_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
コード例 #5
0
 /// <summary>
 /// The root node of a tree
 /// </summary>
 /// <param name="name"></param>
 public BehaviourRootNode(string name = "Root") : base(name, NodeType.DECORATOR)
 {
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
     OnStarted.AddListener(OnStarted_Listener);
     OnStartedSilent.AddListener(OnStartedSilent_Listener);
 }
コード例 #6
0
 public BehaviourRepeatUntil(Func <bool> isConditionMetFunc) : base(NODE_NAME, NodeType.DECORATOR)
 {
     m_isConditionMetFunc = isConditionMetFunc;
     OnStarted.AddListener(OnStarted_Listener);
     OnStartedSilent.AddListener(OnStartedSilent_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
     OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);
 }
コード例 #7
0
        /// <summary>
        /// Run child nodes in parallel
        /// </summary>
        /// <param name="successStopCondition">
        /// How many children should return success before parallel stops with success
        /// </param>
        /// <param name="failureStopCondition">
        /// How many children should return failure before parallel stops with failure
        /// </param>
        public BehaviourParallel(StopCondition successStopCondition, StopCondition failureStopCondition) : base("Parallel", NodeType.COMPOSITE)
        {
            m_successStopCondition = successStopCondition;
            m_failureStopCondition = failureStopCondition;

            OnStarted.AddListener(OnStarted_Listener);
            OnStartedSilent.AddListener(OnStartedSilent_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);
        }
コード例 #8
0
 /// <summary>
 /// Repeated runs it's child node
 /// </summary>
 /// <param name="totalLoops">The amount of times the child node is looped. If -1 it will loop indefinately unless stopped manually.</param>
 public BehaviourRepeater(int totalLoops = -1, bool stopOnChildFail = true) : base(NODE_NAME, NodeType.DECORATOR)
 {
     TotalLoops      = totalLoops;
     StopOnChildFail = stopOnChildFail;
     OnStarted.AddListener(OnStarted_Listener);
     OnStartedSilent.AddListener(OnStartedSilent_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
     OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);
 }
コード例 #9
0
        //private bool m_initParent = false;
        public BehaviourObserver(string name, BehaviourNode decoratee, AbortRule abortRule) : base(name, NodeType.DECORATOR)
        {
            OnStarted.AddListener(OnStarted_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);

            m_abortRule   = abortRule;
            m_isObserving = false;
            AddChild(decoratee);
        }
コード例 #10
0
        private void Init(System.Action serviceAction)
        {
            OnStarted.AddListener(OnStarted_Listener);
            OnStartedSilent.AddListener(OnStartedSilent_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);
            m_serviceAction = serviceAction;
#if UNITY_EDITOR
            DebugTools.GUIlabel = "every tick";
#endif
        }
コード例 #11
0
 public BehaviourStateSelector(T initialState) : base("Enum Selector", NodeType.COMPOSITE)
 {
     NextState     = initialState;
     CurrentState  = initialState;
     States        = Enum.GetValues(typeof(T));
     _stateActions = new Dictionary <T, BehaviourAction>();
     if (States.Length < 1)
     {
         throw new ArgumentException("Enum provided to Initialize must have at least 1 visible definition");
     }
     OnStarted.AddListener(OnStarted_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
コード例 #12
0
        /// <summary>
        /// Delay execution of the child node until the condition is true
        /// </summary>
        /// <param name="isConditionMetFunc">The function used to check the condition</param>
        /// <param name="checkInterval">The interval at which the condition is checked</param>
        /// <param name="randomVariance">The interval variance</param>
        public BehaviourWaitForCondition(Func <bool> isConditionMetFunc, float checkInterval, float randomVariance) : base("WaitForCondition", NodeType.DECORATOR)
        {
            OnStarted.AddListener(OnStarted_Listener);

            OnStopping.AddListener(OnStopping_Listener);
            OnStoppedSilent.AddListener(OnStoppedSilent_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);

            m_isConditionMetFunc = isConditionMetFunc;

            m_checkInterval = checkInterval;
            m_checkVariance = randomVariance;


            // this.Label = "" + (checkInterval - randomVariance) + "..." + (checkInterval + randomVariance) + "s";
        }
コード例 #13
0
        private void Init(float limit, float?randomVariation = null, bool waitOnFailure = false)
        {
            OnStarted.AddListener(OnStarted_Listener);
            OnStartedSilent.AddListener(OnStartedSilent_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);

            m_limit = limit;
            if (randomVariation != null)
            {
                m_randomVariation = randomVariation.Value;
            }
            else
            {
                m_randomVariation = limit * 0.05f;
            }
            m_waitOnFailure = waitOnFailure;
        }
コード例 #14
0
        private void Init(float cooldownTime, float?randomVariation = null, bool startAfterChild = false, bool resetOnFailiure = false, bool failOnCooldown = false)
        {
            OnStarted.AddListener(OnStarted_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);

            m_startAfterChild = false;
            m_cooldownTime    = cooldownTime;
            m_resetOnFailiure = false;
            if (randomVariation != null)
            {
                m_randomVariation = randomVariation.Value;
            }
            else
            {
                m_randomVariation = cooldownTime * 0.1f;
            }
        }
コード例 #15
0
        private void Init(float limit, float?randomVariation, bool waitForChildButFailOnLimitReached)
        {
            OnStarted.AddListener(OnStarted_Listener);
            OnStartedSilent.AddListener(OnStartedSilent_Listener);
            OnStopping.AddListener(OnStopping_Listener);
            OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
            OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener);

            m_limit = limit;
            if (randomVariation != null)
            {
                m_randomVariation = randomVariation.Value;
            }
            else
            {
                m_randomVariation = m_limit * 0.05f;
            }
            m_waitForChildButFailOnLimitReached = waitForChildButFailOnLimitReached;
        }