override public float Run() { if (newVariableID != -1 && oldVariableID != -1) { GVar oldVar; if (oldLocation == VariableLocation.Global) { oldVar = GlobalVariables.GetVariable(oldVariableID); } else { oldVar = LocalVariables.GetVariable(oldVariableID, localVariables); } if (newLocation == VariableLocation.Local && !isAssetFile) { CopyVariable(LocalVariables.GetVariable(newVariableID, localVariables), oldVar); } else { GVar newVar = GlobalVariables.GetVariable(newVariableID); if (newVar != null) { CopyVariable(newVar, oldVar); newVar.Upload(); } } KickStarter.actionListManager.VariableChanged(); } return(0f); }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { 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 = RuntimeVariables.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); } }
/** * <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; } if (uiToggle != null) { isOn = uiToggle.isOn; } else { if (isOn) { isOn = false; } else { isOn = true; } } if (toggleType == AC_ToggleType.Subtitles) { Options.SetSubtitles(isOn); } 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(VariableLocation.Global); } } } if (toggleType == AC_ToggleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } base.ProcessClick(_menu, _slot, _mouseState); }
override public ActionEnd End(List <Action> actions) { if (numSockets <= 0) { ACDebug.LogWarning("Could not compute Random check because no values were possible!"); return(GenerateStopActionEnd()); } if (variableID == -1) { return(GenerateStopActionEnd()); } GVar var = null; if (location == VariableLocation.Local && !isAssetFile) { var = LocalVariables.GetVariable(variableID); } else { var = GlobalVariables.GetVariable(variableID); } if (var != null) { if (var.type == VariableType.Integer) { var.Download(); if (var.val < 1) { var.val = 1; } int originalValue = var.val - 1; var.val++; if (var.val > numSockets) { if (doLoop) { var.val = 1; } else { var.val = numSockets; } } var.Upload(); return(ProcessResult(originalValue, actions)); } else { ACDebug.LogWarning("Variable: Run sequence Action is referencing a Variable that does not exist!"); } } return(GenerateStopActionEnd()); }
public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return(false); } if (uiToggle) { isOn = uiToggle.isOn; } else { if (isOn) { isOn = false; } else { isOn = true; } } switch (toggleType) { case AC_ToggleType.Subtitles: Options.SetSubtitles(isOn); break; case AC_ToggleType.Variable: if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Boolean) { var.IntegerValue = (isOn) ? 1 : 0; var.Upload(VariableLocation.Global); } } break; case AC_ToggleType.CustomScript: MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); break; default: break; } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } return(base.ProcessClick(_menu, _slot, _mouseState)); }
override public float Run() { if (oldRuntimeVariable != null && newRuntimeVariable != null) { CopyVariable(newRuntimeVariable, oldRuntimeVariable); newRuntimeVariable.Upload(newLocation, newRuntimeVariables); } return(0f); }
/** * <summary>Sets the value of a global Vector3 variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new float value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetVector3Value(int _id, Vector3 _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { var.vector3Val = _value; if (synchronise) { var.Upload(); } } }
/** * <summary>Sets the value of a global Vector3 variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new float value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetVector3Value(int _id, Vector3 _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { var.SetVector3Value(_value); if (synchronise) { var.Upload(VariableLocation.Global); } } }
/** * <summary>Sets the value of a global Boolean variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new bool value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetBooleanValue(int _id, bool _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { var.SetValue((_value) ? 1 : 0); if (synchronise) { var.Upload(VariableLocation.Global); } } }
/** * <summary>Sets the value of a global Float variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new float value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetFloatValue(int _id, float _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { var.floatVal = _value; if (synchronise) { var.Upload(VariableLocation.Global); } } }
/** * <summary>Sets the value of a global String variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new string value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetStringValue(int _id, string _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { var.textVal = _value; if (synchronise) { var.Upload(); } } }
override public float Run() { if (runtimeObToRead != null) { if (runtimeVariable != null) { switch (transformRecordType) { case TransformRecordType.Position: if (transformLocation == GlobalLocal.Global) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.position); } else if (transformLocation == GlobalLocal.Local) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.localPosition); } break; case TransformRecordType.Rotation: if (transformLocation == GlobalLocal.Global) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.eulerAngles); } else if (transformLocation == GlobalLocal.Local) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.localEulerAngles); } break; case TransformRecordType.Scale: if (transformLocation == GlobalLocal.Global) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.lossyScale); } else if (transformLocation == GlobalLocal.Local) { runtimeVariable.SetVector3Value(runtimeObToRead.transform.localScale); } break; } runtimeVariable.Upload(variableLocation, runtimeVariables); } } return(0f); }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } base.ProcessClick(_menu, _slot, _mouseState); selected++; if (selected > optionsArray.Count - 1) { selected = 0; } if (cycleType == AC_CycleType.Language) { if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1) { // Ignore original text by skipping to first language selected = 1; } Options.SetLanguage(selected); } else if (cycleType == AC_CycleType.Variable) { if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Integer) { var.val = selected; var.Upload(); } } } if (cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } }
/** * <summary>Sets the value of a global Boolean variable.</summary> * <param name = "_id">The ID number of the variable</param> * <param name = "_value">The new bool value of the variable</param> * <param name = "synchronise">If True, then the variable's value will be synchronised with any external link it may have.</param> */ public static void SetBooleanValue(int _id, bool _value, bool synchronise = true) { GVar var = GetVariable(_id); if (var != null) { if (_value) { var.val = 1; } else { var.val = 0; } if (synchronise) { var.Upload(); } } }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } selected++; if (selected > optionsArray.Count - 1) { selected = 0; } if (cycleType == AC_CycleType.Language) { if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1) { // Ignore original text by skipping to first language selected = 1; } Options.SetLanguage(selected); } else if (cycleType == AC_CycleType.Variable) { if (varID >= 0) { GVar var = RuntimeVariables.GetVariable(varID); if (var.type == VariableType.Integer) { var.val = selected; var.Upload(); } } } if (cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } }
private void SetVariable(GVar newVar, VariableLocation _newLocation, GVar oldVar) { if (newVar == null || oldVar == null) { Debug.LogWarning("Cannot copy variable since it cannot be found!"); return; } if (oldLocation == VariableLocation.Global) { oldVar.Download(); } if (newVar.type == VariableType.Integer || newVar.type == VariableType.Boolean) { int oldValue = oldVar.val; newVar.SetValue(oldValue, SetVarMethod.SetValue); } else if (newVar.type == VariableType.Float) { float oldValue = oldVar.floatVal; newVar.SetValue(oldValue, AC.SetVarMethod.SetValue); } else if (newVar.type == VariableType.String) { string oldValue = oldVar.textVal; newVar.SetValue(oldValue); } if (_newLocation == VariableLocation.Global) { newVar.Upload(); } KickStarter.actionListManager.VariableChanged(); }
private void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } if (location == VariableLocation.Global) { var.Download (); } if (var.type == VariableType.Integer) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetInteger (parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue (); } var.SetValue (_value, setVarMethod); if (doSkip) { var.BackupValue (); } } if (var.type == VariableType.Float) { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetFloat (parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue (); } var.SetFloatValue (_value, setVarMethod); if (doSkip) { var.BackupValue (); } } else if (var.type == VariableType.Boolean) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int) boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { if (animator.GetBool (parameterName)) { _value = 1; } } } var.SetValue (_value, SetVarMethod.SetValue); } else if (var.type == VariableType.PopUp) { var.SetValue (intValue); } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens (stringValue); } else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText) { MenuElement menuElement = PlayerMenus.GetElementWithName (menuName, elementName); if (menuElement != null) { if (menuElement is MenuInput) { MenuInput menuInput = (MenuInput) menuElement; _value = menuInput.GetContents (); if ((Options.GetLanguageName () == "Arabic" || Options.GetLanguageName () == "Hebrew") && _value.Length > 0) { // Invert char[] charArray = _value.ToCharArray (); _value = ""; for (int i = charArray.Length-1; i >= 0; i --) { _value += charArray[i]; } } } else { PlayerMenus.GetMenuWithName (menuName).Recalculate (); menuElement.PreDisplay (slotNumber, Options.GetLanguage (), false); _value = menuElement.GetLabel (slotNumber, Options.GetLanguage ()); } } else { Debug.LogWarning ("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetStringValue (_value); } if (location == VariableLocation.Global) { var.Upload (); } KickStarter.actionListManager.VariableChanged (); }
private void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } if (location == VariableLocation.Global) { var.Download(); } if (var.type == VariableType.Integer) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetInteger(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } } if (var.type == VariableType.Float) { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetFloat(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } } else if (var.type == VariableType.Boolean) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int)boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { if (animator.GetBool(parameterName)) { _value = 1; } } } var.SetValue(_value, SetVarMethod.SetValue); } else if (var.type == VariableType.PopUp) { var.SetValue(intValue); } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue); } else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null) { if (menuElement is MenuInput) { MenuInput menuInput = (MenuInput)menuElement; _value = menuInput.GetContents(); if ((Options.GetLanguageName() == "Arabic" || Options.GetLanguageName() == "Hebrew") && _value.Length > 0) { // Invert char[] charArray = _value.ToCharArray(); _value = ""; for (int i = charArray.Length - 1; i >= 0; i--) { _value += charArray[i]; } } } else { PlayerMenus.GetMenuWithName(menuName).Recalculate(); menuElement.PreDisplay(slotNumber, Options.GetLanguage(), false); _value = menuElement.GetLabel(slotNumber, Options.GetLanguage()); } } else { Debug.LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetValue(_value); } if (location == VariableLocation.Global) { var.Upload(); } KickStarter.actionListManager.VariableChanged(); }
override public ActionEnd End(List <Action> actions) { if (numSockets <= 0) { ACDebug.LogWarning("Could not compute Random check because no values were possible!"); return(GenerateStopActionEnd()); } if (!saveToVariable) { int value = ownVarValue; ownVarValue++; if (ownVarValue >= numSockets) { if (doLoop) { ownVarValue = 0; } else { ownVarValue = numSockets - 1; } } return(ProcessResult(value, actions)); } if (variableID == -1) { return(GenerateStopActionEnd()); } if (runtimeVariable != null) { if (runtimeVariable.type == VariableType.Integer) { if (runtimeVariable.val < 1) { runtimeVariable.val = 1; } int originalValue = runtimeVariable.val - 1; runtimeVariable.val++; if (runtimeVariable.val > numSockets) { if (doLoop) { runtimeVariable.val = 1; } else { runtimeVariable.val = numSockets; } } runtimeVariable.Upload(location, runtimeVariables); return(ProcessResult(originalValue, actions)); } else { ACDebug.LogWarning("'Variable: Run sequence' Action is referencing a Variable that does not exist or is not an Integer!"); } } return(GenerateStopActionEnd()); }
protected void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } switch (var.type) { case VariableType.Integer: { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetInteger(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.Float: { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetFloat(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetFloatValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.Boolean: { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int)boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { if (animator.GetBool(parameterName)) { _value = 1; } } } var.SetValue(_value, SetVarMethod.SetValue); break; } case VariableType.Vector3: { Vector3 newValue = vector3Value; if (setVarMethodVector == SetVarMethodVector.IncreaseByValue) { newValue += var.vector3Val; } var.SetVector3Value(newValue); break; } case VariableType.PopUp: { int _value = 0; if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else if (setVarMethod == SetVarMethod.SetAsRandom) { _value = var.GetNumPopUpValues(); } else { _value = Mathf.Clamp(intValue, 0, var.GetNumPopUpValues() - 1); } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.String: { string _value = string.Empty; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue, Options.GetLanguage(), localVariables); } else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null) { if (menuElement is MenuInput) { MenuInput menuInput = (MenuInput)menuElement; _value = menuInput.GetContents(); if (KickStarter.runtimeLanguages.LanguageReadsRightToLeft(Options.GetLanguage()) && _value.Length > 0) { // Invert char[] charArray = _value.ToCharArray(); _value = ""; for (int i = charArray.Length - 1; i >= 0; i--) { _value += charArray[i]; } } } else { PlayerMenus.GetMenuWithName(menuName).Recalculate(); menuElement.PreDisplay(slotNumber, Options.GetLanguage(), false); _value = menuElement.GetLabel(slotNumber, Options.GetLanguage()); } } else { LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetStringValue(_value, lineID); break; } default: break; } var.Upload(location, runtimeVariables); KickStarter.actionListManager.VariableChanged(); }
private void SetVariable(GVar newVar, VariableLocation _newLocation, GVar oldVar) { if (newVar == null || oldVar == null) { ACDebug.LogWarning ("Cannot copy variable since it cannot be found!"); return; } if (oldLocation == VariableLocation.Global) { oldVar.Download (); } if (newVar.type == VariableType.Integer || newVar.type == VariableType.Boolean) { int oldValue = oldVar.val; newVar.SetValue (oldValue, SetVarMethod.SetValue); } else if (newVar.type == VariableType.Float) { float oldValue = oldVar.floatVal; newVar.SetFloatValue (oldValue, AC.SetVarMethod.SetValue); } else if (newVar.type == VariableType.String) { string oldValue = oldVar.textVal; newVar.SetStringValue (oldValue); } if (_newLocation == VariableLocation.Global) { newVar.Upload (); } KickStarter.actionListManager.VariableChanged (); }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } if (uiDropdown != null) { selected = uiDropdown.value; } else { CycleOption(); } if (cycleType == AC_CycleType.Language) { if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1) { // Ignore original text by skipping to first language selected = 1; } if (KickStarter.speechManager != null && KickStarter.speechManager.separateVoiceAndTextLanguages) { switch (splitLanguageType) { case SplitLanguageType.TextAndVoice: Options.SetLanguage(selected); Options.SetVoiceLanguage(selected); break; case SplitLanguageType.TextOnly: Options.SetLanguage(selected); break; case SplitLanguageType.VoiceOnly: Options.SetVoiceLanguage(selected); break; } } else { Options.SetLanguage(selected); } } else if (cycleType == AC_CycleType.Variable) { if (linkedVariable != null) { linkedVariable.IntegerValue = selected; linkedVariable.Upload(); } } if (cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } base.ProcessClick(_menu, _slot, _mouseState); }
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(); } } } }
private void SetVariable (GVar var, VariableLocation location) { if (var == null) { return; } if (location == VariableLocation.Global) { var.Download (); } if (var.type == VariableType.Integer) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetInteger (parameterName); setVarMethod = SetVarMethod.SetValue; } } var.SetValue (_value, setVarMethod); } if (var.type == VariableType.Float) { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetFloat (parameterName); setVarMethod = SetVarMethod.SetValue; } } var.SetValue (_value, setVarMethod); } else if (var.type == VariableType.Boolean) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int) boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { if (animator.GetBool (parameterName)) { _value = 1; } } } var.SetValue (_value, SetVarMethod.SetValue); } else if (var.type == VariableType.PopUp) { var.SetValue (intValue); } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens (stringValue); } else if (setVarMethodString == SetVarMethodString.SetAsMenuInputLabel) { if (PlayerMenus.GetElementWithName (menuName, elementName) != null) { MenuInput menuInput = (MenuInput) PlayerMenus.GetElementWithName (menuName, elementName); _value = menuInput.label; if ((Options.GetLanguageName () == "Arabic" || Options.GetLanguageName () == "Hebrew") && _value.Length > 0) { // Invert char[] charArray = _value.ToCharArray (); _value = ""; for (int i = charArray.Length-1; i >= 0; i --) { _value += charArray[i]; } } } else { Debug.LogWarning ("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetValue (_value); } if (location == VariableLocation.Global) { var.Upload (); } GameObject.FindWithTag (Tags.gameEngine).GetComponent <ActionListManager>().VariableChanged (); }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } #if UNITY_5_3_OR_NEWER if (uiDropdown != null) { selected = uiDropdown.value; } else { selected++; if (selected > optionsArray.Count - 1) { selected = 0; } } #else selected++; if (selected > optionsArray.Count - 1) { selected = 0; } #endif if (cycleType == AC_CycleType.Language) { if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1) { // Ignore original text by skipping to first language selected = 1; } if (KickStarter.speechManager != null && KickStarter.speechManager.separateVoiceAndTextLanguages) { switch (splitLanguageType) { case SplitLanguageType.TextAndVoice: Options.SetLanguage(selected); Options.SetVoiceLanguage(selected); break; case SplitLanguageType.TextOnly: Options.SetLanguage(selected); break; case SplitLanguageType.VoiceOnly: Options.SetVoiceLanguage(selected); break; } } else { Options.SetLanguage(selected); } } else if (cycleType == AC_CycleType.Variable) { if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Integer) { var.val = selected; var.Upload(VariableLocation.Global); } } } if (cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } base.ProcessClick(_menu, _slot, _mouseState); }
private void SetVariable (GVar newVar, VariableLocation _newLocation, GVar oldVar) { if (newVar == null || oldVar == null) { return; } if (oldLocation == VariableLocation.Global) { oldVar.Download (); } if (newVar.type == VariableType.Integer || newVar.type == VariableType.Boolean) { int oldValue = oldVar.val; newVar.SetValue (oldValue, SetVarMethod.SetValue); } else if (newVar.type == VariableType.Float) { float oldValue = oldVar.floatVal; newVar.SetValue (oldValue, AC.SetVarMethod.SetValue); } else if (newVar.type == VariableType.String) { string oldValue = oldVar.textVal; newVar.SetValue (oldValue); } if (_newLocation == VariableLocation.Global) { newVar.Upload (); } GameObject.FindWithTag (Tags.gameEngine).GetComponent <ActionListManager>().VariableChanged (); }