コード例 #1
0
 public TrainSoundManager(PlaySoundDelegate playSound)
 {
     this.playSound = playSound;
     loopSounds = new List<LoopSound>();
     loopSoundsFor = new List<LoopSoundFor>();
     lastSoundTime = new Time(0);
     lastSoundIndex = SoundIndex.None;
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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();
             }
         }
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
 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();
             }
         }
     }
 }
コード例 #6
0
 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();
             }
         }
     }
 }
コード例 #7
0
 public void playSoundOnce(SoundIndex index)
 {
     this.playSoundOnce(index, soundOnceDelay);
 }
コード例 #8
0
 public void playSoundFor(SoundIndex index, int milliseconds)
 {
     SoundHandle newSound = playSound((int) index, volume, pitch, true);
     loopSoundsFor.Add(new LoopSoundFor(newSound, (int) globalTime.Milliseconds, milliseconds));
 }