private void ChangeScene() { Application.LoadLevel("Loading"); Resources.UnloadUnusedAssets(); GC.Collect(); Application.LoadLevel(NextScene); SoundLib.StopAllSoundEffects(); if (CurrentScene != NextScene) { if (String.Equals(CurrentScene, "QuadMist")) { FF9Wipe_FadeInEx(30); } if (String.Equals(NextScene, "MainMenu")) { SoundLib.StopAllSounds(); } if (String.Equals(NextScene, FieldMapSceneName)) { FF9Snd.sndFuncPtr = FF9Snd.FF9FieldSoundDispatch; if (String.Equals(CurrentScene, WorldMapSceneName)) { FF9Snd.HasJustChangedBetweenWorldAndField = true; } } else if (String.Equals(NextScene, WorldMapSceneName)) { AllSoundDispatchPlayer soundDispatchPlayer = SoundLib.GetAllSoundDispatchPlayer(); soundDispatchPlayer.FF9SOUND_SNDEFFECTRES_STOPCURRENT(); HashSet <Int32> exceptObjNo = new HashSet <Int32> { 1261 }; soundDispatchPlayer.FF9SOUND_SNDEFFECT_STOP_ALL(exceptObjNo); soundDispatchPlayer.FF9SOUND_STREAM_STOP(); FF9Snd.sndFuncPtr = FF9Snd.FF9WorldSoundDispatch; if (String.Equals(CurrentScene, FieldMapSceneName)) { FF9Snd.HasJustChangedBetweenWorldAndField = true; } } else if (!String.Equals(NextScene, BattleMapSceneName)) { FF9Snd.sndFuncPtr = !String.Equals(NextScene, "QuadMist") ? FF9Snd.FF9AllSoundDispatch : (FF9Snd.SoundDispatchDelegate)FF9Snd.FF9MiniGameSoundDispatch; } if (String.IsNullOrEmpty(PendingCurrentScene)) { LastScene = CurrentScene; } else { LastScene = PendingCurrentScene; PendingCurrentScene = String.Empty; } CurrentScene = NextScene; UnityEngine.Debug.Log("---------- Current Scene : " + Instance.CurrentScene + " ----------"); } NextScene = String.Empty; SetTargetFrameRateForCurrentScene(); }
public void PlayMusic(Int32 soundIndex, Int32 fadeIn, SoundProfileType type = SoundProfileType.Music) { SoundProfile soundProfile = this.soundDatabase.Read(soundIndex); if (soundProfile == null) { soundProfile = this.onTheFlySoundDatabase.Read(soundIndex); } if (soundProfile != null) { this.PlayMusic(soundProfile, fadeIn); } else { soundProfile = SoundMetaData.GetSoundProfile(soundIndex, type); this.onTheFlyLoadedSoundProfile = soundProfile; this.onTheFlyLoadedFadeIn = fadeIn; if (this.onTheFlySoundDatabase.ReadAll().Count >= 10) { SoundLib.Log("Unload on the fly sound database."); base.UnloadResource(this.onTheFlySoundDatabase); } base.LoadResource(soundProfile, this.onTheFlySoundDatabase, new SoundPlayer.LoadResourceCallback(this.LoadOnTheFlySoundResourceCallback)); } }
private void RegisterBankAsCallback(SoundProfile profile, SoundDatabase soundDatabase) { if (profile != null && soundDatabase != null) { soundDatabase.Create(profile); this.resourceLoadingCounter--; if (this.resourceLoadingCounter == 0) { this.activeCallback(soundDatabase, false); } else { SoundLib.Log("resourceLoadingCounter > 0! resourceLoadingCounter: " + this.resourceLoadingCounter); this.activeCallback(soundDatabase, true); } } else { SoundLib.Log("either profile OR soundDatabase is null"); this.resourceLoadingCounter--; if (this.resourceLoadingCounter == 0) { this.activeCallback(soundDatabase, true); } else { SoundLib.Log("resourceLoadingCounter > 0! resourceLoadingCounter: " + this.resourceLoadingCounter); this.activeCallback(soundDatabase, true); } } }
private void Exit() { EndGameMain.Instance.endGame.FF9SFX_Play(103u); FF9Snd.ff9endsnd_song_vol_intpl(156, 60, 0); SoundLib.GetAllSoundDispatchPlayer().StopCurrentSong(60); SceneDirector.Replace(PersistenSingleton <SceneDirector> .Instance.LastScene, SceneTransition.FadeOutToBlack_FadeIn, true); }
protected override void Awake() { base.Awake(); SceneDirector.abrColor = new Color32[2]; SceneDirector.abrColor[0] = new Color32(0, 0, 0, Byte.MaxValue); SceneDirector.abrColor[1] = new Color32(0, 0, 0, Byte.MaxValue); SceneDirector.ClearFadeColor(); String loadedLevelName = Application.loadedLevelName; this.LastScene = String.Empty; this.CurrentScene = loadedLevelName; this.NextScene = String.Empty; this.PendingCurrentScene = String.Empty; this.PendingNextScene = String.Empty; this.IsFading = false; this.IsReady = true; this.fadeTex = Texture2D.whiteTexture; this.NeedFade = true; this.screenTex = Texture2D.whiteTexture; this.swirlCount = 0; this._logger = new OSDLogger(); this._logger.Init(); OSDLogger.Instance = this._logger; GameObject gameObject = new GameObject("SoundPlayer"); gameObject.transform.parent = base.transform; SoundLib soundLib = gameObject.AddComponent <SoundLib>(); SoundLibInitializer soundLibInitializer = gameObject.AddComponent <SoundLibInitializer>(); }
public static void Replace(String nextScene, SceneTransition transition = SceneTransition.FadeOutToBlack_FadeIn, Boolean needFade = true) { if (nextScene != "MainMenu") { if (Singleton <BubbleUI> .Instance != null) { Singleton <BubbleUI> .Instance.SetGameObjectActive(false); } EventHUD.Cleanup(); EventInput.ClearPadMask(); } Instance.Transition = transition; if (transition == SceneTransition.SwirlInBlack || transition == SceneTransition.SwirlInWhite) { PersistenSingleton <UIManager> .Instance.SetPlayerControlEnable(false, null); Instance.Swirl(nextScene, transition); } else { Instance.NextScene = nextScene; SoundLib.LazyLoadSoundResources(); PersistenSingleton <UIManager> .Instance.SetLoadingForSceneChange(); Instance.Replace(needFade); } }
public void StopSoundEffect(Int32 soundIndex) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; if (value.SoundIndex == soundIndex) { Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundID, 0); this.playedEffectSet.Remove(soundID); SoundLib.Log("Force stop success"); } else { SoundLib.Log("soundID: " + soundID + " not found"); } } } } }
public static void Replace(String nextScene, SceneTransition transition = SceneTransition.FadeOutToBlack_FadeIn, Boolean needFade = true) { if (String.IsNullOrEmpty(nextScene)) { Log.Error($"[{nameof(SceneDirector)}] Someone tried to change the current scene [{Instance.CurrentScene}] to the invalid scene: [{nextScene}]. Stack: " + Environment.NewLine + Environment.StackTrace); } if (nextScene != "MainMenu") { if (Singleton <BubbleUI> .Instance != (UnityEngine.Object)null) { Singleton <BubbleUI> .Instance.SetGameObjectActive(false); } EventHUD.Cleanup(); EventInput.ClearPadMask(); } PersistenSingleton <SceneDirector> .Instance.Transition = transition; if (transition == SceneTransition.SwirlInBlack || transition == SceneTransition.SwirlInWhite) { PersistenSingleton <UIManager> .Instance.SetPlayerControlEnable(false, (Action)null); PersistenSingleton <SceneDirector> .Instance.Swirl(nextScene, transition); return; } PersistenSingleton <SceneDirector> .Instance.NextScene = nextScene; SoundLib.LazyLoadSoundResources(); PersistenSingleton <UIManager> .Instance.SetLoadingForSceneChange(); PersistenSingleton <SceneDirector> .Instance.Replace(needFade); }
private static void CreateBattleEncountBgmMetaData(String path, out Dictionary <Int32, Dictionary <Int32, Int32> > mapper) { TextAsset textAsset = AssetManager.Load <TextAsset>(path, false); mapper = new Dictionary <Int32, Dictionary <Int32, Int32> >(); if ((UnityEngine.Object)null == textAsset) { SoundLib.LogError("File not found AT path: " + path); return; } JSONClass jsonclass = (JSONClass)JSONNode.Parse(textAsset.text); foreach (String text in jsonclass.Dict.Keys) { Dictionary <Int32, Int32> dictionary = new Dictionary <Int32, Int32>(); Int32 key = Convert.ToInt32(text); JSONClass jsonclass2 = (JSONClass)jsonclass[text]; foreach (String text2 in jsonclass2.Dict.Keys) { Int32 key2 = Convert.ToInt32(text2); Int32 value = Convert.ToInt32(jsonclass2[text2]); dictionary.Add(key2, value); } mapper.Add(key, dictionary); } }
void Awake() { if (instance != null) { Destroy(gameObject); //When we reload a new Sence. We get a copy. so we need to Destroy it. } else { DontDestroyOnLoad(gameObject); instance = this; library = GetComponent <SoundLib>(); musicSources = new AudioSource[2]; for (int i = 0; i < 2; i++) { GameObject newMusicSource = new GameObject("Music source" + (i + 1)); musicSources[i] = newMusicSource.AddComponent <AudioSource>(); newMusicSource.transform.parent = transform; } GameObject newSfx2Dsource = new GameObject("2D sfx source"); sfx2DSource = newSfx2Dsource.AddComponent <AudioSource>(); newSfx2Dsource.transform.parent = transform; audioListener = FindObjectOfType <AudioListener>().transform; //playerT = FindObjectOfType<Player>().transform; masterVolumePercent = PlayerPrefs.GetFloat("master Volume", masterVolumePercent); musicVolumePercent = PlayerPrefs.GetFloat("music Volume", masterVolumePercent); sfxVolumePercent = PlayerPrefs.GetFloat("Sfx Volume", sfxVolumePercent); } }
public static void StopMovieMusic(String movieName, Boolean isForceStop = false) { if (SoundLib.instance == (UnityEngine.Object)null) { return; } if (!isForceStop) { if (String.Equals(movieName, "FMV000")) { SoundLib.Log("Don't stop sound for " + movieName + " if it is NOT forced to stop."); } else { SoundLib.movieAudioPlayer.StopMusic(); } } else if (String.Equals(movieName, "FMV000")) { Int32 ticks = 90; Int32 fadeOut = AllSoundDispatchPlayer.ConvertTickToMillisec(ticks); SoundLib.movieAudioPlayer.StopMusic(fadeOut); } else { SoundLib.movieAudioPlayer.StopMusic(); } }
public static SoundProfile GetSoundProfile(Int32 soundIndex, SoundProfileType type) { String text = String.Empty; switch (type) { case SoundProfileType.Music: text = SoundMetaData.MusicIndex[soundIndex]; break; case SoundProfileType.SoundEffect: text = SoundMetaData.SoundEffectIndex[soundIndex]; break; case SoundProfileType.MovieAudio: text = SoundMetaData.MovieAudioIndex[soundIndex]; break; case SoundProfileType.Song: text = SoundMetaData.SongIndex[soundIndex]; break; case SoundProfileType.Sfx: SoundLib.Log("GetSoundProfile does not support type SoundProfileType.Sfx"); return((SoundProfile)null); } return(new SoundProfile { Code = soundIndex.ToString(), Name = text, SoundIndex = soundIndex, ResourceID = text, SoundProfileType = type }); }
public void SetActiveSoundType(SoundProfileType type) { if (this.activeSound != null) { SoundLib.StopMusic(); this.IsPlay = false; } this.activeType = type; this.currentPlaylist = 0; this.GeneratePlaylistData(this.currentPlaylist); if (this.playlist != null) { if (this.playlist.Count > 0) { this.activeSound = this.playlist[0]; } } else { SoundLib.LogWarning("SetActiveSoundType, playlist is null!"); } if (type == SoundProfileType.Sfx) { } }
public void SetMusicPanning(Single panning) { if (this.activeSound.SoundProfileType == SoundProfileType.Music) { SoundLib.SetMusicPanning(panning); } }
public void SetMusicVolume(Single volume) { if (this.activeSound.SoundProfileType == SoundProfileType.Music) { SoundLib.SetMusicVolume(volume); } }
public override void Load(SoundProfile profile, ISoundLoader.ResultCallback callback, SoundDatabase soundDatabase) { String text = AssetManagerUtil.GetStreamingAssetsPath() + "/Sounds/" + profile.ResourceID; SoundLib.Log("Load: " + text); FileInfo fileInfo = new FileInfo(text); Byte[] array = null; if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.IPhonePlayer) { array = File.ReadAllBytes(text); } else if (Application.platform == RuntimePlatform.Android) { } if (array != null) { IntPtr intPtr = Marshal.AllocHGlobal((Int32)fileInfo.Length); Marshal.Copy(array, 0, intPtr, (Int32)fileInfo.Length); Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); profile.AkbBin = intPtr; profile.BankID = bankID; } else { SoundLib.Log("akbBytes is null"); } callback(profile, soundDatabase); }
private void OnDestroy() { SoundLib.Log("Unload all sound resources"); SoundLib.UnloadAllSoundEffect(); SoundLib.UnloadMusic(); SoundLib.UnloadAllResidentSfxSoundData(); }
public Boolean IsSoundEffectPlaying(Int32 soundIndex) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; if (value.SoundIndex == soundIndex) { Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { return(true); } SoundLib.Log("soundID: " + soundID + " not found"); } } } SoundLib.Log("soundIndex: " + soundIndex + " not found in DB"); return(false); }
public void SetVolume(Single volume) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundID, volume, 0); SoundLib.Log("Set volume to soundID: " + soundID + " finished"); } else { SoundLib.Log("soundID: " + soundID + " not found"); } } } this.playerVolume = volume; }
public void OnDestroy() { if (this.movieMaterial != null) { this.movieMaterial.Destroy(); } SoundLib.UnloadMovieResources(); }
public void Resume() { this.Play(); if (this.getFirstFrame) { SoundLib.PlayMovieMusic(this.movieKey, 0); } }
private void changeScenePanel() { GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button("(<)", new GUILayoutOption[0])) { Int32 num = EventEngine.FindArrayIDFromEventID((Int32)this.FF9.fldMapNo); num--; if (num < 0) { num = EventEngine.testEventIDs.GetUpperBound(0); } this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num]; this.shutdownField(); SoundLib.StopAllSounds(); SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true); } this.stringToEdit = GUILayout.TextField(this.stringToEdit, new GUILayoutOption[] { GUILayout.Width(90f) }); if (GUILayout.Button("(>)", new GUILayoutOption[0])) { Int32 num2 = EventEngine.FindArrayIDFromEventID((Int32)this.FF9.fldMapNo); num2++; if (num2 > EventEngine.testEventIDs.GetUpperBound(0)) { num2 = 0; } this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num2]; this.shutdownField(); SoundLib.StopAllSounds(); SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button("Jump", new GUILayoutOption[0])) { Int32 num3; Int32.TryParse(this.stringToEdit, out num3); num3 = EventEngine.FindArrayIDFromEventID(num3); if (num3 == -1) { this.stringToEdit = this.FF9.fldMapNo.ToString(); return; } if (num3 < 0 || num3 > EventEngine.testEventIDs.GetUpperBound(0)) { num3 = 0; } this.FF9.fldMapNo = (Int16)EventEngine.testEventIDs[num3]; this.shutdownField(); SoundLib.StopAllSounds(); SceneDirector.Replace("FieldMap", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
public void LoadSfxSoundGroup(Int32 specialEffectID) { DateTime now = DateTime.Now; SoundLib.LoadSfxSoundData(specialEffectID); DateTime now2 = DateTime.Now; SoundLib.Log("Sound effect Loading time: " + (now2 - now).Milliseconds); }
public void ReloadSoundMetaData() { SoundMetaData.LoadMetaData(); this.ParseSoundList(); SoundLib.UnloadSoundEffect(); SoundLib.LoadGameSoundEffect(SoundMetaData.SoundEffectMetaData); SoundLib.UnloadMusic(); SoundLib.LoadMusic(SoundMetaData.MusicMetaData); }
private void BuildSfxSoundSelector() { Rect fullscreenRect = DebugGuiSkin.GetFullscreenRect(); GUILayout.BeginVertical(new GUILayoutOption[0]); this.soundSelectorScrollPosition = GUILayout.BeginScrollView(this.soundSelectorScrollPosition, new GUILayoutOption[] { GUILayout.Width(fullscreenRect.width * 2f / 3f), GUILayout.Height(fullscreenRect.height * 0.45f) }); if (this.sfxSoundUIState == 0) { foreach (Int32 num in this.soundViewController.AllSfxGroupSongIndex) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("EFX ID: " + num, new GUILayoutOption[0]); if (GUILayout.Button("Load", new GUILayoutOption[0])) { this.CurrentSpecialEffectID = num; this.sfxSoundUIState = 1; this.soundViewController.LoadSfxSoundGroup(num); } GUILayout.EndHorizontal(); } } else if (this.sfxSoundUIState == 1) { List <String> sfxSoundPlaylist = this.soundViewController.GetSfxSoundPlaylist(this.CurrentSpecialEffectID); GUILayout.BeginVertical(new GUILayoutOption[0]); if (GUILayout.Button("Back", new GUILayoutOption[0])) { this.sfxSoundUIState = 0; } for (Int32 i = 0; i < sfxSoundPlaylist.Count; i++) { if (i == SoundLib.GetResidentSfxSoundCount()) { GUILayout.Label("---- ---- ---- ----", new GUILayoutOption[0]); } String text = sfxSoundPlaylist[i]; GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label(text, new GUILayoutOption[0]); if (GUILayout.Button("Play", new GUILayoutOption[0])) { this.soundViewController.SelectSound(i); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } else { SoundLib.LogError("sfxSoundUIState is invalid: " + this.sfxSoundUIState); } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
public void Pause() { if (!this.hasStream) { throw new InvalidOperationException("[Movie.MovieMaterial.GLPlugin] Stream is not available"); } this.advance = false; SoundLib.PauseMovieMusic(this.movieKey); }
private void FinalizePlugin() { if (!this.m_isInitialized) { return; } SoundLib.Log("FinalizePlugin()"); ISdLibAPIProxy.Instance.SdSoundSystem_Release(); this.m_isInitialized = false; }
public void LoadMovie(String fileName) { this.MBGInitialized = (SByte)(this.MBGInitialized + 1); this.movieMaterial.Load(fileName); SoundLib.UnloadMovieResources(); SoundLib.LoadMovieResources("MovieAudio/", new String[] { fileName }); }
public static void ff9ShutdownStateBattleResult() { if ((FF9StateSystem.Common.FF9.btl_flag & 8) != 0) { return; } btlsnd.ff9btlsnd_song_vol_intplall(120, 0); SoundLib.GetAllSoundDispatchPlayer().StopCurrentSong(120); }
public void PlayMusic(String soundName, Int32 fadeIn = 0) { Int32 soundIndex = SoundMetaData.GetSoundIndex(soundName, SoundProfileType.MovieAudio); SoundLib.Log("PlayMuvieAudio movieName: " + soundName); if (soundIndex != -1) { base.PlayMusic(soundIndex, fadeIn, SoundProfileType.MovieAudio); } }