/// <summary> /// Executes on Each Loop /// </summary> /// <param name="context"></param> /// <param name="completedInstance"></param> private void LoopExecution(NativeActivityContext context, ActivityInstance completedInstance) { LoopValue.Set(context, LoopValue.Get(context) + Addition.Get(context)); if ((Addition.Get(context) > 0) ? (To.Get(context) >= LoopValue.Get(context)) : (To.Get(context) <= LoopValue.Get(context))) { context.ScheduleAction <Int32>(Loop, LoopValue.Get(context), LoopExecution, null); } }
/// <summary> /// Execution Main /// </summary> /// <param name="context"></param> protected override void Execute(NativeActivityContext context) { if (Addition.Get(context) == 0) { throw new ArgumentException("[Addition] must not Zero"); } if (Addition.Get(context) > 0 ^ From.Get(context) < To.Get(context)) { throw new ArgumentException("Invalid [From] and [To]"); } if (Loop != null) { LoopValue.Set(context, From.Get(context)); context.ScheduleAction <Int32>(Loop, LoopValue.Get(context), LoopExecution, null); } }
private void Jump() { Slider slider = stateMachine.jumpingSlider; if (loopValue == LoopValue.Increasing) { slider.value += 0.5f * Time.deltaTime; if (slider.value >= 1) { slider.value = 1; loopValue = LoopValue.Decreasing; } } if (loopValue == LoopValue.Decreasing) { slider.value -= 0.5f * Time.deltaTime; if (slider.value <= 0) { slider.value = 0; loopValue = LoopValue.Ended; } } }
public override void OnExitState() { loopValue = 0; }
public void OnExitState(FiniteStateMachine stateMachine) { loopValue = 0; }