private void Update() { if (isActive) { timetoswitch -= Time.deltaTime; float num = 1f - timetoswitch / timeperswing; float num2 = (float)Sine.EaseInOut((double)num, (double)lastPos.x, (double)(destination.x - lastPos.x), 1.0); float num3 = (float)Sine.EaseInOut((double)num, (double)lastPos.y, (double)(destination.y - lastPos.y), 1.0); Transform transform = base.transform; float x = num2; float y = num3; Vector3 localPosition = base.transform.localPosition; transform.localPosition = new Vector3(x, y, localPosition.z); if (!(timetoswitch > 0f)) { base.transform.localPosition = destination; if (remainingcount > 0 || infinite) { timetoswitch = timeperswing; UpdateShake(); remainingcount--; } else { isActive = false; base.transform.localPosition = srcPos; } } } }
public static float EaseInOut(double linearStep, EasingType type) { switch (type) { case EasingType.Step: return(linearStep < 0.5 ? 0 : 1); case EasingType.Linear: return((float)linearStep); case EasingType.Sine: return(Sine.EaseInOut(linearStep)); case EasingType.Quadratic: return(Power.EaseInOut(linearStep, 2)); case EasingType.Cubic: return(Power.EaseInOut(linearStep, 3)); case EasingType.Quartic: return(Power.EaseInOut(linearStep, 4)); case EasingType.Quintic: return(Power.EaseInOut(linearStep, 5)); } throw new NotImplementedException(); }
public static float EaseInOut(double linearStep, EasingType type) { switch (type) { case EasingType.Step: return(linearStep < 0.5 ? 0 : 1); case EasingType.Linear: return((float)linearStep); case EasingType.Sine: return(Sine.EaseInOut(linearStep)); case EasingType.Quadratic: return(Power.EaseInOut(linearStep, 2)); case EasingType.Cubic: return(Power.EaseInOut(linearStep, 3)); case EasingType.Quartic: return(Power.EaseInOut(linearStep, 4)); case EasingType.Quintic: return(Power.EaseInOut(linearStep, 5)); default: throw new ArgumentOutOfRangeException(nameof(type), type, "Unknown EasingType"); } }
/// <summary> /// Calculate a Ease InOut from a pourcent /// </summary> /// <param name="linearStep">Pourcent on the ease</param> /// <param name="type">Easing Type</param> public static float EaseInOut(float linearStep, EasingType type) { switch (type) { case EasingType.Step: return(Mathf.Round(linearStep)); default: case EasingType.Linear: return(linearStep); case EasingType.Sine: return(Sine.EaseInOut(linearStep)); case EasingType.Quadratic: return(Power.EaseInOut(linearStep, 2)); case EasingType.Cubic: return(Power.EaseInOut(linearStep, 3)); case EasingType.Quartic: return(Power.EaseInOut(linearStep, 4)); case EasingType.Quintic: return(Power.EaseInOut(linearStep, 5)); case EasingType.Elastic: return(Elastic.EaseInOut(linearStep)); case EasingType.Bounce: return(Bounce.EaseInOut(linearStep)); case EasingType.Back: return(Back.EaseInOut(linearStep)); case EasingType.Expo: return(Expo.EaseInOut(linearStep)); case EasingType.Circ: return(Circ.EaseInOut(linearStep)); } }
public static float EaseInOut(double linearStep, EasingType type) { switch (type) { case EasingType.Step: return(linearStep < 0.5 ? 0 : 1); case EasingType.Linear: return((float)linearStep); case EasingType.Sine: return(Sine.EaseInOut(linearStep)); case EasingType.Quadratic: return(Power.EaseInOut(linearStep, 2)); case EasingType.Cubic: return(Power.EaseInOut(linearStep, 3)); case EasingType.Quartic: return(Power.EaseInOut(linearStep, 4)); case EasingType.Quintic: return(Power.EaseInOut(linearStep, 5)); default: return((float)linearStep); } }
public static float EaseInOut(float linearStep, EaseType type) { switch (type) { case EaseType.None: return(1); case EaseType.Linear: return(linearStep); case EaseType.Sine: return(Sine.EaseInOut(linearStep)); case EaseType.Quad: return(Power.EaseInOut(linearStep, 2)); case EaseType.Cubic: return(Power.EaseInOut(linearStep, 3)); case EaseType.Quartic: return(Power.EaseInOut(linearStep, 4)); case EaseType.Quintic: return(Power.EaseInOut(linearStep, 5)); case EaseType.Circ: return(Circ.EaseInOut(linearStep)); case EaseType.Bounce: return(Bounce.EaseInOut(linearStep)); case EaseType.Back: return(Back.EaseInOut(linearStep)); case EaseType.Elastic: return(Elastic.EaseInOut(linearStep)); } Debug.LogError("Um."); return(0); }
public override double Ease(double t, double b, double c, double d) { return(Sine.EaseInOut(t, b, c, d)); }