Example #1
0
 //---------------------------------------------------------------------
 public override BehaviorReturnCode Behave()
 {
     try
     {
         if (mRandomFunction.Invoke() <= mProbability)
         {
             ReturnCode = mBehavior.Behave();
             return(ReturnCode);
         }
         else
         {
             ReturnCode = BehaviorReturnCode.Running;
             return(BehaviorReturnCode.Running);
         }
     }
     catch (Exception e)
     {
         ReturnCode = BehaviorReturnCode.Failure;
         return(BehaviorReturnCode.Failure);
     }
 }
Example #2
0
 //---------------------------------------------------------------------
 public override BehaviorReturnCode Behave()
 {
     try
     {
         if (mCounter < mMaxCount)
         {
             mCounter++;
             ReturnCode = BehaviorReturnCode.Running;
             return(BehaviorReturnCode.Running);
         }
         else
         {
             mCounter   = 0;
             ReturnCode = mBehavior.Behave();
             return(ReturnCode);
         }
     }
     catch (Exception e)
     {
         ReturnCode = BehaviorReturnCode.Failure;
         return(BehaviorReturnCode.Failure);
     }
 }
Example #3
0
        //---------------------------------------------------------------------
        public override BehaviorReturnCode Behave()
        {
            try
            {
                mTimeElapsed += mFuncElapsedTm.Invoke();

                if (mTimeElapsed >= mWaitTime)
                {
                    mTimeElapsed = 0;
                    ReturnCode   = mBehavior.Behave();
                    return(ReturnCode);
                }
                else
                {
                    ReturnCode = BehaviorReturnCode.Running;
                    return(BehaviorReturnCode.Running);
                }
            }
            catch (Exception e)
            {
                ReturnCode = BehaviorReturnCode.Failure;
                return(BehaviorReturnCode.Failure);
            }
        }