예제 #1
0
		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 ();
		}
예제 #2
0
 /**
  * <summary>The default Constructor.</summary>
  * <param name = "_gVar">The variable that this is a preset for</param>
  */
 public PresetValue(GVar _gVar)
 {
     id = _gVar.id;
     val = _gVar.val;
     floatVal = _gVar.floatVal;
     textVal = _gVar.textVal;
 }
예제 #3
0
		public GVar (GVar assetVar)
		{
			// Duplicates Asset to Runtime instance
			// (Do it the long way to ensure no connections remain to the asset file)
			
			val = assetVar.val;
			floatVal = assetVar.floatVal;
			textVal = assetVar.textVal;
			type = assetVar.type;
			id = assetVar.id;
			label = assetVar.label;
			link = assetVar.link;
			pmVar = assetVar.pmVar;
			popUps = assetVar.popUps;
			updateLinkOnStart = assetVar.updateLinkOnStart;
		}
예제 #4
0
        /**
         * <summary>Ensure the List of PresetValues contains a preset for a supplied variable.</summary>
         * <param name = "_vars">The variable to create a preset for</param>
         */
        public void UpdateCollection(GVar _var)
        {
            bool foundMatch = false;

            foreach (PresetValue presetValue in presetValues)
            {
                if (presetValue.id == _var.id)
                {
                    foundMatch = true;
                    break;
                }
            }

            if (!foundMatch)
            {
                presetValues.Add (new PresetValue (_var));
            }
        }
예제 #5
0
        /**
         * <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);

                        #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;
                }
                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);
            }
        }
예제 #6
0
        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 ();
        }
예제 #7
0
        private void SideMenu(GVar _var, List<GVar> _vars, VariableLocation location)
        {
            GenericMenu menu = new GenericMenu ();
            sideVar = _vars.IndexOf (_var);
            sideVarLocation = location;

            menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
            if (_vars.Count > 0)
            {
                menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
            }
            if (sideVar > 0 || sideVar < _vars.Count-1)
            {
                menu.AddSeparator ("");
            }
            if (sideVar > 0)
            {
                menu.AddItem (new GUIContent ("Move up"), false, Callback, "Move up");
            }
            if (sideVar < _vars.Count-1)
            {
                menu.AddItem (new GUIContent ("Move down"), false, Callback, "Move down");
            }

            menu.ShowAsContext ();
        }
예제 #8
0
        private void SetTab(int tab)
        {
            showGlobal = false;
            showLocal = false;
            selectedVar = null;

            if (tab == 0)
            {
                showGlobal = true;
            }
            else if (tab == 1)
            {
                showLocal = true;
            }
        }
예제 #9
0
        public override float Run()
        {
            string newSaveLabel = string.Empty;

            if (manageSaveType == ManageSaveType.RenameSave)
            {
                GVar gVar = GlobalVariables.GetVariable(varID);
                if (gVar != null)
                {
                    newSaveLabel = gVar.TextValue;
                }
                else
                {
                    LogWarning("Could not " + manageSaveType.ToString() + " - no variable found.");
                    return(0f);
                }
            }

            int i = Mathf.Max(0, saveIndex);

            if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
            {
                GVar gVar = GlobalVariables.GetVariable(slotVarID);
                if (gVar != null)
                {
                    i = gVar.IntegerValue;
                }
                else
                {
                    LogWarning("Could not rename save - no variable found.");
                    return(0f);
                }
            }
            else if (selectSaveType == SelectSaveType.Autosave)
            {
                if (manageSaveType == ManageSaveType.DeleteSave)
                {
                    SaveSystem.DeleteSave(0);
                    return(0f);
                }
                else if (manageSaveType == ManageSaveType.RenameSave)
                {
                    LogWarning("The Autosave file cannot be renamed.");
                    return(0f);
                }
            }

            if (selectSaveType != SelectSaveType.Autosave && selectSaveType != SelectSaveType.SetSaveID)
            {
                if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName))
                {
                    MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                    if (menuElement != null && menuElement is MenuSavesList)
                    {
                        MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                        i += menuSavesList.GetOffset();
                    }
                    else
                    {
                        LogWarning("Cannot find SavesList element '" + elementName + "' in Menu '" + menuName + "'.");
                    }
                }
                else
                {
                    LogWarning("No SavesList element referenced when trying to find save slot " + i.ToString());
                }
            }

            if (manageSaveType == ManageSaveType.DeleteSave)
            {
                if (selectSaveType == SelectSaveType.SetSaveID)
                {
                    SaveSystem.DeleteSave(i);
                }
                else
                {
                    KickStarter.saveSystem.DeleteSave(i, -1, false);
                }
            }
            else if (manageSaveType == ManageSaveType.RenameSave)
            {
                if (selectSaveType == SelectSaveType.SetSaveID)
                {
                    KickStarter.saveSystem.RenameSaveByID(newSaveLabel, i);
                }
                else
                {
                    KickStarter.saveSystem.RenameSave(newSaveLabel, i);
                }
            }

            return(0f);
        }
예제 #10
0
        private bool CheckCondition(InvItem _compareItem, GVar _compareVar)
        {
            if (_parameter == null)
            {
                Debug.LogWarning("Cannot check state of variable since it cannot be found!");
                return(false);
            }

            if (_parameter.parameterType == ParameterType.Boolean)
            {
                int fieldValue   = _parameter.intValue;
                int compareValue = (int)boolValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Integer)
            {
                int fieldValue   = _parameter.intValue;
                int compareValue = intValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Float)
            {
                float fieldValue   = _parameter.floatValue;
                float compareValue = floatValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.floatVal;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return(true);
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.String)
            {
                string fieldValue   = _parameter.stringValue;
                string compareValue = AdvGame.ConvertTokens(stringValue);
                if (_compareVar != null)
                {
                    compareValue = _compareVar.textVal;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return(true);
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.GameObject)
            {
                if ((compareObject != null && _parameter.gameObject == compareObject) ||
                    (compareObjectConstantID != 0 && _parameter.intValue == compareObjectConstantID))
                {
                    return(true);
                }
            }

            else if (_parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.LocalVariable)
            {
                if (_compareVar != null && _parameter.intValue == _compareVar.id)
                {
                    return(true);
                }
            }

            else if (_parameter.parameterType == ParameterType.InventoryItem)
            {
                if (_compareItem != null && _parameter.intValue == _compareItem.id)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #11
0
        protected void PerformSaveOrLoad()
        {
            ClearAllEvents();

            if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame)
            {
                EventManager.OnFinishLoading += OnFinishLoading;
                EventManager.OnFailLoading   += OnFail;
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                EventManager.OnFinishSaving += OnFinishSaving;
                EventManager.OnFailSaving   += OnFail;
            }

            if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad)
            {
                KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad);
            }

            string newSaveLabel = "";

            if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame))
            {
                if (selectSaveType != SelectSaveType.Autosave)
                {
                    GVar gVar = GlobalVariables.GetVariable(varID);
                    if (gVar != null)
                    {
                        newSaveLabel = gVar.GetValue(Options.GetLanguage());
                    }
                    else
                    {
                        LogWarning("Could not " + saveHandling.ToString() + " - no variable found.");
                        return;
                    }
                }
            }

            int i = Mathf.Max(0, saveIndex);

            if (saveHandling == SaveHandling.ContinueFromLastSave)
            {
                SaveSystem.ContinueGame();
                return;
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                if (selectSaveType == SelectSaveType.Autosave)
                {
                    if (saveHandling == SaveHandling.LoadGame)
                    {
                        SaveSystem.LoadAutoSave();
                        return;
                    }
                    else
                    {
                        if (PlayerMenus.IsSavingLocked(this, true))
                        {
                            OnComplete();
                        }
                        else
                        {
                            SaveSystem.SaveAutoSave();
                        }
                        return;
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.IntegerValue;
                    }
                    else
                    {
                        LogWarning("Could not get save slot index - no variable found.");
                        return;
                    }
                }
            }

            if (selectSaveType != SelectSaveType.Autosave && selectSaveType != SelectSaveType.SetSaveID)
            {
                if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName))
                {
                    MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                    if (menuElement != null && menuElement is MenuSavesList)
                    {
                        MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                        i += menuSavesList.GetOffset();
                    }
                    else
                    {
                        LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                    }
                }
                else
                {
                    LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString());
                }
            }

            if (saveHandling == SaveHandling.LoadGame)
            {
                if (selectSaveType == SelectSaveType.SetSaveID)
                {
                    SaveSystem.LoadGame(i);
                }
                else
                {
                    SaveSystem.LoadGame(i, -1, false);
                }
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                if (PlayerMenus.IsSavingLocked(this, true))
                {
                    OnComplete();
                }
                else
                {
                    if (saveHandling == SaveHandling.OverwriteExistingSave)
                    {
                        if (selectSaveType == SelectSaveType.SetSaveID)
                        {
                            SaveSystem.SaveGame(0, i, true, updateLabel, newSaveLabel);
                        }
                        else
                        {
                            SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel);
                        }
                    }
                    else if (saveHandling == SaveHandling.SaveNewGame)
                    {
                        SaveSystem.SaveNewGame(updateLabel, newSaveLabel);
                    }
                }
            }
        }
        override public float Run()
        {
            if (!KickStarter.settingsManager.useProfiles)
            {
                ACDebug.LogWarning("Save game profiles are not enabled - please set in Settings Manager to use this Action.");
                return(0f);
            }

            string newProfileLabel = "";

            if ((manageProfileType == ManageProfileType.CreateProfile && useCustomLabel) || manageProfileType == ManageProfileType.RenameProfile)
            {
                GVar gVar = GlobalVariables.GetVariable(varID);
                if (gVar != null)
                {
                    newProfileLabel = gVar.textVal;
                }
                else
                {
                    ACDebug.LogWarning("Could not " + manageProfileType.ToString() + " - no variable found.");
                    return(0f);
                }
            }

            if (manageProfileType == ManageProfileType.CreateProfile)
            {
                KickStarter.options.CreateProfile(newProfileLabel);
            }
            else if (manageProfileType == ManageProfileType.DeleteProfile || manageProfileType == ManageProfileType.RenameProfile)
            {
                if (deleteProfileType == DeleteProfileType.ActiveProfile)
                {
                    if (manageProfileType == ManageProfileType.DeleteProfile)
                    {
                        KickStarter.saveSystem.DeleteProfile();
                        return(0f);
                    }
                    else
                    {
                        KickStarter.options.RenameProfile(newProfileLabel);
                        return(0f);
                    }
                }

                int i = Mathf.Max(0, profileIndex);

                if (deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.val;
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not create profile - no variable found.");
                        return(0f);
                    }
                }

                bool includeActive = true;
                if (menuName != "" && elementName != "")
                {
                    MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                    if (menuElement != null && menuElement is MenuProfilesList)
                    {
                        MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement;
                        i            += menuProfilesList.GetOffset();
                        includeActive = menuProfilesList.showActive;
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                    }
                }
                else
                {
                    ACDebug.LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString());
                }

                if (manageProfileType == ManageProfileType.DeleteProfile)
                {
                    KickStarter.saveSystem.DeleteProfile(i, includeActive);
                }
                else
                {
                    KickStarter.options.RenameProfile(newProfileLabel, i, includeActive);
                }
            }

            return(0f);
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (AdvGame.GetReferences().settingsManager != null && !AdvGame.GetReferences().settingsManager.useProfiles)
            {
                EditorGUILayout.HelpBox("Save game profiles are not enabled - please set in Settings Manager to use this Action.", MessageType.Warning);
                AfterRunningOption();
                return;
            }

            manageProfileType = (ManageProfileType)EditorGUILayout.EnumPopup("Method:", manageProfileType);

            if (manageProfileType == ManageProfileType.CreateProfile)
            {
                useCustomLabel = EditorGUILayout.Toggle("Use custom label?", useCustomLabel);
            }

            if ((manageProfileType == ManageProfileType.CreateProfile && useCustomLabel) || manageProfileType == AC.ManageProfileType.RenameProfile)
            {
                varID = AdvGame.GlobalVariableGUI("Label as String variable:", varID);
                if (varID >= 0 && AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager)
                {
                    GVar _var = AdvGame.GetReferences().variablesManager.GetVariable(varID);
                    if (_var != null && _var.type != VariableType.String)
                    {
                        EditorGUILayout.HelpBox("The chosen Variable must be a String.", MessageType.Warning);
                    }
                }
            }

            if (manageProfileType == ManageProfileType.DeleteProfile || manageProfileType == ManageProfileType.RenameProfile)
            {
                string _action = "delete";
                if (manageProfileType == ManageProfileType.RenameProfile)
                {
                    _action = "rename";
                }

                deleteProfileType = (DeleteProfileType)EditorGUILayout.EnumPopup("Profile to " + _action + ":", deleteProfileType);
                if (deleteProfileType == DeleteProfileType.SetSlotIndex)
                {
                    profileIndexParameterID = Action.ChooseParameterGUI("Slot index to " + _action + ":", parameters, profileIndexParameterID, ParameterType.Integer);
                    if (profileIndexParameterID == -1)
                    {
                        profileIndex = EditorGUILayout.IntField("Slot index to " + _action + ":", profileIndex);
                    }
                }
                else if (deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                {
                    slotVarID = AdvGame.GlobalVariableGUI("Integer variable:", slotVarID);
                    if (slotVarID >= 0 && AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager)
                    {
                        GVar _var = AdvGame.GetReferences().variablesManager.GetVariable(slotVarID);
                        if (_var != null && _var.type != VariableType.Integer)
                        {
                            EditorGUILayout.HelpBox("The chosen Variable must be an Integer.", MessageType.Warning);
                        }
                    }
                }

                if (deleteProfileType != DeleteProfileType.ActiveProfile)
                {
                    EditorGUILayout.Space();
                    menuName    = EditorGUILayout.TextField("Menu with ProfilesList:", menuName);
                    elementName = EditorGUILayout.TextField("ProfilesList element:", elementName);
                }
            }

            AfterRunningOption();
        }
예제 #14
0
 private void ActivateVar(GVar var)
 {
     var.isEditing = true;
     selectedVar   = var;
 }
예제 #15
0
        private bool CheckCondition(InvItem _compareItem, GVar _compareVar)
        {
            if (_parameter == null)
            {
                ACDebug.LogWarning ("Cannot check state of variable since it cannot be found!");
                return false;
            }

            if (_parameter.parameterType == ParameterType.Boolean)
            {
                int fieldValue = _parameter.intValue;
                int compareValue = (int) boolValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Integer)
            {
                int fieldValue = _parameter.intValue;
                int compareValue = intValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Float)
            {
                float fieldValue = _parameter.floatValue;
                float compareValue = floatValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.floatVal;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.String)
            {
                string fieldValue = _parameter.stringValue;
                string compareValue = AdvGame.ConvertTokens (stringValue);
                if (_compareVar != null)
                {
                    compareValue = _compareVar.textVal;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.GameObject)
            {
                if ((compareObject != null && _parameter.gameObject == compareObject) ||
                    (compareObjectConstantID != 0 && _parameter.intValue == compareObjectConstantID))
                {
                    return true;
                }
                if (compareObject == null && _parameter.gameObject == null)
                {
                    return true;
                }
            }

            else if (_parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.LocalVariable)
            {
                if (_compareVar != null && _parameter.intValue == _compareVar.id)
                {
                    return true;
                }
            }

            else if (_parameter.parameterType == ParameterType.InventoryItem)
            {
                if (_compareItem != null && _parameter.intValue == _compareItem.id)
                {
                    return true;
                }
            }

            return false;
        }
예제 #16
0
		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 ();
		}
예제 #17
0
		private bool CheckCondition (GVar _var, GVar _compareVar)
		{
			if (_compareVar != null && _var != null && _compareVar.type != _var.type)
			{
				Debug.LogWarning ("Cannot compare " + _var.label + " and " + _compareVar.label + " as they are not the same type!");
				return false;
			}

			if (_var.type == VariableType.Boolean)
			{
				int fieldValue = _var.val;
				int compareValue = (int) boolValue;
				if (_compareVar != null)
				{
					compareValue = _compareVar.val;
				}

				if (boolCondition == BoolCondition.EqualTo)
				{
					if (fieldValue == compareValue)
					{
						return true;
					}
				}
				else
				{
					if (fieldValue != compareValue)
					{
						return true;
					}
				}
			}

			else if (_var.type == VariableType.Integer || _var.type == VariableType.PopUp)
			{
				int fieldValue = _var.val;
				int compareValue = intValue;
				if (_compareVar != null)
				{
					compareValue = _compareVar.val;
				}

				if (intCondition == IntCondition.EqualTo)
				{
					if (fieldValue == compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.NotEqualTo)
				{
					if (fieldValue != compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.LessThan)
				{
					if (fieldValue < compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.MoreThan)
				{
					if (fieldValue > compareValue)
					{
						return true;
					}
				}
			}

			else if (_var.type == VariableType.Float)
			{
				float fieldValue = _var.floatVal;
				float compareValue = floatValue;
				if (_compareVar != null)
				{
					compareValue = _compareVar.floatVal;
				}

				if (intCondition == IntCondition.EqualTo)
				{
					if (fieldValue == compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.NotEqualTo)
				{
					if (fieldValue != compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.LessThan)
				{
					if (fieldValue < compareValue)
					{
						return true;
					}
				}
				else if (intCondition == IntCondition.MoreThan)
				{
					if (fieldValue > compareValue)
					{
						return true;
					}
				}
			}

			else if (_var.type == VariableType.String)
			{
				string fieldValue = _var.textVal;
				string compareValue = AdvGame.ConvertTokens (stringValue);
				if (_compareVar != null)
				{
					compareValue = _compareVar.textVal;
				}

				if (boolCondition == BoolCondition.EqualTo)
				{
					if (fieldValue == compareValue)
					{
						return true;
					}
				}
				else
				{
					if (fieldValue != compareValue)
					{
						return true;
					}
				}
			}
			
			return false;
		}
예제 #18
0
		private void DeactivateAllVars ()
		{
			if (GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>())
			{
				foreach (GVar var in GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>().localVars)
				{
					var.isEditing = false;
				}
			}

			foreach (GVar var in vars)
			{
				var.isEditing = false;
			}
			selectedVar = null;
		}
예제 #19
0
 private void ActivateVar(GVar var)
 {
     var.isEditing = true;
     selectedVar = var;
 }
 /// <summary>
 /// Gets the ID of the DialogueSystemEnvironment AC variable. If the variable hasn't been defined
 /// in AC yet, this method also creates the variable.
 /// </summary>
 /// <returns>The DialogueSystemEnvironment variable ID.</returns>
 private static int GetDialogueSystemVarID()
 {
     var variablesManager = KickStarter.variablesManager;
     if (variablesManager == null) return 0;
     List<GVar> globalVarList = GlobalVariables.GetAllVars();
     foreach (GVar var in globalVarList) {
         if (string.Equals(var.label, DialogueSystemGlobalVariableName)) return var.id;
     }
     GVar newVar = new GVar(GetVarIDArray(variablesManager));
     newVar.label = DialogueSystemGlobalVariableName;
     newVar.type = VariableType.String;
     variablesManager.vars.Add(newVar);
     globalVarList.Add(newVar);
     return newVar.id;
 }
예제 #21
0
파일: GVar.cs 프로젝트: mcbodge/eidolon
 /**
  * A Constructor that copies all values from another variable.
  * This way ensures that no connection remains to the asset file.
  */
 public GVar(GVar assetVar)
 {
     val = assetVar.val;
     floatVal = assetVar.floatVal;
     textVal = assetVar.textVal;
     type = assetVar.type;
     id = assetVar.id;
     label = assetVar.label;
     link = assetVar.link;
     pmVar = assetVar.pmVar;
     popUps = assetVar.popUps;
     updateLinkOnStart = assetVar.updateLinkOnStart;
     backupVal = assetVar.val;
     backupFloatVal = assetVar.floatVal;
 }
예제 #22
0
        /**
         * <summary>Gets the PresetValue for a speicific variable.</summary>
         * <param name = "_var">The variable to get the PresetValue of</param>
         */
        public PresetValue GetPresetValue(GVar _var)
        {
            foreach (PresetValue presetValue in presetValues)
            {
                if (presetValue.id == _var.id)
                {
                    return presetValue;
                }
            }

            PresetValue newPresetValue = new PresetValue (_var);
            presetValues.Add (newPresetValue);
            return newPresetValue;
        }
예제 #23
0
        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 ();
        }
예제 #24
0
파일: GVar.cs 프로젝트: sirmortimus/team9
        /**
         * <summary>Copies the value of another variable onto itself.</summary>
         * <param name = "oldVar">The variable to copy from</param>
         * <param name = "oldLocation">The location of the variable to copy (Global, Local)</param>
         */
        public void CopyFromVariable(GVar oldVar, VariableLocation oldLocation)
        {
            if (oldLocation == VariableLocation.Global)
            {
                oldVar.Download();
            }

            if (type == VariableType.Integer || type == VariableType.Boolean || type == VariableType.PopUp)
            {
                int oldValue = oldVar.val;

                if (oldVar.type == VariableType.Float)
                {
                    oldValue = (int)oldVar.floatVal;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float oldValueAsFloat = 0f;
                    float.TryParse(oldVar.textVal, out oldValueAsFloat);
                    oldValue = (int)oldValueAsFloat;
                }

                if (type == VariableType.PopUp && oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }

                SetValue(oldValue, SetVarMethod.SetValue);
            }
            else if (type == VariableType.Float)
            {
                float oldValue = oldVar.floatVal;

                if (oldVar.type == VariableType.Integer || oldVar.type == VariableType.Boolean || oldVar.type == VariableType.PopUp)
                {
                    oldValue = (float)oldVar.val;
                }
                else if (oldVar.type == VariableType.String)
                {
                    float.TryParse(oldVar.textVal, out oldValue);
                }

                SetFloatValue(oldValue, AC.SetVarMethod.SetValue);
            }
            else if (type == VariableType.String)
            {
                string oldValue = oldVar.GetValue();
                textVal = oldValue;

                if (oldVar.HasTranslations())
                {
                    runtimeTranslations = oldVar.GetTranslations();
                }
                else
                {
                    runtimeTranslations = null;
                }
            }
            else if (type == VariableType.Vector3)
            {
                Vector3 oldValue = oldVar.vector3Val;
                vector3Val = oldValue;
            }
        }