Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 public void Init(float seconds, float randomVariance)
 {
     this.WaitSeconds    = seconds;
     this.randomVariance = randomVariance;
     OnStarted.AddListener(OnStarted_Listener);
     OnStartedSilent.AddListener(OnStartedSilent_Listener);
     OnStopping.AddListener(OnStopping_Listener);
     OnStoppingSilent.AddListener(OnStoppingSilent_Listener);
 }
Ejemplo n.º 3
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);
 }
        /// <summary>
        /// Remove all BehaviourNode related Event listeners
        /// </summary>
        public void RemoveAllListeners()
        {
            OnStarted.RemoveAllListeners();
            OnStartedSilent.RemoveAllListeners();

            OnStopping.RemoveAllListeners();
            OnStoppingSilent.RemoveAllListeners();

            OnStopped.RemoveAllListeners();
            OnStoppedSilent.RemoveAllListeners();
        }
 /// <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);
 }
 /// <summary>
 /// Initiates the stopping process
 /// </summary>
 /// <returns>If it successfully initiated the stopping process</returns>
 public bool RequestStopNode(bool silent = false)
 {
     if (this.State == NodeState.ACTIVE)
     {
         this.State = NodeState.STOPPING;
         if (!silent)
         {
             OnStopping.Invoke();
         }
         else
         {
             OnStoppingSilent.Invoke();
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
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;
        }