public override void SimulateOwner() { Think(); behavior.Behave(Character); state.Direction = Character.Body.Direction; state.Velocity = Character.Body.Velocity; }
/// <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); }
/// <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); } }
/// <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); } }
/// <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); }
/// <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); } }
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>())); }
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(); }
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>())); }
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(); }
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); } }
/// <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); }
/// <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); }