Exemple #1
0
        public override bool ConvertGlobalVariableToLocal(int oldGlobalID, int newLocalID, bool isCorrectScene)
        {
            bool wasAmended = base.ConvertGlobalVariableToLocal(oldGlobalID, newLocalID, isCorrectScene);

            if (location == VariableLocation.Global && variableID == oldGlobalID)
            {
                wasAmended = true;
                if (isCorrectScene)
                {
                    location   = VariableLocation.Local;
                    variableID = newLocalID;
                }
            }

            if (getVarMethod == GetVarMethod.GlobalVariable && compareVariableID == oldGlobalID)
            {
                wasAmended = true;
                if (isCorrectScene)
                {
                    getVarMethod      = GetVarMethod.LocalVariable;
                    compareVariableID = newLocalID;
                }
            }

            return(wasAmended);
        }
Exemple #2
0
        public override bool ConvertLocalVariableToGlobal(int oldLocalID, int newGlobalID)
        {
            bool wasAmended = base.ConvertLocalVariableToGlobal(oldLocalID, newGlobalID);

            if (location == VariableLocation.Local && variableID == oldLocalID)
            {
                location   = VariableLocation.Global;
                variableID = newGlobalID;
                wasAmended = true;
            }

            if (getVarMethod == GetVarMethod.LocalVariable && compareVariableID == oldLocalID)
            {
                getVarMethod      = GetVarMethod.GlobalVariable;
                compareVariableID = newGlobalID;
                wasAmended        = true;
            }

            return(wasAmended);
        }
Exemple #3
0
        private int ShowVarGUI(List <ActionParameter> parameters, List <GVar> vars, int ID, bool changeID)
        {
            if (vars.Count > 0)
            {
                if (changeID)
                {
                    ID = ShowVarSelectorGUI(vars, ID);
                }
                variableNumber = Mathf.Min(variableNumber, vars.Count - 1);
                getVarMethod   = (GetVarMethod)EditorGUILayout.EnumPopup("Compare with:", getVarMethod);

                if (parameters == null || parameters.Count == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                }

                if (vars [variableNumber].type == VariableType.Boolean)
                {
                    boolCondition = (BoolCondition)EditorGUILayout.EnumPopup(boolCondition);
                    if (getVarMethod == GetVarMethod.EnteredValue)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Boolean:", parameters, checkParameterID, ParameterType.Boolean);
                        if (checkParameterID < 0)
                        {
                            boolValue = (BoolValue)EditorGUILayout.EnumPopup("Boolean:", boolValue);
                        }
                    }
                }
                else if (vars [variableNumber].type == VariableType.Integer)
                {
                    intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                    if (getVarMethod == GetVarMethod.EnteredValue)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Integer:", parameters, checkParameterID, ParameterType.Integer);
                        if (checkParameterID < 0)
                        {
                            intValue = EditorGUILayout.IntField("Integer:", intValue);
                        }
                    }
                }
                else if (vars [variableNumber].type == VariableType.PopUp)
                {
                    intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                    if (getVarMethod == GetVarMethod.EnteredValue)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Value:", parameters, checkParameterID, ParameterType.Integer);
                        if (checkParameterID < 0)
                        {
                            intValue = EditorGUILayout.Popup("Value:", intValue, vars [variableNumber].popUps);
                        }
                    }
                }
                else if (vars [variableNumber].type == VariableType.Float)
                {
                    intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                    if (getVarMethod == GetVarMethod.EnteredValue)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Float:", parameters, checkParameterID, ParameterType.Float);
                        if (checkParameterID < 0)
                        {
                            floatValue = EditorGUILayout.FloatField("Float:", floatValue);
                        }
                    }
                }
                else if (vars [variableNumber].type == VariableType.String)
                {
                    boolCondition = (BoolCondition)EditorGUILayout.EnumPopup(boolCondition);
                    if (getVarMethod == GetVarMethod.EnteredValue)
                    {
                        checkParameterID = Action.ChooseParameterGUI("String:", parameters, checkParameterID, ParameterType.String);
                        if (checkParameterID < 0)
                        {
                            stringValue = EditorGUILayout.TextField("String:", stringValue);
                        }
                    }
                }

                if (getVarMethod == GetVarMethod.GlobalVariable)
                {
                    if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                    }
                    else
                    {
                        checkParameterID = Action.ChooseParameterGUI("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable);
                        if (checkParameterID < 0)
                        {
                            compareVariableID = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, compareVariableID);
                        }
                    }
                }
                else if (getVarMethod == GetVarMethod.LocalVariable)
                {
                    if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                    }
                    else
                    {
                        checkParameterID = Action.ChooseParameterGUI("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable);
                        if (checkParameterID < 0)
                        {
                            compareVariableID = ShowVarSelectorGUI(KickStarter.localVariables.localVars, compareVariableID);
                        }
                    }
                }

                if (parameters == null || parameters.Count == 0)
                {
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No variables exist!", MessageType.Info);
                ID             = -1;
                variableNumber = -1;
            }

            return(ID);
        }
Exemple #4
0
        private int ShowVarGUI(List <ActionParameter> parameters, List <GVar> _vars, int ID, bool changeID)
        {
            VariableType showType = VariableType.Boolean;

            if (changeID)
            {
                if (_vars != null && _vars.Count > 0)
                {
                    ID = ShowVarSelectorGUI(_vars, ID, "Variable:");

                    variableNumber = Mathf.Min(variableNumber, _vars.Count - 1);
                    getVarMethod   = (GetVarMethod)EditorGUILayout.EnumPopup("Compare with:", getVarMethod);

                    showType = _vars[variableNumber].type;
                }
                else
                {
                    EditorGUILayout.HelpBox("No variables exist!", MessageType.Info);
                    ID             = -1;
                    variableNumber = -1;
                    return(ID);
                }

                placeholderType = showType;
            }
            else
            {
                showType = placeholderType;
            }

            switch (showType)
            {
            case VariableType.Boolean:
                boolCondition = (BoolCondition)EditorGUILayout.EnumPopup("Condition:", boolCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Boolean:", parameters, checkParameterID, ParameterType.Boolean);
                    if (checkParameterID < 0)
                    {
                        boolValue = (BoolValue)EditorGUILayout.EnumPopup("Boolean:", boolValue);
                    }
                }
                break;

            case VariableType.Integer:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Integer:", parameters, checkParameterID, ParameterType.Integer);
                    if (checkParameterID < 0)
                    {
                        intValue = EditorGUILayout.IntField("Integer:", intValue);
                    }
                }
                break;

            case VariableType.Float:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Float:", parameters, checkParameterID, ParameterType.Float);
                    if (checkParameterID < 0)
                    {
                        floatValue = EditorGUILayout.FloatField("Float:", floatValue);
                    }
                }
                break;

            case VariableType.PopUp:
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Condition:", intCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("Value:", parameters, checkParameterID, ParameterType.Integer);
                    if (checkParameterID < 0)
                    {
                        if (changeID && _vars != null && _vars.Count > variableNumber)
                        {
                            string[] popUpLabels = _vars[variableNumber].GenerateEditorPopUpLabels();
                            intValue = EditorGUILayout.Popup("Value:", intValue, popUpLabels);
                            placeholderPopUpLabelDataID = _vars[variableNumber].popUpID;
                        }
                        else if (!changeID && AdvGame.GetReferences().variablesManager != null)
                        {
                            // Parameter override
                            placeholderPopUpLabelDataID = AdvGame.GetReferences().variablesManager.ShowPlaceholderPresetData(placeholderPopUpLabelDataID);
                            PopUpLabelData popUpLabelData = AdvGame.GetReferences().variablesManager.GetPopUpLabelData(placeholderPopUpLabelDataID);

                            if (popUpLabelData != null && placeholderPopUpLabelDataID > 0)
                            {
                                // Show placeholder labels
                                intValue = EditorGUILayout.Popup("Index value:", intValue, popUpLabelData.GenerateEditorPopUpLabels());
                            }
                            else
                            {
                                intValue = EditorGUILayout.IntField("Index value:", intValue);
                            }
                        }
                        else
                        {
                            intValue = EditorGUILayout.IntField("Index value:", intValue);
                        }
                    }
                }
                break;

            case VariableType.String:
                boolCondition = (BoolCondition)EditorGUILayout.EnumPopup("Condition:", boolCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    checkParameterID = Action.ChooseParameterGUI("String:", parameters, checkParameterID, ParameterType.String);
                    if (checkParameterID < 0)
                    {
                        stringValue = EditorGUILayout.TextField("String:", stringValue);
                    }
                }
                checkCase = EditorGUILayout.Toggle("Case-sensitive?", checkCase);
                break;

            case VariableType.Vector3:
                vectorCondition = (VectorCondition)EditorGUILayout.EnumPopup("Condition:", vectorCondition);
                if (getVarMethod == GetVarMethod.EnteredValue)
                {
                    if (vectorCondition == VectorCondition.MagnitudeGreaterThan)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Float:", parameters, checkParameterID, ParameterType.Float);
                        if (checkParameterID < 0)
                        {
                            floatValue = EditorGUILayout.FloatField("Float:", floatValue);
                        }
                    }
                    else if (vectorCondition == VectorCondition.EqualTo)
                    {
                        checkParameterID = Action.ChooseParameterGUI("Vector3:", parameters, checkParameterID, ParameterType.Vector3);
                        if (checkParameterID < 0)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Vector3:", GUILayout.MaxWidth(60f));
                            vector3Value = EditorGUILayout.Vector3Field("", vector3Value);
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                break;

            default:
                break;
            }

            if (getVarMethod == GetVarMethod.GlobalVariable)
            {
                if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                {
                    EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                }
                else
                {
                    checkParameterID = Action.ChooseParameterGUI("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable);
                    if (checkParameterID < 0)
                    {
                        compareVariableID = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, compareVariableID, "Global variable:");
                    }
                }
            }
            else if (getVarMethod == GetVarMethod.LocalVariable)
            {
                if (localVariables == null || localVariables.localVars == null || localVariables.localVars.Count == 0)
                {
                    EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                }
                else
                {
                    checkParameterID = Action.ChooseParameterGUI("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable);
                    if (checkParameterID < 0)
                    {
                        compareVariableID = ShowVarSelectorGUI(localVariables.localVars, compareVariableID, "Local variable:");
                    }
                }
            }
            else if (getVarMethod == GetVarMethod.ComponentVariable)
            {
                checkParameterID = Action.ChooseParameterGUI("Component variable:", parameters, checkParameterID, ParameterType.ComponentVariable);
                if (checkParameterID < 0)
                {
                    compareVariables           = (Variables)EditorGUILayout.ObjectField("Component", compareVariables, typeof(Variables), true);
                    compareVariablesConstantID = FieldToID <Variables> (compareVariables, compareVariablesConstantID);
                    compareVariables           = IDToField <Variables> (compareVariables, compareVariablesConstantID, false);

                    if (compareVariables != null)
                    {
                        compareVariableID = ShowVarSelectorGUI(compareVariables.vars, compareVariableID, "Component variable:");
                    }
                }
            }

            return(ID);
        }
		private int ShowVarGUI (List<ActionParameter> parameters, List<GVar> vars, int ID, bool changeID)
		{
			if (vars.Count > 0)
			{
				if (changeID)
				{
					ID = ShowVarSelectorGUI (vars, ID);
				}
				variableNumber = Mathf.Min (variableNumber, vars.Count-1);
				getVarMethod = (GetVarMethod) EditorGUILayout.EnumPopup ("Compare with:", getVarMethod);

				if (parameters == null || parameters.Count == 0)
				{
					EditorGUILayout.BeginHorizontal ();
				}

				if (vars [variableNumber].type == VariableType.Boolean)
				{
					boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition);
					if (getVarMethod == GetVarMethod.EnteredValue)
					{
						checkParameterID = Action.ChooseParameterGUI ("Boolean:", parameters, checkParameterID, ParameterType.Boolean);
						if (checkParameterID < 0)
						{
							boolValue = (BoolValue) EditorGUILayout.EnumPopup ("Boolean:", boolValue);
						}
					}
				}
				else if (vars [variableNumber].type == VariableType.Integer)
				{
					intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition);
					if (getVarMethod == GetVarMethod.EnteredValue)
					{
						checkParameterID = Action.ChooseParameterGUI ("Integer:", parameters, checkParameterID, ParameterType.Integer);
						if (checkParameterID < 0)
						{
							intValue = EditorGUILayout.IntField ("Integer:", intValue);
						}
					}
				}
				else if (vars [variableNumber].type == VariableType.PopUp)
				{
					intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition);
					if (getVarMethod == GetVarMethod.EnteredValue)
					{
						checkParameterID = Action.ChooseParameterGUI ("Value:", parameters, checkParameterID, ParameterType.Integer);
						if (checkParameterID < 0)
						{
							intValue = EditorGUILayout.Popup ("Value:", intValue, vars [variableNumber].popUps);
						}
					}
				}
				else if (vars [variableNumber].type == VariableType.Float)
				{
					intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition);
					if (getVarMethod == GetVarMethod.EnteredValue)
					{
						checkParameterID = Action.ChooseParameterGUI ("Float:", parameters, checkParameterID, ParameterType.Float);
						if (checkParameterID < 0)
						{
							floatValue = EditorGUILayout.FloatField ("Float:", floatValue);
						}
					}
				}
				else if (vars [variableNumber].type == VariableType.String)
				{
					boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition);
					if (getVarMethod == GetVarMethod.EnteredValue)
					{
						checkParameterID = Action.ChooseParameterGUI ("String:", parameters, checkParameterID, ParameterType.String);
						if (checkParameterID < 0)
						{
							stringValue = EditorGUILayout.TextField ("String:", stringValue);
						}
					}
				}

				if (getVarMethod == GetVarMethod.GlobalVariable)
				{
					if (!variablesManager)
					{
						variablesManager = AdvGame.GetReferences ().variablesManager;
					}

					if (variablesManager == null || variablesManager.vars == null || variablesManager.vars.Count == 0)
					{
						EditorGUILayout.HelpBox ("No Global variables exist!", MessageType.Info);
					}
					else
					{
						checkParameterID = Action.ChooseParameterGUI ("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable);
						if (checkParameterID < 0)
						{
							compareVariableID = ShowVarSelectorGUI (variablesManager.vars, compareVariableID);
						}
					}
				}
				else if (getVarMethod == GetVarMethod.LocalVariable)
				{
					if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>())
					{
						localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>();
					}
					
					if (localVariables == null || localVariables.localVars == null || localVariables.localVars.Count == 0)
					{
						EditorGUILayout.HelpBox ("No Local variables exist!", MessageType.Info);
					}
					else
					{
						checkParameterID = Action.ChooseParameterGUI ("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable);
						if (checkParameterID < 0)
						{
							compareVariableID = ShowVarSelectorGUI (localVariables.localVars, compareVariableID);
						}
					}
				}

				if (parameters == null || parameters.Count == 0)
				{
					EditorGUILayout.EndHorizontal ();
				}
			}
			else
			{
				EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info);
				ID = -1;
				variableNumber = -1;
			}

			return ID;
		}