IEnumerator RescuePeopleRoutine() { float elapsed = 0f; Vector3 originalPos = helicopter.position; spriteSquish.SquishThin(); while (elapsed <= RESCUE_FLY_DURATION) { elapsed += Time.deltaTime; float t = Mathf.Clamp01(elapsed / RESCUE_FLY_DURATION); helicopter.position = originalPos + Vector3.down * Easing.CubicInOut(t) * 45f; yield return(null); } elapsed = 0f; while (elapsed <= RESCUE_PICKUP_DURATION) { elapsed += Time.deltaTime; yield return(null); } spriteSquish.SquishThin(); elapsed = 0f; while (elapsed <= RESCUE_FLY_DURATION) { elapsed += Time.deltaTime; float t = 1 - Mathf.Clamp01(elapsed / RESCUE_FLY_DURATION); helicopter.position = originalPos + Vector3.down * Easing.CubicInOut(t) * 45f; yield return(null); } helicopter.position = originalPos; state = State.Patrolling; }
public void CubicInOut() { Assert.AreEqual( 0f, Easing.CubicInOut(0f) ); Assert.AreEqual( 1f, Easing.CubicInOut(1f) ); Assert.AreEqual( 0.5f, Easing.CubicInOut(0.5f) ); }
private void Move() { float xx = (endX - startX) * time / easingTime; float yy = 0.0f; switch (type) { case EasingType.Constant: yy = endY; break; case EasingType.QuadIn: yy = Easing.QuadIn(time, easingTime, startY, endY); break; case EasingType.QuadOut: yy = Easing.QuadOut(time, easingTime, startY, endY); break; case EasingType.QuadInOut: yy = Easing.QuadInOut(time, easingTime, startY, endY); break; case EasingType.CubicIn: yy = Easing.CubicIn(time, easingTime, startY, endY); break; case EasingType.CubicOut: yy = Easing.CubicOut(time, easingTime, startY, endY); break; case EasingType.CubicInOut: yy = Easing.CubicInOut(time, easingTime, startY, endY); break; case EasingType.QuartIn: yy = Easing.QuartIn(time, easingTime, startY, endY); break; case EasingType.QuartOut: yy = Easing.QuartOut(time, easingTime, startY, endY); break; case EasingType.QuartInOut: yy = Easing.QuartInOut(time, easingTime, startY, endY); break; case EasingType.QuintIn: yy = Easing.QuintIn(time, easingTime, startY, endY); break; case EasingType.QuintOut: yy = Easing.QuintOut(time, easingTime, startY, endY); break; case EasingType.QuintInOut: yy = Easing.QuintInOut(time, easingTime, startY, endY); break; case EasingType.SineIn: yy = Easing.SineIn(time, easingTime, startY, endY); break; case EasingType.SineOut: yy = Easing.SineOut(time, easingTime, startY, endY); break; case EasingType.SineInOut: yy = Easing.SineInOut(time, easingTime, startY, endY); break; case EasingType.ExpIn: yy = Easing.ExpIn(time, easingTime, startY, endY); break; case EasingType.ExpOut: yy = Easing.ExpOut(time, easingTime, startY, endY); break; case EasingType.ExpInOut: yy = Easing.ExpInOut(time, easingTime, startY, endY); break; case EasingType.CircIn: yy = Easing.CircIn(time, easingTime, startY, endY); break; case EasingType.CircOut: yy = Easing.CircOut(time, easingTime, startY, endY); break; case EasingType.CircInOut: yy = Easing.CircInOut(time, easingTime, startY, endY); break; case EasingType.ElasticIn: yy = Easing.ElasticIn(time, easingTime, startY, endY); break; case EasingType.ElasticOut: yy = Easing.ElasticOut(time, easingTime, startY, endY); break; case EasingType.ElasticInOut: yy = Easing.ElasticInOut(time, easingTime, startY, endY); break; case EasingType.BackIn: yy = Easing.BackIn(time, easingTime, startY, endY, 1.7f); break; case EasingType.BackOut: yy = Easing.BackOut(time, easingTime, startY, endY, 1.7f); break; case EasingType.BackInOut: yy = Easing.BackInOut(time, easingTime, startY, endY, 1.7f); break; case EasingType.BounceIn: yy = Easing.BounceIn(time, easingTime, startY, endY); break; case EasingType.BounceOut: yy = Easing.BounceOut(time, easingTime, startY, endY); break; case EasingType.BounceInOut: yy = Easing.BounceInOut(time, easingTime, startY, endY); break; case EasingType.Linear: yy = Easing.Linear(time, easingTime, startY, endY); break; } if (float.IsNaN(yy)) { yy = 1; } ball.transform.position = new Vector3(startX + xx, yy, 0); }
public System.Func <float, float> GetEaseAction(EzEaseType type) { if (type == EzEaseType.SineIn) { return((v) => Easing.SineIn(v)); } else if (type == EzEaseType.SineOut) { return((v) => Easing.SineOut(v)); } else if (type == EzEaseType.SineInOut) { return((v) => Easing.SineInOut(v)); } else if (type == EzEaseType.QuadIn) { return((v) => Easing.QuadIn(v)); } else if (type == EzEaseType.QuadOut) { return((v) => Easing.QuadOut(v)); } else if (type == EzEaseType.QuadInOut) { return((v) => Easing.QuadInOut(v)); } else if (type == EzEaseType.CubicIn) { return((v) => Easing.CubicIn(v)); } else if (type == EzEaseType.CubicOut) { return((v) => Easing.CubicOut(v)); } else if (type == EzEaseType.CubicInOut) { return((v) => Easing.CubicInOut(v)); } else if (type == EzEaseType.QuartIn) { return((v) => Easing.QuartIn(v)); } else if (type == EzEaseType.QuartOut) { return((v) => Easing.QuartOut(v)); } else if (type == EzEaseType.QuartInOut) { return((v) => Easing.QuartInOut(v)); } else if (type == EzEaseType.ExpIn) { return((v) => Easing.ExpIn(v)); } else if (type == EzEaseType.ExpOut) { return((v) => Easing.ExpOut(v)); } else if (type == EzEaseType.ExpInOut) { return((v) => Easing.ExpInOut(v)); } else if (type == EzEaseType.CircIn) { return((v) => Easing.CircIn(v)); } else if (type == EzEaseType.CircOut) { return((v) => Easing.CircOut(v)); } else if (type == EzEaseType.CircInOut) { return((v) => Easing.CircInOut(v)); } else if (type == EzEaseType.ElasticIn) { return((v) => Easing.ElasticIn(v)); } else if (type == EzEaseType.ElasticOut) { return((v) => Easing.ElasticOut(v)); } else if (type == EzEaseType.ElasticInOut) { return((v) => Easing.ElasticInOut(v)); } else if (type == EzEaseType.BackIn) { return((v) => Easing.BackIn(v)); } else if (type == EzEaseType.BackOut) { return((v) => Easing.BackOut(v)); } else if (type == EzEaseType.BackInOut) { return((v) => Easing.BackInOut(v)); } else if (type == EzEaseType.BounceIn) { return((v) => Easing.BounceIn(v)); } else if (type == EzEaseType.BounceOut) { return((v) => Easing.BounceOut(v)); } else if (type == EzEaseType.BounceInOut) { return((v) => Easing.BounceInOut(v)); } else { return((v) => Easing.Linear(v)); } }