Exemplo n.º 1
0
        public static void PlayMusic(string musicName, bool loop = true, float fadeInTime = 0f)
        {
            if (!MgrData.GetBool(MgrData.appSettingsName, "XLAF.music", true))
            {
                return;
            }
            if (musicName.IndexOf(".") < 0)
            {
                XLAFInnerLog.Warning("You must use musicName's extension, for example \"click.mp3\"");
                return;
            }
            AudioClip clip = Resources.Load <AudioClip> (_GetAudioSource(musicName.Split(new char[] { '.' }) [0]));

            musicSource.loop = loop;
            musicSource.clip = clip;
            musicSource.Play();
            if (fadeInTime <= 0f)
            {
                musicSource.volume = maxMusicVolume;
            }
            else
            {
                _FadeInOutVolume(musicSource, fadeInTime, 0, maxMusicVolume);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Plaies the sound.
 /// </summary>
 /// <param name="soundName">Sound name. (with ext  e.g. click.mp3)</param>
 /// <param name="valume">Valume.</param>
 public static void PlaySound(string soundName, float valume)
 {
     if (!MgrData.GetBool(MgrData.appSettingsName, "XLAF.sound", true))
     {
         return;
     }
     if (soundName.IndexOf(".") < 0)
     {
         XLAFInnerLog.Warning("You must use soundName's extension, for example \"click.mp3\"");
         return;
     }
                 #if UNITY_ANDROID && !UNITY_EDITOR
     int soundId = 0;
     if (androidSoundIds.TryGetValue(soundName, out soundId))
     {
         audioCenter.Call("PlaySound", soundId, valume);
     }
                 #else
     AudioClip clip = Resources.Load <AudioClip> (_GetAudioSource(soundName.Split(new char[] { '.' }) [0]));
     if (clip != null)
     {
         soundSource.volume = valume;
         soundSource.PlayOneShot(clip);
     }
                 #endif
 }
Exemplo n.º 3
0
        static Log()
        {
            debug_file = ModUtils.documentsDirectory + "/debug.log";
            error_file = ModUtils.documentsDirectory + "/error.log";
            int level = MgrData.GetInt(MgrData.sysSettingsName, "XLAF.debug", 0);

            SetDebugLevel(level);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the debug level.<para></para>
 /// e.g. <para></para>
 /// set 0xF to enable all log;<para></para>
 /// set 0x0 to close all log; <para></para>
 /// set 0xE means Error closed and others opened.
 /// </summary>
 /// <param name="level">Level, after convert to binary, each byte means isWarnOn,isInfoOn,isDebugOn,isErrorOn</param>
 public static void SetDebugLevel(int level)
 {
     MgrData.Set(MgrData.sysSettingsName, "XLAF.debug", level);
     _isErrorOn = _GetByteInfo(level, 0) == 1;
     _isDebugOn = _GetByteInfo(level, 1) == 1;
     _isInfoOn  = _GetByteInfo(level, 2) == 1;
     _isWarnOn  = _GetByteInfo(level, 3) == 1;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Switchs the language.<para></para>
 /// this will call <code>Scenes or Popup 's UpdateLanguage()</code>
 /// </summary>
 /// <param name="lang">Language json filename (without extension) in Resources/Lang/ or xxxx.assetBundle 's Lang folder. </param>
 public static void SwitchLanguage(string lang)
 {
     currentLanguage = lang;
     MgrData.Set(MgrData.appSettingsName, "XLAF.language", lang);
     Load();
     foreach (KeyValuePair <string, SceneObject> kv in MgrScene.GetAllScenes())
     {
         kv.Value.script.UpdateLanguage();
     }
     foreach (KeyValuePair <string, SceneObject> kv in MgrPopup.GetAllPopups())
     {
         kv.Value.script.UpdateLanguage();
     }
 }
Exemplo n.º 6
0
 public static void SwitchSound(bool isSoundOn)
 {
     MgrData.Set(MgrData.appSettingsName, "XLAF.sound", isSoundOn);
 }
Exemplo n.º 7
0
 public static void SwitchMusic(bool isMusicOn)
 {
     MgrData.Set(MgrData.appSettingsName, "XLAF.music", isMusicOn);
 }
Exemplo n.º 8
0
 static MgrMultiLanguage()
 {
     currentLanguage = MgrData.GetString(MgrData.appSettingsName, "XLAF.language", DEFAULT_LANGUAGE);
     XLAFInnerLog.Debug("currentLanguage", currentLanguage);
     Load();
 }