IEnumerator deccelerateOnExit() { boostHoldTimer = 0; while (boostHoldTimer <= BoostHoldTime) { boostHoldTimer += Time.deltaTime; controller.acceleration = EasingFunctions.EaseOutQuint(controller.acceleration, oldAccel, boostHoldTimer / BoostHoldTime); yield return(null); } yield return(null); }
private void AnimateTween(Vector2 startPos, Vector2 changePos) { if (time < duration) { time++; } var x = EasingFunctions.EaseOutQuint(time, startPos.x, changePos.x - startPos.x, duration); var y = EasingFunctions.EaseOutQuint(time, startPos.y, changePos.y - startPos.y, duration); Position = new Vector2(x, y); }
private void ButtonReaction( Image _image, ref int ArrowChangeState, ref float ArrowAnimTime, float deltaTime) { if (ArrowChangeState == 0) { ArrowAnimTime += deltaTime / this.ArrowBigAnimTimeLimit; float time = Mathf.InverseLerp(0.0f, 1f, ArrowAnimTime); float num = EasingFunctions.EaseOutQuint(time, 1f); ((Graphic)_image).set_color(new Color(Mathf.Lerp((float)this.arrowColor[0].r, (float)this.arrowColor[2].r, num), Mathf.Lerp((float)this.arrowColor[0].g, (float)this.arrowColor[2].g, num), Mathf.Lerp((float)this.arrowColor[0].b, (float)this.arrowColor[2].b, num), Mathf.Lerp((float)this.arrowColor[0].a, (float)this.arrowColor[2].a, num))); ((Component)_image).get_transform().set_localScale(Vector3.Lerp(Vector3.get_one(), Vector3.op_Multiply(Vector3.get_one(), 1.3f), num)); if ((double)num != 1.0) { return; } ArrowAnimTime = 0.0f; ArrowChangeState = 1; } else if (ArrowChangeState == 1) { ArrowAnimTime += deltaTime / this.ArrowWaitAnimTimeLimit; if ((double)Mathf.InverseLerp(0.0f, 1f, ArrowAnimTime) != 1.0) { return; } ArrowAnimTime = 1f; ArrowChangeState = 2; } else { if (ArrowChangeState != 2) { return; } ArrowAnimTime -= deltaTime / this.ArrowSmallAnimTimeLimit; float time = Mathf.InverseLerp(0.0f, 1f, ArrowAnimTime); float num = EasingFunctions.EaseOutQuint(time, 1f); ((Graphic)_image).set_color(new Color(Mathf.Lerp((float)this.arrowColor[0].r, (float)this.arrowColor[2].r, num), Mathf.Lerp((float)this.arrowColor[0].g, (float)this.arrowColor[2].g, num), Mathf.Lerp((float)this.arrowColor[0].b, (float)this.arrowColor[2].b, num), Mathf.Lerp((float)this.arrowColor[0].a, (float)this.arrowColor[2].a, num))); ((Component)_image).get_transform().set_localScale(Vector3.Lerp(Vector3.get_one(), Vector3.op_Multiply(Vector3.get_one(), 1.3f), num)); if ((double)num != 0.0) { return; } ArrowAnimTime = 0.0f; ArrowChangeState = -1; } }
private void EasingImage( Image _image, float _count, float _limit, Color _color1, Color _color2, Vector3 _scale1, Vector3 _scale2) { float time = Mathf.InverseLerp(0.0f, _limit, _count); float t = EasingFunctions.EaseOutQuint(time, 1f); ((Graphic)_image).set_color(this.Lerp(_color1, _color2, t)); ((Component)_image).get_transform().set_localScale(Vector3.Lerp(_scale1, _scale2, t)); }
public override void _Process(float delta) { var root = GetParent().GetParent <Node2D>(); var menuContainer = root.GetNode <VBoxContainer>("Background/MenuContainer"); var marginContainer = root.GetNode <MarginContainer>("Background/MenuContainer/MarginContainer"); var label = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/No"); if (Input.IsActionJustPressed("ui_up") || Input.IsActionJustPressed("ui_down")) { if (choice == Choices.Yes) { choice = Choices.No; } else { choice = Choices.Yes; } prevPos = Position; time = 0; } if (Input.IsActionJustPressed("ui_accept")) { GetTree().Paused = false; if (choice == Choices.Yes) { GetTree().ChangeScene("res://Scenes/Rooms/TitleScreen.tscn"); } else { root.Visible = false; } SetProcess(false); } if (Input.IsActionJustPressed("ui_cancel")) { root.Visible = false; SetProcess(false); } switch (choice) { case Choices.Yes: label = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/Yes"); break; case Choices.No: label = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/No"); break; } var x = menuContainer.RectPosition.y + 112; var y = menuContainer.RectPosition.y + marginContainer.RectPosition.y + label.RectPosition.y + label.RectSize.y / 2; var labelPos = new Vector2(x, y); // Ease movement if (time < duration) { time++; } x = EasingFunctions.EaseOutQuint(time, prevPos.x, labelPos.x - prevPos.x, duration); y = EasingFunctions.EaseOutQuint(time, prevPos.y, labelPos.y - prevPos.y, duration); Position = new Vector2(x, y); }