diff --git a/Assets/Scripts/Games/BouncyRoad/Ball.cs b/Assets/Scripts/Games/BouncyRoad/Ball.cs index 4df193782..e4822e68b 100644 --- a/Assets/Scripts/Games/BouncyRoad/Ball.cs +++ b/Assets/Scripts/Games/BouncyRoad/Ball.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections; using System.Collections.Generic; using UnityEngine; using NaughtyBezierCurves; @@ -48,12 +46,7 @@ namespace HeavenStudio.Games.Scripts_BouncyRoad private void Bounce() { - var sounds = new List(); - for (int i = 0; i < 12 ; i++) - { - sounds.Add(new MultiSound.Sound("bouncyRoad/ballBounce", startBeat + i * lengthBeat)); - } - MultiSound.Play(sounds.ToArray()); + game.PlayBounceSound(startBeat, lengthBeat); var actions = new List(); diff --git a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs index 014ed5825..37581a1ad 100644 --- a/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs +++ b/Assets/Scripts/Games/BouncyRoad/BouncyRoad.cs @@ -1,6 +1,4 @@ -using System; using System.Linq; -using System.Collections; using System.Collections.Generic; using UnityEngine; using NaughtyBezierCurves; @@ -8,8 +6,6 @@ using NaughtyBezierCurves; using HeavenStudio.Util; using HeavenStudio.InputSystem; -using Jukebox; - namespace HeavenStudio.Games.Loaders { using static Minigames; @@ -238,6 +234,19 @@ namespace HeavenStudio.Games }); } + List bounceBeats = new(); + public void PlayBounceSound(double beat, double length) + { + var sounds = new List(); + for (int i = 0; i < 12 ; i++) + { + var bounceBeat = beat + i * length; + if (!bounceBeats.Contains(bounceBeat)) sounds.Add(new MultiSound.Sound("bouncyRoad/ballBounce", bounceBeat)); + bounceBeats.Add(bounceBeat); + } + MultiSound.Play(sounds.ToArray()); + } + private Transform GenerateInitCurve(Vector3 pos1, Vector3 pos2) { float dist = Vector3.Distance(pos1, pos2);