From 4b3cbea538972a6d0e4a6e264b7119effb2f130e Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Sat, 24 Jun 2023 16:11:32 +0200 Subject: [PATCH] Fixed issues with platform heights on gameswitches --- .../Scripts/Games/NightWalkAgb/AgbNightWalk.cs | 4 ++-- .../Games/NightWalkAgb/AgbPlatformHandler.cs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs b/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs index 4cda2608a..788836c79 100644 --- a/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs +++ b/Assets/Scripts/Games/NightWalkAgb/AgbNightWalk.cs @@ -107,7 +107,7 @@ namespace HeavenStudio.Games public static AgbNightWalk instance; public AgbPlayYan playYan; [SerializeField] private AgbPlatformHandler platformHandler; - [NonSerialized] public double countInBeat = -1; + [NonSerialized] public double countInBeat = double.MinValue; [NonSerialized] public float countInLength = 8; [Header("Curves")] [SerializeField] SuperCurveObject.Path[] jumpPaths; @@ -331,7 +331,7 @@ namespace HeavenStudio.Games { allEnds.Sort((x, y) => x.beat.CompareTo(y.beat)); List tempEnds = new(); - double beat = -1; + double beat = double.MinValue; for (int i = 0; i < allEnds.Count; i++) { if (allEnds[i].datamodel.Split(2) == "nightWalkAgb") diff --git a/Assets/Scripts/Games/NightWalkAgb/AgbPlatformHandler.cs b/Assets/Scripts/Games/NightWalkAgb/AgbPlatformHandler.cs index 9816ab4c4..42d9cbd3b 100644 --- a/Assets/Scripts/Games/NightWalkAgb/AgbPlatformHandler.cs +++ b/Assets/Scripts/Games/NightWalkAgb/AgbPlatformHandler.cs @@ -19,7 +19,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk public int platformCount = 20; private float lastHeight = 0; private float heightToRaiseTo = 0; - private double raiseBeat = -1; + private double raiseBeat = double.MinValue; [NonSerialized] public List allPlatforms = new(); private void Awake() @@ -29,7 +29,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk public void SpawnPlatforms(double beat) { - if (game.countInBeat != -1) + if (game.countInBeat != double.MinValue) { for (int i = 0; i < platformCount; i++) { @@ -42,14 +42,22 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk } else { + double firstInputBeat = Math.Ceiling(beat); for (int i = 0; i < platformCount; i++) { AgbPlatform platform = Instantiate(platformRef, transform); allPlatforms.Add(platform); platform.handler = this; - platform.StartInput(beat, Math.Ceiling(beat) + i - platformCount); + platform.StartInput(beat, firstInputBeat + i - platformCount); platform.gameObject.SetActive(true); } + int lastUnits = game.FindHeightUnitsAtBeat(firstInputBeat - 1); + int currentUnits = game.FindHeightUnitsAtBeat(firstInputBeat); + RaiseHeight(firstInputBeat - 1, lastUnits, currentUnits); + if (lastUnits != currentUnits) + { + game.playYan.Jump(firstInputBeat - 1); + } } } @@ -58,7 +66,7 @@ namespace HeavenStudio.Games.Scripts_AgbNightWalk var cond = Conductor.instance; if (cond.isPlaying && !cond.isPaused) { - if (raiseBeat != -1) + if (raiseBeat != double.MinValue) { float normalizedBeat = Mathf.Clamp(cond.GetPositionFromBeat(raiseBeat, 1), 0, 1); EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseOutQuint);