public TimeRamp StartDownIn(float waitTime) { _hasPending = true; rampState = RampState.reachedOne; // if (ignoreTimeScale) // pendingTime = Time.time + waitTime * Time.timeScale; // else pendingTime = Time.time + waitTime; pendingState = RampState.goingDown; return(this); }
/// <summary> /// changes the direction of the ramp - used mainly internally /// </summary> public TimeRamp TurnUp() { if (triggerCallbacksOnDirectionChange) { _callbackZero(); } float v = (Time.time - startTime) / duration; startTime = Time.time - duration * (1 - v); rampState = RampState.goingUp; return(this); }
/// <summary> /// Tells the ramp to go towards ZERO, reverses the movement if going UP, does nothing if it already goes ZERO, forces one update if reached ZERO /// </summary> public TimeRamp GoZero() { switch (rampState) { case RampState.reachedZero: rampState = RampState.goingDown; // will force at least one update break; case RampState.goingDown: return(this); case RampState.reachedOne: StartFromOne(); break; case RampState.goingUp: TurnDown(); break; } return(this); }
public TimeRamp Stop() { rampState = RampState.reachedZero; _hasPending = false; return(this); }
/// <summary> /// Use GoOne if you think ramp might be already running /// </summary> public TimeRamp StartFromZero() { startTime = Time.time; rampState = RampState.goingUp; return(this); }
/// <summary> /// Use GoZero if you think ramp might be already running /// </summary> public TimeRamp StartFromOne() { startTime = Time.time; rampState = RampState.goingDown; return(this); }