示例#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);
     }
 }
示例#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);
     }
 }
示例#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);
            }
        }