public void PlayGameOver() { // Precautions if (_Vox_GameOver.Count > 0 && _PlayingSound == false) { // Get random sound from the list AudioWrapper source = _Vox_GameOver[RandomSoundVoxInt(_Vox_GameOver)]; // Queue the sound to the voxel waiting list SoundManager._pInstance.GetVoxelWaitingList().Add(source); // If the sound is the only one in the list if (SoundManager._pInstance.GetVoxelWaitingList().Count == 1) { // And the sound has no owner associated with it (only the announcer sounds have no owner) if (SoundManager._pInstance.GetVoxelWaitingList()[0]._Owner == null) { // Play the sound SoundManager._pInstance.GetVoxelWaitingList()[0]._SoundSource.Play(); SoundManager._pInstance.StartingPlayingVoxels(); _PlayingSound = false; } } } }
/// VOX public void PlayTaunt() { // Precautions if (_TauntSounds.Count > 0) { // Get random sound from list AudioWrapper sound = _TauntSounds[RandomSoundVoxInt(_TauntSounds)]; // Queue the sound to the voxel waiting list SoundManager._pInstance.GetVoxelWaitingList().Add(sound); // If the sound is the only one in the list if (SoundManager._pInstance.GetVoxelWaitingList().Count == 1) { // And the sound belongs to us if (SoundManager._pInstance.GetVoxelWaitingList()[0]._Owner._Player == this.GetComponent <Dialog>().GetPlayerAssociated()) { // Play the sound SoundManager._pInstance.GetVoxelWaitingList()[0]._SoundSource.Play(); SoundManager._pInstance.StartingPlayingVoxels(); _IsTauntPlaying = true; } } } }
private AudioClip GetAudioClipFromMP3(string mp3) { _wrapper = new AudioWrapper(); _wrapper.Open(mp3); var rtn = AudioClip.Create(mp3, (int)_wrapper.Samples, 2, _wrapper.Frequency, true, OnAudioRead); return(rtn); }
public void Swap(string _name) { if (m_audioclipmap.ContainsKey(_name)) { AudioWrapper ap = frontpeer; frontpeer.SetFadeOut(); frontpeer = backpeer; frontpeer.SetAudioClip(m_audioclipmap[_name]); frontpeer.SetFadeIn(); frontpeer.StartPlaying(); backpeer = ap; _ba.ReadBpm(frontpeer.GetComponent <AudioSource>().clip.name); } else { m_audioclipmap.Add(_name, GetComponent <AudioLoader>().LoadSong(_name)); } //UniBpmAnalyzer.AnalyzeBpm(frontpeer.GetComponent<AudioSource>().clip); }
// Update is called once per frame void Update() { if (PlayerController._crescendo) { if (m_playqueue.Count > 0 && !QTE) { next = _stateGenerator.GenerateState(StateGenerator.GenerateType.QUICKTIMEEVENTSTATE, m_playqueue.Peek().GetClipName(), m_audioclipmap[m_playqueue.Peek().GetClipName()]); QTE = true; } } if (swap && m_playqueue.Count > 0) { curr.StopRun(); curr = m_playqueue.Dequeue(); if (QTE) { curr = next; QTE = false; } curr.Run(); AudioWrapper ap = frontpeer; frontpeer.SetFadeOut(); frontpeer = backpeer; frontpeer.SetAudioClip(m_audioclipmap[curr.GetClipName()]); frontpeer.SetFadeIn(); frontpeer.StartPlaying(); backpeer = ap; swap = !swap; } else if (m_playqueue.Count <= 0) { playerScore.SaveScore(); SceneManager.LoadScene("SongEndScene"); } }
//-------------------------------------------------------------- // *** FRAME *** private void Update() { // If there are voxel sounds waiting to be played if (_VoxelWaitingList.Count > 0) { if (_IsPlayingVoxel == true) { // Find the voxel sound that is current playing AudioWrapper vox = null; foreach (var sound in _VoxelWaitingList) { AudioSource source = sound._SoundSource; // If a sound from the voxel list is playing if (source.isPlaying == true) { // Then a voxel is playing vox = sound; if (vox._Owner != null) { vox._Owner.GetComponent <Char_Geomancer>().GetDialog().SetIsTaunting(true); } } break; } _IsPlayingVoxel = vox != null; } // A vox has finished playing else /// _IsPlayingVoxel == false // Character is no longer taunting { if (_VoxelWaitingList[0]._Owner != null) { _VoxelWaitingList[0]._Owner.GetComponent <Char_Geomancer>().GetDialog().SetIsTaunting(false); } // Get the last voxel that was playing (should be at the front of the list) & remove it from the queue _VoxelWaitingList.RemoveAt(0); // If there are still voxels in the queue if (_VoxelWaitingList.Count > 0) { // Play the next vox sound in the queue _VoxelWaitingList[0]._SoundSource.Play(); if (_VoxelWaitingList[0]._Owner != null) { _VoxelWaitingList[0]._Owner.GetComponent <Char_Geomancer>().GetDialog().SetIsTaunting(true); } _IsPlayingVoxel = true; _TimeSinceLastVoxel = 0f; } } } // No more voxels are left in the playing queue else if (_VoxelWaitingList.Count == 0) { // Add to timer _TimeSinceLastVoxel += Time.deltaTime; } }