public void PlayCollision(AudioEvent audioEvent) { // print("collision sound playing"); // print(audioEvent.gameObject.name); colIndex++; if (colIndex == numCollVoices - 1) { colIndex = 0; } collisionVoices[colIndex] = audioEvent; if (colIndex == numCollVoices - 1) { collisionVoices[0].StopSound(); } else if (collisionVoices[colIndex + 1] != null) { collisionVoices[colIndex + 1].StopSound(); } if (firstPlay) { audioEvent.PlaySound(0); StartCoroutine(CoolDownCoroutine()); } else { audioEvent.PlaySound(1); } }
public override void OnEvent(Event evt) { AudioEvent audioEvent = null; AudioInfo sounds = entity[Key_SoundEffects]; if (sounds == null) { throw new Exception(String.Format("No sound effects defined for Entity '{0}'", entity.ToString())); } AudioInfo.Sound sound = sounds.GetSoundForEvent(evt.Type); if (sound == null) { return; } switch (evt.Type) { case NewEntityEvent.NEW_ENTITY: NewEntityEvent newEntityEvent = (NewEntityEvent)evt; if (entity.ID != newEntityEvent.EntityID) { return; } break; case DestroyEntityEvent.DESTROY_ENTITY: DestroyEntityEvent destroyEntityEvent = (DestroyEntityEvent)evt; if (entity.ID != destroyEntityEvent.EntityID || destroyEntityEvent.IsCausedByCleanup) { return; } break; } audioEvent = AudioEvent.PlaySound(entity.ID, sound.EventName, sound.Project); if (audioEvent != null) { audioQueue.Add(audioEvent); } }