//--------------------------------------------------------------------- // randomly executes the behavior // <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 DecoratorRandom(BehaviorTree bt, float probability, Func<float> func_random, BehaviorComponent behavior) : base(bt) { mProbability = probability; mRandomFunction = func_random; mBehavior = behavior; }
//--------------------------------------------------------------------- // executes the behavior after a given amount of time in miliseconds has passed // <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 DecoratorTimer(BehaviorTree bt, Func <int> func_elapsedtm, int wait_tm, BehaviorComponent behavior) : base(bt) { mFuncElapsedTm = func_elapsedtm; mBehavior = behavior; mWaitTime = wait_tm; }
//--------------------------------------------------------------------- // randomly executes the behavior // <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 DecoratorRandom(BehaviorTree bt, float probability, Func <float> func_random, BehaviorComponent behavior) : base(bt) { mProbability = probability; mRandomFunction = func_random; mBehavior = behavior; }
//--------------------------------------------------------------------- // executes the behavior after a given amount of time in miliseconds has passed // <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 DecoratorTimer(BehaviorTree bt, Func<int> func_elapsedtm, int wait_tm, BehaviorComponent behavior) : base(bt) { mFuncElapsedTm = func_elapsedtm; mBehavior = behavior; mWaitTime = wait_tm; }
//--------------------------------------------------------------------- // 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 public DecoratorCounter(BehaviorTree bt, int max_count, BehaviorComponent behavior) : base(bt) { mMaxCount = max_count; mBehavior = behavior; }
//--------------------------------------------------------------------- // inverts the given behavior // -Returns Success on Failure or Error // -Returns Failure on Success // -Returns Running on Running public DecoratorInverter(BehaviorTree bt, BehaviorComponent behavior) : base(bt) { mBehavior = behavior; }
//--------------------------------------------------------------------- public void setRoot(BehaviorComponent behavior) { RootSelector root = new RootSelector(this, delegate() { return(0); }, behavior); mRoot = root; }
//--------------------------------------------------------------------- public void setRoot(BehaviorComponent behavior) { RootSelector root = new RootSelector(this, delegate() { return 0; }, behavior); mRoot = root; }