Beispiel #1
0
        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);
        }
Beispiel #2
0
        public override void Load()
        {
            base.Load();
            AudioArgs args = new AudioArgs(m_menuSelection.Music);

            args.FadeTime = 2;
            m_audio.Play(args);
        }
Beispiel #3
0
 public void Stop(AudioArgs args)
 {
     StartCoroutine(CoAudioVolume(0, args.FadeTime, () =>
     {
         m_audioSource.Stop();
         args.Done?.Invoke();
     }));
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public void Pause(AudioArgs args)
        {
            if (args.Clip == null)
            {
                return;
            }

            StartCoroutine(CoAudioVolume(0, args.FadeTime, () =>
            {
                m_audioSource.Pause();
                args.Done?.Invoke();
            }));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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();
            }));
        }
Beispiel #8
0
        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();
            }));
        }
Beispiel #9
0
 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);
     }
 }
Beispiel #10
0
        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));
            }
        }
Beispiel #11
0
 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));
     }
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        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));
            }
        }
Beispiel #14
0
        /// <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.
        }
Beispiel #15
0
        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;
                }
            }
        }