public void LoadExperience() { //Debug.LogError("LoadExperience: " + Selection.Location + " " + Selection.ExperienceType.ToString()); AudioArgs args = new AudioArgs(null, AudioType.MUSIC) { FadeTime = 2, Done = () => { if (PhotonNetwork.InRoom) { PhotonNetwork.LoadLevel(Selection.Location); } else { SceneManager.LoadSceneAsync(Selection.Location); } } }; m_audio.Stop(args); m_player.FadeOut(); AudioArgs voArgs = new AudioArgs(null, AudioType.VO) { FadeTime = 2, }; m_audio.Stop(voArgs); m_uiEngine.DisplayProgress("Loading: " + Selection.Location, true); //SceneManager.LoadScene(Selection.Location); }
public override void Load() { base.Load(); AudioArgs args = new AudioArgs(m_menuSelection.Music); args.FadeTime = 2; m_audio.Play(args); }
public void Stop(AudioArgs args) { StartCoroutine(CoAudioVolume(0, args.FadeTime, () => { m_audioSource.Stop(); args.Done?.Invoke(); })); }
public override void OnLoad() { base.OnLoad(); if (Selection.VoiceOver == null || ExperienceMachine.AppMode == AppMode.TRAINING) { return; } AudioArgs voArgs = new AudioArgs(Selection.VoiceOver, AudioType.VO); voArgs.FadeTime = 2; m_audio.Play(voArgs); }
public void Pause(AudioArgs args) { if (args.Clip == null) { return; } StartCoroutine(CoAudioVolume(0, args.FadeTime, () => { m_audioSource.Pause(); args.Done?.Invoke(); })); }
public virtual void OnLoad() { AudioSelectionFlag = false; if (m_settings == null) { m_settings = IOCCore.Resolve <ISettings>(); } if (m_audio == null) { m_audio = IOCCore.Resolve <IAudio>(); } if (m_experienceMachine == null) { m_experienceMachine = IOCCore.Resolve <IExperienceMachine>(); } if (m_commonResource == null) { m_commonResource = IOCCore.Resolve <ICommonResource>(); } var musicCategories = GetCategories(ResourceType.MUSIC); if (musicCategories == null || musicCategories.Length == 0) { return; } ExperienceResource[] resources = null; if (Selection.MusicGroup != null && Array.FindIndex(musicCategories, item => item != null && item.Name.Equals(Selection.MusicGroup)) != -1) { resources = GetResource(ResourceType.MUSIC, Selection.MusicGroup); } else { resources = GetResource(ResourceType.MUSIC, musicCategories[UnityEngine.Random.Range(0, musicCategories.Length)].Name); } if (resources == null || resources.Length == 0) { return; } AudioClip clip = ((AudioResource)resources[UnityEngine.Random.Range(0, resources.Length)]).Clip; Selection.Music = clip; AudioArgs args = new AudioArgs(clip, AudioType.MUSIC); m_audio.Play(args); }
public void Stop(AudioArgs args) { if (args.AudioType == AudioType.NONE) { return; } AudioSource audioSource = GetAudioSource(args.AudioType); StartCoroutine(CoAudioVolume(GetAudioSource(args.AudioType), 0, args.FadeTime, () => { audioSource.Stop(); args.Done?.Invoke(); })); }
public void Pause(AudioArgs args) { if (args.AudioType == AudioType.NONE || args.Clip == null) { return; } AudioSource audioSource = GetAudioSource(args.AudioType); StartCoroutine(CoAudioVolume(audioSource, 0, args.FadeTime, () => { audioSource.Pause(); args.Done?.Invoke(); })); }
public override void Load() { base.Load(); if (m_gameMachine == null) { m_gameMachine = IOC.Resolve <IGameMachine>(); } if (m_music.Length > 0) { AudioArgs args = new AudioArgs(m_music[0]); args.Fade = true; args.FadeTime = 2.0f; args.Volume = .2f; IOC.Resolve <IAudio>().Play(args); //AudioManager.Instance.PlayOneShot(m_music[0], Vector3.zero, .2f); } }
public void Resume(AudioArgs args) { if (args.Clip == null) { return; } m_audioSource.clip = args.Clip; m_audioSource.volume = 0; m_audioSource.UnPause(); if (args.FadeTime == 0) { m_audioSource.volume = 1; } else { StartCoroutine(CoAudioVolume(args.Volume, args.FadeTime, null)); } }
public void Play(AudioArgs args) { //Debug.LogError("Play"); if (args.Clip == null) { return; } m_audioSource.clip = args.Clip; m_audioSource.volume = 0.0f; m_audioSource.Play(); if (args.FadeTime == 0) { m_audioSource.volume = args.Volume; } else { StartCoroutine(CoAudioVolume(args.Volume, args.FadeTime, args.Done)); } }
public void LoadGame() { //AudioArgs args = new AudioArgs(m_menuSelection.Music); //args.FadeTime = 2; //args.Done = () => SceneManager.LoadScene(m_menuSelection.Location); //m_audio.Pause(args); //m_currentGame.OnLoad IOC.Resolve <IGlobalUI>().CloseLastScreen(); AudioArgs args = new AudioArgs(null); args.FadeTime = 1; args.Done = () => { m_currentGame.Unload(); m_currentGame = GetGame(m_menuSelection.Playground); m_currentGame.Load(); }; m_audio.Stop(args); }
public void Play(AudioArgs args) { if (args.AudioType == AudioType.NONE || args.Clip == null) { return; } AudioSource audioSource = GetAudioSource(args.AudioType); float finalVOlume = GetVolumeSetting(args.AudioType); audioSource.clip = args.Clip; audioSource.time = 0; audioSource.Play(); if (args.FadeTime == 0) { audioSource.volume = finalVOlume; } else { StartCoroutine(CoAudioVolume(audioSource, finalVOlume, args.FadeTime, args.Done)); } }
/// <summary> /// Gameplay resource selection happens here. /// </summary> /// <param name="args"></param> public override void UpdateResourceSelection(MenuClickArgs args) { base.UpdateResourceSelection(args); if (args.Data != null && args.Data is ExperienceResource) { ExperienceResource resource = (ExperienceResource)args.Data; if (resource.ResourceType == ResourceType.AUDIO) { Selection.VoiceOver = ((AudioResource)resource).Clip; AudioArgs voArgs = new AudioArgs(Selection.VoiceOver, AudioType.VO); voArgs.FadeTime = 2; m_audio.Play(voArgs); AudioSelectionFlag = true; } } //Apply selection to gameplay. //Selection can be accessed from Selection object. }
public virtual void UpdateResourceSelection(MenuClickArgs args) { if (args.Data != null && args.Data is ExperienceResource) { ExperienceResource resource = (ExperienceResource)args.Data; if (resource.ResourceType == ResourceType.MUSIC) { //Selection.Music = Array.Find(m_musicList, item => item.Clip == ((AudioResource)resource).Clip).Clip; Selection.Music = ((AudioResource)resource).Clip; AudioArgs audioStopArgs = new AudioArgs(null, AudioType.MUSIC) { FadeTime = 1.0f, Done = () => { AudioClip audioClip = Selection.Music; AudioArgs audioArgs = new AudioArgs(audioClip, AudioType.MUSIC) { FadeTime = 1 }; m_audio.Play(audioArgs); } }; m_audio.Stop(audioStopArgs); // var music = m_commonResource.GetResource(ResourceType.MUSIC, resource.Category); // Selection.Music = ((AudioResource)Array.Find(music, item => ((AudioResource)item).Clip == ((AudioResource)resource).Clip)).Clip; } if (resource.ResourceType == ResourceType.LOCATION) { Selection.Location = resource.Name; } } }