예제 #1
0
 public override void SimulateOwner()
 {
     Think();
     behavior.Behave(Character);
     state.Direction = Character.Body.Direction;
     state.Velocity  = Character.Body.Velocity;
 }
예제 #2
0
    /// <summary>
    /// performs the given behavior
    /// </summary>
    /// <returns>the behaviors return code</returns>
    public BehaviorReturnCode Behave(Entity entity)
    {
        try
        {
            switch (_Behavior.Behave(entity))
            {
            case BehaviorReturnCode.Failure:
                ReturnCode = BehaviorReturnCode.Success;
                return(ReturnCode);

            case BehaviorReturnCode.Success:
                ReturnCode = BehaviorReturnCode.Failure;
                return(ReturnCode);

            case BehaviorReturnCode.Running:
                ReturnCode = BehaviorReturnCode.Running;
                return(ReturnCode);
            }
        }
        catch (Exception e)
        {
            Debug.Log("oopsie..." + e.ToString());

            ReturnCode = BehaviorReturnCode.Success;
            return(ReturnCode);
        }

        ReturnCode = BehaviorReturnCode.Success;
        return(ReturnCode);
    }
예제 #3
0
    /// <summary>
    /// performs the given behavior
    /// </summary>
    /// <returns>the behaviors return code</returns>
    public BehaviorReturnCode Behave(Entity entity)
    {
        try
        {
            _TimeElapsed += _ElapsedTimeFunction();

            if (_TimeElapsed >= _WaitTime)
            {
                _TimeElapsed = 0;
                ReturnCode   = _Behavior.Behave(entity);
                return(ReturnCode);
            }
            else
            {
                ReturnCode = BehaviorReturnCode.Running;
                return(BehaviorReturnCode.Running);
            }
        }
        catch (Exception e)
        {
            Debug.Log("oopsie..." + e.ToString());

            ReturnCode = BehaviorReturnCode.Failure;
            return(BehaviorReturnCode.Failure);
        }
    }
예제 #4
0
        /// <summary>
        /// performs the given behavior
        /// </summary>
        /// <returns>the behaviors return code</returns>
        public BehaviorReturnCode Behave(Entity entity)
        {
            try
            {
                if (_counter < _max_count)
                {
                    _counter++;
                    ReturnCode = BehaviorReturnCode.Running;
                    return(BehaviorReturnCode.Running);
                }
                else
                {
                    _counter   = 0;
                    ReturnCode = _behavior.Behave(entity);
                    return(ReturnCode);
                }
            }
            catch (Exception e)
            {
                Debug.Log("oopsie..." + e.ToString());

                ReturnCode = BehaviorReturnCode.Failure;
                return(BehaviorReturnCode.Failure);
            }
        }
예제 #5
0
 /// <summary>
 /// performs the given behavior
 /// </summary>
 /// <returns>the behaviors return code</returns>
 public BehaviorReturnCode Behave(Entity entity)
 {
     ReturnCode = _Behavior.Behave(entity);
     if (ReturnCode == BehaviorReturnCode.Failure)
     {
         ReturnCode = BehaviorReturnCode.Success;
     }
     return(ReturnCode);
 }
예제 #6
0
 /// <summary>
 /// performs the given behavior
 /// </summary>
 /// <returns>the behaviors return code</returns>
 public BehaviorReturnCode Behave(Entity entity)
 {
     ReturnCode = _Behavior.Behave(entity);
     if (ReturnCode == BehaviorReturnCode.Failure)
     {
         return(BehaviorReturnCode.Failure);
     }
     else
     {
         ReturnCode = BehaviorReturnCode.Running;
         return(BehaviorReturnCode.Running);
     }
 }
예제 #7
0
        public void EndWithLateBound_Behavior_ShouldBehaveLateBound()
        {
            IBehavior <ICustomExtension> interceptedBehavior = null;
            var extension = new Mock <IExecutable <ICustomExtension> >();
            var behavior  = new Mock <IBehavior <ICustomExtension> >();

            this.SetupCreateActionExecutableReturnsExecutable(extension.Object);
            extension.Setup(e => e.Add(It.IsAny <IBehavior <ICustomExtension> >())).Callback <IBehavior <ICustomExtension> >(b => interceptedBehavior = b);

            this.testee.Begin.End.With(() => behavior.Object);

            interceptedBehavior.Behave(Enumerable.Empty <ICustomExtension>());

            behavior.Verify(b => b.Behave(Enumerable.Empty <ICustomExtension>()));
        }
예제 #8
0
        public void EndWithLateBound_Behavior_ShouldBehaveLateBound()
        {
            IBehavior <ICustomExtension> interceptedBehavior = null;
            var extension = A.Fake <IExecutable <ICustomExtension> >();
            var behavior  = A.Fake <IBehavior <ICustomExtension> >();

            this.SetupCreateActionExecutableReturnsExecutable(extension);
            A.CallTo(() => extension.Add(A <IBehavior <ICustomExtension> > ._)).Invokes((IBehavior <ICustomExtension> b) => interceptedBehavior = b);

            this.testee.Begin.End.With(() => behavior);

            interceptedBehavior.Behave(Enumerable.Empty <ICustomExtension>());

            A.CallTo(() => behavior.Behave(Enumerable.Empty <ICustomExtension>())).MustHaveHappened();
        }
예제 #9
0
        public void WithLateBoundAfterExecuteWithActionOnExtension_Behavior_ShouldBehaveLateBound()
        {
            IBehavior <ICustomExtension> interceptedBehavior = null;
            var extension = new Mock <IExecutable <ICustomExtension> >();
            var behavior  = new Mock <IBehavior <ICustomExtension> >();

            this.executableFactory.Setup(f => f.CreateExecutable(It.IsAny <Expression <Action <ICustomExtension> > >())).Returns(extension.Object);
            extension.Setup(e => e.Add(It.IsAny <IBehavior <ICustomExtension> >())).Callback <IBehavior <ICustomExtension> >(b => interceptedBehavior = b);

            this.testee
            .Execute(e => e.Dispose())
            .With(() => behavior.Object);

            interceptedBehavior.Behave(Enumerable.Empty <ICustomExtension>());

            behavior.Verify(b => b.Behave(Enumerable.Empty <ICustomExtension>()));
        }
예제 #10
0
        public void WithLateBoundAfterExecuteWithActionOnExtension_Behavior_ShouldBehaveLateBound()
        {
            IBehavior <ICustomExtension> interceptedBehavior = null;
            var extension = A.Fake <IExecutable <ICustomExtension> >();
            var behavior  = A.Fake <IBehavior <ICustomExtension> >();

            A.CallTo(() => this.executableFactory.CreateExecutable(A <Expression <Action <ICustomExtension> > > ._)).Returns(extension);
            A.CallTo(() => extension.Add(A <IBehavior <ICustomExtension> > ._)).Invokes((IBehavior <ICustomExtension> b) => interceptedBehavior = b);

            this.testee
            .Execute(e => e.Dispose())
            .With(() => behavior);

            interceptedBehavior.Behave(Enumerable.Empty <ICustomExtension>());

            A.CallTo(() => behavior.Behave(Enumerable.Empty <ICustomExtension>())).MustHaveHappened();
        }
예제 #11
0
    public BehaviorReturnCode Behave(Entity entity)
    {
        try
        {
            if (_RandomFunction() <= _Probability)
            {
                ReturnCode = _Behavior.Behave(entity);
                return(ReturnCode);
            }
            else
            {
                ReturnCode = BehaviorReturnCode.Running;
                return(BehaviorReturnCode.Running);
            }
        }
        catch (Exception e)
        {
            Debug.Log("oopsie..." + e.ToString());

            ReturnCode = BehaviorReturnCode.Failure;
            return(BehaviorReturnCode.Failure);
        }
    }
예제 #12
0
        /// <inheritdoc />
        /// <remarks>Creates the behavior with the specified behavior provider and executes behave on the lazy initialized behavior.</remarks>
        public void Behave(IEnumerable <TExtension> extensions)
        {
            IBehavior <TExtension> behavior = this.behaviorProvider();

            behavior.Behave(extensions);
        }
예제 #13
0
 /// <summary>
 /// performs the given behavior
 /// </summary>
 /// <returns>the behaviors return code</returns>
 public BehaviorReturnCode Behave(Entity entity)
 {
     ReturnCode = _Behavior.Behave(entity);
     ReturnCode = BehaviorReturnCode.Running;
     return(BehaviorReturnCode.Running);
 }