private IEnumerator Sequence(Vector2 node, bool reverse) { Vector2 start = base.Position; if (reverse) { while (TimedSwitch.Check(Scene)) { yield return((object)null); } } else { while (!TimedSwitch.Check(Scene)) { yield return((object)null); } } if (persistent) { TimedSwitch.SetLevelFlag(SceneAs <Level>()); } yield return((object)0.1f); openSfx.Play("event:/game/general/touchswitch_gate_open", null, 0f); StartShaking(0.5f); while (icon.Rate < 1f) { icon.Color = Color.Lerp(inactiveColor, activeColor, icon.Rate); icon.Rate += Engine.DeltaTime * 2f; yield return((object)null); } yield return((object)0.1f); int particleAt = 0; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 2f, true); tween.OnUpdate = delegate(Tween t) { MoveTo(Vector2.Lerp(start, node, t.Eased)); if (Scene.OnInterval(0.1f)) { particleAt++; particleAt %= 2; for (int n = 0; (float)n < Width / 8f; n++) { for (int num2 = 0; (float)num2 < Height / 8f; num2++) { if ((n + num2) % 2 == particleAt) { //SceneAs<Level>().ParticlesBG.Emit(P_Behind, base.Position + new Vector2((float)(n * 8), (float)(num2 * 8)) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f)); } } } } }; Add(tween); yield return((object)1.8f); bool collidable = base.Collidable; base.Collidable = false; if (node.X <= start.X) { Vector2 value = new Vector2(0f, 2f); for (int i = 0; (float)i < Height / 8f; i++) { Vector2 vector = new Vector2(Left - 1f, Top + 4f + (float)(i * 8)); Vector2 point = vector + Vector2.UnitX; if (Scene.CollideCheck <Solid>(vector) && !Scene.CollideCheck <Solid>(point)) { //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector + value, 3.14159274f); //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector - value, 3.14159274f); } } } if (node.X >= start.X) { Vector2 value2 = new Vector2(0f, 2f); for (int j = 0; (float)j < Height / 8f; j++) { Vector2 vector2 = new Vector2(Right + 1f, Top + 4f + (float)(j * 8)); Vector2 point2 = vector2 - Vector2.UnitX * 2f; if (Scene.CollideCheck <Solid>(vector2) && !Scene.CollideCheck <Solid>(point2)) { //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector2 + value2, 0f); //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector2 - value2, 0f); } } } if (node.Y <= start.Y) { Vector2 value3 = new Vector2(2f, 0f); for (int k = 0; (float)k < Width / 8f; k++) { Vector2 vector3 = new Vector2(Left + 4f + (float)(k * 8), Top - 1f); Vector2 point3 = vector3 + Vector2.UnitY; if (Scene.CollideCheck <Solid>(vector3) && !Scene.CollideCheck <Solid>(point3)) { //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector3 + value3, -1.57079637f); //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector3 - value3, -1.57079637f); } } } if (node.Y >= start.Y) { Vector2 value4 = new Vector2(2f, 0f); for (int l = 0; (float)l < Width / 8f; l++) { Vector2 vector4 = new Vector2(Left + 4f + (float)(l * 8), Bottom + 1f); Vector2 point4 = vector4 - Vector2.UnitY * 2f; if (Scene.CollideCheck <Solid>(vector4) && !Scene.CollideCheck <Solid>(point4)) { //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector4 + value4, 1.57079637f); //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector4 - value4, 1.57079637f); } } } base.Collidable = collidable; Audio.Play("event:/game/general/touchswitch_gate_finish", base.Position); StartShaking(0.2f); bool collidable2 = base.Collidable; base.Collidable = false; base.Collidable = collidable2; if (!reverse) { base.Add(new Coroutine(Sequence(ogPosition, true), true)); } else { base.Add(new Coroutine(Sequence(ogTarget, false), true)); } }
public override void Update() { orig_Update(); // Slightly dirty place to perform this, but oh well... if (CoreModule.Settings.QuickRestart != null) { int slot = CoreModule.Settings.QuickRestart.Value; CoreModule.Settings.QuickRestart = null; CoreModule.Instance.SaveSettings(); SaveData save = UserIO.Load <SaveData>(SaveData.GetFilename(slot)); if (save != null) { SaveData.Start(save, slot); if (slot == -1) { save.DebugMode = true; } if (save.CurrentSession?.InArea ?? false) { LevelEnter.Go(save.CurrentSession, true); } else { Overworld.Goto <OuiChapterSelect>(); } } } if (!updateChecked && Everest.Updater.HasUpdate && Everest.Updater.Newest != null && alpha >= 1f) { updateChecked = true; updateTex = Everest.Updater.Newest.Branch == "stable" ? GFX.Gui["areas/new"] : GFX.Gui["areas/new-yellow"]; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeInOut, 0.3f, true); tween.OnUpdate = t => { updateAlpha = t.Percent; }; Add(tween); } if (alpha >= 1f && Selected && Input.MenuRight && arrowToVanilla != null) { switchingToVanillaBack = Math.Max(0f, switchingToVanillaBack - Engine.DeltaTime * 8f); switchingToVanilla += Engine.DeltaTime; if (switchingToVanilla >= switchingToVanillaDuration && !Everest.RestartVanilla) { Everest.RestartVanilla = true; new FadeWipe(Scene, false, () => { Engine.Scene = new Scene(); Engine.Instance.Exit(); }); } } else if (switchingToVanilla < switchingToVanillaDuration) { if (switchingToVanilla > 0f) { switchingToVanillaBack = Math.Max(switchingToVanilla, switchingToVanillaBack); } switchingToVanillaBack = Math.Max(0f, switchingToVanillaBack - Engine.DeltaTime * 4f); switchingToVanilla = 0f; } }
private IEnumerator BoostRoutine(Player player) { holding = player; travelling = true; ++nodeIndex; sprite.Visible = false; sprite.Position = Vector2.Zero; Collidable = false; var finalBoost = nodeIndex >= nodes.Length; Level level = SceneAs <Level>(); Stopwatch sw = new Stopwatch(); sw.Start(); if (!finalBoost) { Audio.Play("event:/char/badeline/booster_begin", Position); } else { Audio.Play("event:/char/badeline/booster_final", Position); } if (player.Holding != null) { player.Drop(); } player.StateMachine.State = 11; player.DummyAutoAnimate = false; player.DummyGravity = false; if (player.Inventory.Dashes > 1) { player.Dashes = 1; } else { player.RefillDash(); } player.RefillStamina(); player.Speed = Vector2.Zero; var side = Math.Sign(player.X - X); if (side == 0) { side = -1; } BadelineDummy badeline = new BadelineDummy(Position); Scene.Add(badeline); if (side == -1) { player.Facing = Facings.Right; } else { player.Facing = Facings.Left; } badeline.Sprite.Scale.X = side; Vector2 playerFrom = player.Position; Vector2 playerTo = Position + new Vector2(side * 4, -3f); Vector2 badelineFrom = badeline.Position; Vector2 badelineTo = Position + new Vector2(-side * 4, 3f); for (var p = 0.0f; (double)p < 1.0; p += Engine.DeltaTime / 0.2f) { Vector2 target = Vector2.Lerp(playerFrom, playerTo, p); if (player.Scene != null) { player.MoveToX(target.X); } if (player.Scene != null) { player.MoveToY(target.Y); } badeline.Position = Vector2.Lerp(badelineFrom, badelineTo, p); yield return(null); } if (finalBoost) { Vector2 center = new Vector2(Calc.Clamp(player.X - level.Camera.X, 120f, 200f), Calc.Clamp(player.Y - level.Camera.Y, 60f, 120f)); Add(new Coroutine(level.ZoomTo(center, 1.5f, 0.18f))); Engine.TimeRate = 0.5f; } else { Audio.Play("event:/char/badeline/booster_throw", Position); } badeline.Sprite.Play("boost"); yield return(0.1f); if (!player.Dead) { player.MoveV(5f); } yield return(0.1f); Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { if (player.Dashes < player.Inventory.Dashes) { ++player.Dashes; } Scene.Remove(badeline); (Scene as Level)?.Displacement.AddBurst(badeline.Position, 0.25f, 8f, 32f, 0.5f); }, 0.15f, true)); (Scene as Level)?.Shake(); holding = null; if (!finalBoost) { player.BadelineBoostLaunch(CenterX); Vector2 from = Position; Vector2 to = nodes[nodeIndex]; var time = Vector2.Distance(from, to) / MoveSpeed; time = Math.Min(3f, time); stretch.Visible = true; stretch.Rotation = (to - from).Angle(); Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.SineInOut, time, true); tween.OnUpdate = t => { Position = Vector2.Lerp(from, to, t.Eased); stretch.Scale.X = (float)(1.0 + Calc.YoYo(t.Eased) * 2.0); stretch.Scale.Y = (float)(1.0 - Calc.YoYo(t.Eased) * 0.75); if (t.Eased >= 0.899999976158142 || !Scene.OnInterval(0.03f)) { return; } TrailManager.Add(this, Player.TwoDashesHairColor, 0.5f, false); level.ParticlesFG.Emit(BadelineBoost.P_Move, 1, Center, Vector2.One * 4f); }; tween.OnComplete = t => { if (level != null && X >= (double)level.Bounds.Right) { RemoveSelf(); } else { travelling = false; stretch.Visible = false; sprite.Visible = true; Collidable = true; Audio.Play("event:/char/badeline/booster_reappear", Position); } }; Add(tween); relocateSfx.Play("event:/char/badeline/booster_relocate"); Input.Rumble(RumbleStrength.Strong, RumbleLength.Medium); level.DirectionalShake(-Vector2.UnitY); level.Displacement.AddBurst(Center, 0.4f, 8f, 32f, 0.5f); } else { Console.WriteLine("TIME: " + sw.ElapsedMilliseconds); Engine.FreezeTimer = 0.1f; yield return(null); Input.Rumble(RumbleStrength.Strong, RumbleLength.Long); level.Flash(Color.White * 0.5f, true); level.DirectionalShake(Vector2.UnitY, 0.6f); level.Displacement.AddBurst(Center, 0.6f, 8f, 64f, 0.5f); level.ResetZoom(); player.StateMachine.State = 18; Engine.TimeRate = 1f; Finish(); } }
/// <summary> /// Tweens a vector over the given spline over time. /// </summary> static public Tween Vector(ISpline inSpline, Action <Vector3> inSetter, TweenSettings inSettings, SplineTweenSettings inSplineSettings) { return(Tween.Create(new TweenData_Value_Spline(inSpline, inSetter, inSplineSettings), inSettings)); }
/// <summary> /// Tweens a vector over the given spline over time. /// </summary> static public Tween Vector(ISpline inSpline, Action <Vector3> inSetter, float inTime) { return(Tween.Create(new TweenData_Value_Spline(inSpline, inSetter, SplineTweenSettings.Default), inTime)); }
/// <summary> /// Tweens over the given spline over time. /// </summary> static public Tween Spline(ISpline inSpline, SplineUpdateDelegate inUpdate, TweenSettings inSettings, SplineTweenSettings inSplineSettings) { return(Tween.Create(new TweenData_Value_SplineInfo(inSpline, inUpdate, inSplineSettings), inSettings)); }
/// <summary> /// Tweens over the given spline over time. /// </summary> static public Tween Spline(ISpline inSpline, SplineUpdateDelegate inUpdate, float inTime) { return(Tween.Create(new TweenData_Value_SplineInfo(inSpline, inUpdate, SplineTweenSettings.Default), inTime)); }