public TrainSoundManager(PlaySoundDelegate playSound) { this.playSound = playSound; loopSounds = new List<LoopSound>(); loopSoundsFor = new List<LoopSoundFor>(); lastSoundTime = new Time(0); lastSoundIndex = SoundIndex.None; }
public void playSoundOnce(SoundIndex index, int delayBeforeRepeating) { if (index != lastSoundIndex || (globalTime.Milliseconds - lastSoundTime.Milliseconds > delayBeforeRepeating)) { lastSoundIndex = index; lastSoundTime = globalTime; playSound((int) index,volume,pitch,false); } }
public void PlayLoopSound(SoundIndex index) { for (int i = 0; i < allSounds.Length; i++) { if (allSounds[i].name == index) { if (!allSounds[i].source.isPlaying) { allSounds[i].source.Play(); } } } }
public void startSound(ref int id, SoundIndex index) { if (!loopSounds.Exists(delegate (LoopSound sound) { return sound.index == index; })) { LoopSound sound; sound.handle = this.playSound((int) index,volume,pitch,true); sound.index = index; loopSounds.Add(sound); id = loopSounds.IndexOf(sound); } }
public void StopLoopSound(SoundIndex index) { for (int i = 0; i < allSounds.Length; i++) { if (allSounds[i].name == index) { if (allSounds[i].source.isPlaying) { allSounds[i].source.Pause(); allSounds[i].source.Stop(); } } } }
public void PlayShortSound(SoundIndex index) { for (int i = 0; i < allSounds.Length; i++) { if (allSounds[i].type == SoundType.PlayOnce) { if (allSounds[i].name == index) { //Debug.Log("Playing: " + allSounds[i].nameForInspector); //if(!allSounds[i].source.isPlaying) allSounds[i].source.Play(); } } } }
public void playSoundOnce(SoundIndex index) { this.playSoundOnce(index, soundOnceDelay); }
public void playSoundFor(SoundIndex index, int milliseconds) { SoundHandle newSound = playSound((int) index, volume, pitch, true); loopSoundsFor.Add(new LoopSoundFor(newSound, (int) globalTime.Milliseconds, milliseconds)); }