bounce sound avoid duplication
This commit is contained in:
parent
ff44126316
commit
153459432a
|
@ -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<MultiSound.Sound>();
|
||||
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<BeatAction.Action>();
|
||||
|
||||
|
|
|
@ -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<double> bounceBeats = new();
|
||||
public void PlayBounceSound(double beat, double length)
|
||||
{
|
||||
var sounds = new List<MultiSound.Sound>();
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue