예제 #1
0
        /// <summary>
        /// Applied before these methods run.
        /// </summary>
        internal static bool Prefix()
        {
            var options = FastTrackOptions.Instance;

            return(!options.DisableSound && KPlayerPrefs.GetFloat(SoundUpdater.VOLUME_MUSIC,
                                                                  1.0f) > 0.0f && KPlayerPrefs.GetFloat(SoundUpdater.VOLUME_MASTER, 1.0f) > 0.0f);
        }
 public void StartUserVolumesSnapshot()
 {
     Start(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot);
     if (activeSnapshots.TryGetValue(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot, out EventInstance value))
     {
         value.getDescription(out EventDescription description);
         description.getUserProperty("buses", out USER_PROPERTY property);
         string   text  = property.stringValue();
         char     c     = '-';
         string[] array = text.Split(c);
         for (int i = 0; i < array.Length; i++)
         {
             float  busLevel = 1f;
             string key      = "Volume_" + array[i];
             if (KPlayerPrefs.HasKey(key))
             {
                 busLevel = KPlayerPrefs.GetFloat(key);
             }
             UserVolumeBus userVolumeBus = new UserVolumeBus();
             userVolumeBus.busLevel    = busLevel;
             userVolumeBus.labelString = Strings.Get("STRINGS.UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUDIO_BUS_" + array[i].ToUpper());
             userVolumeSettings.Add(array[i], userVolumeBus);
             SetUserVolume(array[i], userVolumeBus.busLevel);
         }
     }
 }
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        if (KPlayerPrefs.HasKey(UIScalePrefKey))
        {
            SetUserScale(KPlayerPrefs.GetFloat(UIScalePrefKey) / 100f);
        }
        else
        {
            SetUserScale(1f);
        }
        ScreenResize instance = ScreenResize.Instance;

        instance.OnResize = (System.Action)Delegate.Combine(instance.OnResize, new System.Action(OnResize));
    }
예제 #4
0
    private void PlayImpactSound(Vector3 pos)
    {
        if (impactSound == null)
        {
            impactSound = "Meteor_Large_Impact";
        }
        loopingSounds.StopSound(flyingSound);
        string sound = GlobalAssets.GetSound(impactSound, false);

        if (CameraController.Instance.IsAudibleSound(pos, sound))
        {
            EventInstance instance = KFMOD.BeginOneShot(sound, pos);
            instance.setParameterValue("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
            KFMOD.EndOneShot(instance);
        }
    }
예제 #5
0
 public void PlayDynamicMusic()
 {
     if (DynamicMusicIsActive())
     {
         Log("Trying to play DynamicMusic when it is already playing.");
     }
     else
     {
         string nextDynamicSong = GetNextDynamicSong();
         if (!(nextDynamicSong == "NONE"))
         {
             PlaySong(nextDynamicSong, false);
             if (activeSongs.TryGetValue(nextDynamicSong, out SongInfo value))
             {
                 activeDynamicSong = value;
                 AudioMixer.instance.Start(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot);
                 if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null && SpeedControlScreen.Instance.IsPaused)
                 {
                     SetDynamicMusicPaused();
                 }
                 if ((UnityEngine.Object)OverlayScreen.Instance != (UnityEngine.Object)null && OverlayScreen.Instance.mode != OverlayModes.None.ID)
                 {
                     SetDynamicMusicOverlayActive();
                 }
                 SetDynamicMusicPlayHook();
                 string key = "Volume_Music";
                 if (KPlayerPrefs.HasKey(key))
                 {
                     float @float = KPlayerPrefs.GetFloat(key);
                     AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "userVolume_Music", @float, true);
                 }
                 AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "intensity", value.sfxAttenuationPercentage / 100f, true);
             }
             else
             {
                 Log("DynamicMusic song " + nextDynamicSong + " did not start.");
                 string text = string.Empty;
                 foreach (KeyValuePair <string, SongInfo> activeSong in activeSongs)
                 {
                     text = text + activeSong.Key + ", ";
                     Debug.Log(text);
                 }
                 DebugUtil.DevAssert(false, "Song failed to play: " + nextDynamicSong);
             }
         }
     }
 }
        public void ShowExplosion(Comet comet)
        {
            var    position = comet.transform.GetPosition();
            string sound    = GlobalAssets.GetSound(comet.impactSound);

            if (CameraController.Instance.IsAudibleSound(position, sound))
            {
                EventInstance instance = KFMOD.BeginOneShot(sound, position);
                instance.setParameterByName("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
                KFMOD.EndOneShot(instance);
            }
            var fx_position = position;

            fx_position.z = Grid.GetLayerZ(Grid.SceneLayer.FXFront2);
            var cell = Grid.PosToCell(fx_position);

            if (SafeCell(cell))
            {
                Game.Instance.SpawnFX(comet.explosionEffectHash, fx_position, 0f);
            }
        }
예제 #7
0
        public void Render200ms(float dt)
        {
            if (KPlayerPrefs.GetFloat(VOLUME_MASTER, 1.0f) > 0.0f && !FastTrackOptions.
                Instance.DisableSound)
            {
#if false
                var lsm = LoopingSoundManager.Get();
                if (lsm != null)
                {
                    LoopingSoundManagerUpdater.RenderEveryTick(lsm, dt);
                }
#endif
                if (KPlayerPrefs.GetFloat(VOLUME_AMBIENCE, 1.0f) > 0.0f)
                {
                    StartCoroutine(RunAmbienceNextFrame());
                    runMix = true;
                }
                else
                {
                    runMix = false;
                }
            }
        }