Ejemplo n.º 1
0
        /**
         * <summary>Recalculates the element's size.
         * This should be called whenever a Menu's shape is changed.</summary>
         * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (!_menu.IsClickable())
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);
            if (uiToggle != null)
            {
                isOn = uiToggle.isOn;
            }
            else
            {
                if (isOn)
                {
                    isOn = false;
                }
                else
                {
                    isOn = true;
                }
            }

            if (toggleType == AC_ToggleType.Subtitles)
            {
                Options.optionsData.showSubtitles = isOn;
                Options.SavePrefs();
            }
            else if (toggleType == AC_ToggleType.Variable)
            {
                if (varID >= 0)
                {
                    GVar var = GlobalVariables.GetVariable(varID);
                    if (var.type == VariableType.Boolean)
                    {
                        if (isOn)
                        {
                            var.val = 1;
                        }
                        else
                        {
                            var.val = 0;
                        }
                        var.Upload();
                    }
                }
            }

            if (toggleType == AC_ToggleType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }

            if (actionListOnClick)
            {
                AdvGame.RunActionListAsset(actionListOnClick);
            }
        }
Ejemplo n.º 2
0
        /**
         * <summary>Sets the value of its linked variable to its value (if appropriate).</summary>
         * <param name = "_location">The variable's location</param>
         * <param name = "_variables">The variable's Variables component, if location = VariableLocation.Component</param>
         */
        public void Upload(VariableLocation _location = VariableLocation.Global, Variables _variables = null)
        {
            if (_location == VariableLocation.Local)
            {
                return;
            }

            if (link == VarLink.PlaymakerVariable && !string.IsNullOrEmpty(pmVar))
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (_location != VariableLocation.Component)
                {
                    _variables = null;
                }
                if (_location == VariableLocation.Component && _variables == null)
                {
                    return;
                }

                switch (type)
                {
                case VariableType.Integer:
                case VariableType.PopUp:
                    PlayMakerIntegration.SetInt(pmVar, val, _variables);
                    break;

                case VariableType.Boolean:
                    PlayMakerIntegration.SetBool(pmVar, (val == 1), _variables);
                    break;

                case VariableType.String:
                    PlayMakerIntegration.SetString(pmVar, textVal, _variables);
                    break;

                case VariableType.Float:
                    PlayMakerIntegration.SetFloat(pmVar, floatVal, _variables);
                    break;

                case VariableType.Vector3:
                    PlayMakerIntegration.SetVector3(pmVar, vector3Val, _variables);
                    break;
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnUploadVariable(this, _variables);
            }
        }
Ejemplo n.º 3
0
 /**
  * <summary>Changes the currently-selected language.</summary>
  * <param name = "i">The language's index number in SpeechManager</param>
  */
 public static void SetLanguage(int i)
 {
     if (Options.optionsData != null)
     {
         Options.optionsData.language = i;
         Options.SavePrefs();
     }
     else
     {
         ACDebug.LogWarning("Could not find Options data!");
     }
 }
Ejemplo n.º 4
0
        /**
         * <summary>Changes the subtitle display setting.</summary>
         * <param name = "showSubtitles">If True, subtitles will be shown</param>
         */
        public static void SetSubtitles(bool showSubtitles)
        {
            if (Options.optionsData != null)
            {
                Options.optionsData.showSubtitles = showSubtitles;
                Options.SavePrefs();

                KickStarter.eventManager.Call_OnChangeSubtitles(showSubtitles);
            }
            else
            {
                ACDebug.LogWarning("Could not find Options data!");
            }
        }
Ejemplo n.º 5
0
        /**
         * <summary>Changes the currently-selected language.</summary>
         * <param name = "i">The language's index number in SpeechManager</param>
         */
        public static void SetLanguage(int i)
        {
            if (Options.optionsData != null)
            {
                Options.optionsData.language = i;
                Options.SavePrefs();

                KickStarter.eventManager.Call_OnChangeLanguage(i);
            }
            else
            {
                ACDebug.LogWarning("Could not find Options data!");
            }
        }
Ejemplo n.º 6
0
        /**
         * Sets the value of its linked Options Data or PlayMaker variable to its value (if appropriate).
         */
        public void Upload()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    PlayMakerIntegration.SetGlobalInt(pmVar, val);
                }
                else if (type == VariableType.Boolean)
                {
                    if (val == 1)
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, true);
                    }
                    else
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, false);
                    }
                }
                else if (type == VariableType.String)
                {
                    PlayMakerIntegration.SetGlobalString(pmVar, textVal);
                }
                else if (type == VariableType.Float)
                {
                    PlayMakerIntegration.SetGlobalFloat(pmVar, floatVal);
                }
                else if (type == VariableType.Vector3)
                {
                    PlayMakerIntegration.SetGlobalVector3(pmVar, vector3Val);
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnUploadVariable(this);
            }
        }
Ejemplo n.º 7
0
        /**
         * <summary>Changes the currently-selected voice language. If voice and text languages are synced, the text language will be set to this as well.</summary>
         * <param name = "i">The language's index number in SpeechManager</param>
         */
        public static void SetVoiceLanguage(int i)
        {
            if (KickStarter.speechManager == null || !KickStarter.speechManager.separateVoiceAndTextLanguages)
            {
                SetLanguage(i);
                return;
            }

            if (Options.optionsData != null)
            {
                Options.optionsData.voiceLanguage = i;
                Options.SavePrefs();

                KickStarter.eventManager.Call_OnChangeVoiceLanguage(i);
                KickStarter.runtimeLanguages.LoadAssetBundle(i);
            }
            else
            {
                ACDebug.LogWarning("Could not find Options data!");
            }
        }
Ejemplo n.º 8
0
        /**
         * <summary>Updates the volume of all Sound object of a specific SoundType to their correct values.</summary>
         * <param name = "_soundType">The SoundType that matches the Sound objects to update (Music, SFX, Other)</param>
         * <param name = "newVolume">If >= 0, the OptionsData will be updated as well</param>
         */
        public void SetVolume(SoundType _soundType, float newVolume = -1f)
        {
            if (newVolume >= 0f)
            {
                if (Options.optionsData != null)
                {
                    if (_soundType == SoundType.Music)
                    {
                        Options.optionsData.musicVolume = newVolume;
                    }
                    else if (_soundType == SoundType.SFX)
                    {
                        Options.optionsData.sfxVolume = newVolume;
                    }
                    else if (_soundType == SoundType.Speech)
                    {
                        Options.optionsData.speechVolume = newVolume;
                    }

                    Options.SavePrefs();

                    KickStarter.eventManager.Call_OnChangeVolume(_soundType, newVolume);
                }
                else
                {
                    ACDebug.LogWarning("Could not find Options data!");
                }
            }

            Sound[] soundObs = FindObjectsOfType(typeof(Sound)) as Sound[];
            foreach (Sound soundOb in soundObs)
            {
                if (soundOb.soundType == _soundType)
                {
                    soundOb.AfterLoading();
                }
            }

            KickStarter.dialog.UpdateSpeechVolumes();
        }
Ejemplo n.º 9
0
        /**
         * Sets the value of its linked Options Data or PlayMaker variable to its value (if appropriate).
         */
        public void Upload()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    PlayMakerIntegration.SetGlobalInt(pmVar, val);
                }
                else if (type == VariableType.Boolean)
                {
                    if (val == 1)
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, true);
                    }
                    else
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, false);
                    }
                }
                else if (type == VariableType.String)
                {
                    PlayMakerIntegration.SetGlobalString(pmVar, textVal);
                }
                else if (type == VariableType.Float)
                {
                    PlayMakerIntegration.SetGlobalFloat(pmVar, floatVal);
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
        }
Ejemplo n.º 10
0
        private void UpdateValue()
        {
            if (uiSlider == null)
            {
                visualAmount = Mathf.Clamp(visualAmount, 0f, 1f);

                // Limit by steps
                if (numberOfSteps > 0)
                {
                    visualAmount = Mathf.Round(visualAmount * numberOfSteps) / numberOfSteps;
                }

                amount = (visualAmount * (maxValue - minValue)) + minValue;
            }
            else
            {
                amount = visualAmount;
            }

            if (sliderType == AC_SliderType.Speech || sliderType == AC_SliderType.SFX || sliderType == AC_SliderType.Music)
            {
                if (Options.optionsData != null)
                {
                    if (sliderType == AC_SliderType.Speech)
                    {
                        Options.optionsData.speechVolume = amount;
                        KickStarter.options.SetVolume(SoundType.SFX);
                    }
                    else if (sliderType == AC_SliderType.Music)
                    {
                        Options.optionsData.musicVolume = amount;
                        KickStarter.options.SetVolume(SoundType.Music);
                    }
                    else if (sliderType == AC_SliderType.SFX)
                    {
                        Options.optionsData.sfxVolume = amount;
                        KickStarter.options.SetVolume(SoundType.SFX);
                    }

                                        #if UNITY_5
                    if (sliderType == AC_SliderType.Speech)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.speechMixerGroup, KickStarter.settingsManager.speechAttentuationParameter, amount);
                    }
                    else if (sliderType == AC_SliderType.Music)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.musicMixerGroup, KickStarter.settingsManager.musicAttentuationParameter, amount);
                    }
                    else if (sliderType == AC_SliderType.SFX)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.sfxMixerGroup, KickStarter.settingsManager.sfxAttentuationParameter, amount);
                    }
                                        #endif

                    Options.SavePrefs();
                }
                else
                {
                    ACDebug.LogWarning("Could not find Options data!");
                }
            }
            else if (sliderType == AC_SliderType.FloatVariable)
            {
                if (varID >= 0)
                {
                    GVar var = GlobalVariables.GetVariable(varID);
                    if (var.type == VariableType.Float)
                    {
                        var.SetFloatValue(amount);
                    }
                }
            }

            if (!KickStarter.actionListAssetManager.IsListRunning(actionListOnChange))
            {
                AdvGame.RunActionListAsset(actionListOnChange);
            }
        }
Ejemplo n.º 11
0
        private void UpdateValue()
        {
            if (uiSlider == null)
            {
                if (amount < 0f)
                {
                    amount = 0;
                }
                else if (amount > 1f)
                {
                    amount = 1f;
                }

                // Limit by steps
                if (numberOfSteps > 0)
                {
                    float valueSeparation = 1f / (float)numberOfSteps;
                    float nearestValue    = 0f;
                    while (nearestValue < amount)
                    {
                        nearestValue += valueSeparation;
                    }

                    // Now larger than amount, so which is closer?
                    float lowerNearest = nearestValue - valueSeparation;
                    if (amount - lowerNearest > nearestValue - amount)
                    {
                        amount = nearestValue;
                    }
                    else
                    {
                        amount = lowerNearest;
                    }
                }
            }

            if (sliderType == AC_SliderType.Speech || sliderType == AC_SliderType.SFX || sliderType == AC_SliderType.Music)
            {
                if (Options.optionsData != null)
                {
                    if (sliderType == AC_SliderType.Speech)
                    {
                        Options.optionsData.speechVolume = amount;
                    }
                    else if (sliderType == AC_SliderType.Music)
                    {
                        Options.optionsData.musicVolume = amount;
                        KickStarter.options.SetVolume(SoundType.Music);
                    }
                    else if (sliderType == AC_SliderType.SFX)
                    {
                        Options.optionsData.sfxVolume = amount;
                        KickStarter.options.SetVolume(SoundType.SFX);
                    }

                                        #if UNITY_5
                    if (sliderType == AC_SliderType.Speech)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.speechMixerGroup, KickStarter.settingsManager.speechAttentuationParameter, amount);
                    }
                    else if (sliderType == AC_SliderType.Music)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.musicMixerGroup, KickStarter.settingsManager.musicAttentuationParameter, amount);
                    }
                    else if (sliderType == AC_SliderType.SFX)
                    {
                        AdvGame.SetMixerVolume(KickStarter.settingsManager.sfxMixerGroup, KickStarter.settingsManager.sfxAttentuationParameter, amount);
                    }
                                        #endif

                    Options.SavePrefs();
                }
                else
                {
                    Debug.LogWarning("Could not find Options data!");
                }
            }
            else if (sliderType == AC_SliderType.FloatVariable)
            {
                if (varID >= 0)
                {
                    GVar var = RuntimeVariables.GetVariable(varID);
                    if (var.type == VariableType.Float)
                    {
                        var.floatVal = amount;
                        var.Upload();
                    }
                }
            }
        }