Example #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);
 }
Example #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);
 }
Example #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>
 /// 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);
 }
Example #5
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;
        }
Example #6
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;
            }
        }
Example #7
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;
        }