Exemple #1
0
    public static string GetString(CustomValueData customValue)
    {
        if (customValue.type != CustomValueData.ValueType.String)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected String");
            return("");
        }

        if (!_strings.ContainsKey(customValue))
        {
            _strings.Add(customValue, "");
        }

        return(_strings[customValue]);
    }
Exemple #2
0
    public static float GetFloat(CustomValueData customValue)
    {
        if (customValue.type != CustomValueData.ValueType.Float)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected Float");
            return(0f);
        }

        if (!_floats.ContainsKey(customValue))
        {
            _floats.Add(customValue, 0f);
        }

        return(_floats[customValue]);
    }
Exemple #3
0
    public static int GetInt(CustomValueData customValue)
    {
        if (customValue.type != CustomValueData.ValueType.Int)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected Int");
            return(0);
        }

        if (!_ints.ContainsKey(customValue))
        {
            _ints.Add(customValue, 0);
        }

        return(_ints[customValue]);
    }
Exemple #4
0
    //public static SecureEvent valuesUpdatedEvent = new SecureEvent();

    public static bool GetBool(CustomValueData customValue)
    {
        if (customValue.type != CustomValueData.ValueType.Bool)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected Bool");
            return(false);
        }

        if (!_bools.ContainsKey(customValue))
        {
            _bools.Add(customValue, false);
        }

        return(_bools[customValue]);
    }
Exemple #5
0
    public static void SetString(CustomValueData customValue, string stringValue)
    {
        if (customValue.type != CustomValueData.ValueType.String)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected String");
            return;
        }

        if (_strings.ContainsKey(customValue))
        {
            _strings[customValue] = stringValue;
        }
        else
        {
            _strings.Add(customValue, stringValue);
        }

        //valuesUpdatedEvent.Invoke();
    }
Exemple #6
0
    public static void SetFloat(CustomValueData customValue, float floatValue)
    {
        if (customValue.type != CustomValueData.ValueType.Float)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected Float");
            return;
        }

        if (_floats.ContainsKey(customValue))
        {
            _floats[customValue] = floatValue;
        }
        else
        {
            _floats.Add(customValue, floatValue);
        }

        //valuesUpdatedEvent.Invoke();
    }
Exemple #7
0
    public static void SetBool(CustomValueData customValue, bool boolValue)
    {
        if (customValue.type != CustomValueData.ValueType.Bool)
        {
            Debug.LogError("Incorrect custom value type requested! Is a " + customValue.type.ToString() + ", expected Bool");
            return;
        }

        if (_bools.ContainsKey(customValue))
        {
            _bools[customValue] = boolValue;
        }
        else
        {
            _bools.Add(customValue, boolValue);
        }

        //valuesUpdatedEvent.Invoke();
    }
Exemple #8
0
 public static bool EvaluateConditional(CustomValueData customValue1, CustomValueData customValue2, ComparisonOperator comparisonOperator)
 {
     return(EvaluateConditional(new CustomValueConditional(customValue1, customValue2, comparisonOperator)));
 }
Exemple #9
0
 public CustomValueConditional(CustomValueData newValue1, CustomValueData newValue2, ComparisonOperator newComparisonOperator)
 {
     value1             = newValue1;
     value2             = newValue2;
     comparisonOperator = newComparisonOperator;
 }
Exemple #10
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            position.height = 16;
            Rect lineRect = new Rect(position.x, position.y + 5, position.width, 16);

            if (property.FindPropertyRelative("gameEventData").objectReferenceValue != null)
            {
                Rect totalRect = position;
                totalRect.height = GetPropertyHeight(property, new GUIContent());
                totalRect.x     -= 2;
                totalRect.width += 4;

                GUI.Box(totalRect, "", EditorStyles.helpBox);
            }

            Rect valueRect = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            if (property.FindPropertyRelative("gameEventData").objectReferenceValue != null)
            {
                valueRect.y += 5;
            }

            EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("gameEventData"), GUIContent.none);

            if (property.FindPropertyRelative("gameEventData").objectReferenceValue != null)
            {
                valueRect.y += 18;
                lineRect.y  += 18;
                EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("delay"));

                valueRect.y += 18;
                lineRect.y  += 18;
                EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("delayType"));

                SerializedObject gameEventObject = new SerializedObject(property.FindPropertyRelative("gameEventData").objectReferenceValue);

                //Objects
                int numObjects = gameEventObject.FindProperty("eventObjects").arraySize;
                property.FindPropertyRelative("objects").arraySize = numObjects;

                if (numObjects > 0)
                {
                    lineRect.y += 18;
                    EditorGUI.LabelField(lineRect, "    Objects", EditorStyles.boldLabel);
                }

                for (int i = 0; i < numObjects; i++)
                {
                    lineRect.y += 18;

                    SerializedProperty objectNameProperty = gameEventObject.FindProperty(string.Format("eventObjects.Array.data[{0}].objectID", i));
                    SerializedProperty objectTypeProperty = gameEventObject.FindProperty(string.Format("eventObjects.Array.data[{0}].type", i));
                    valueRect = EditorGUI.PrefixLabel(lineRect, new GUIContent(string.Format("     • {0}", objectNameProperty.stringValue)));

                    property.FindPropertyRelative(string.Format("objects.Array.data[{0}].id", i)).stringValue = objectNameProperty.stringValue;
                    SerializedProperty objectValueProperty = property.FindPropertyRelative(string.Format("objects.Array.data[{0}].value", i));
                    objectValueProperty.objectReferenceValue = EditorGUI.ObjectField(valueRect, objectValueProperty.objectReferenceValue, GameEventData.TypeFromEnum((GameEventData.SupportedObjectType)objectTypeProperty.enumValueIndex), true);

                    if (objectValueProperty.objectReferenceValue != null)
                    {
                        if (objectValueProperty.objectReferenceValue is CustomValueData)
                        {
                            CustomValueData cvd = (CustomValueData)objectValueProperty.objectReferenceValue;
                            lineRect.y += 18;

                            if (cvd.type == CustomValueData.ValueType.Bool)
                            {
                                EditorGUI.LabelField(lineRect, " ", "     (Bool Type)", EditorStyles.boldLabel);
                            }
                            else if (cvd.type == CustomValueData.ValueType.Int)
                            {
                                EditorGUI.LabelField(lineRect, " ", "     (int Type)", EditorStyles.boldLabel);
                            }
                            else if (cvd.type == CustomValueData.ValueType.Float)
                            {
                                EditorGUI.LabelField(lineRect, " ", "     (Float Type)", EditorStyles.boldLabel);
                            }
                            else if (cvd.type == CustomValueData.ValueType.String)
                            {
                                EditorGUI.LabelField(lineRect, " ", "     (String Type)", EditorStyles.boldLabel);
                            }
                        }
                    }
                }

                //Bools
                int numBools = gameEventObject.FindProperty("eventBools").arraySize;
                property.FindPropertyRelative("bools").arraySize = numBools;

                if (numBools > 0)
                {
                    lineRect.y += 18;
                    EditorGUI.LabelField(lineRect, "    Bools", EditorStyles.boldLabel);
                }

                for (int i = 0; i < numBools; i++)
                {
                    lineRect.y += 18;

                    SerializedProperty boolNameProperty = gameEventObject.FindProperty(string.Format("eventBools.Array.data[{0}]", i));
                    valueRect = EditorGUI.PrefixLabel(lineRect, new GUIContent(string.Format("     • {0}", boolNameProperty.stringValue)));

                    property.FindPropertyRelative(string.Format("bools.Array.data[{0}].id", i)).stringValue = boolNameProperty.stringValue;
                    SerializedProperty boolValueProperty = property.FindPropertyRelative(string.Format("bools.Array.data[{0}].value", i));
                    EditorGUI.PropertyField(valueRect, boolValueProperty, new GUIContent());
                }

                //Ints
                int numInts = gameEventObject.FindProperty("eventInts").arraySize;
                property.FindPropertyRelative("ints").arraySize = numInts;

                if (numInts > 0)
                {
                    lineRect.y += 18;
                    EditorGUI.LabelField(lineRect, "    Ints", EditorStyles.boldLabel);
                }

                for (int i = 0; i < numInts; i++)
                {
                    lineRect.y += 18;

                    SerializedProperty intNameProperty = gameEventObject.FindProperty(string.Format("eventInts.Array.data[{0}]", i));
                    valueRect = EditorGUI.PrefixLabel(lineRect, new GUIContent(string.Format("     • {0}", intNameProperty.stringValue)));

                    property.FindPropertyRelative(string.Format("ints.Array.data[{0}].id", i)).stringValue = intNameProperty.stringValue;
                    SerializedProperty intValueProperty = property.FindPropertyRelative(string.Format("ints.Array.data[{0}].value", i));
                    EditorGUI.PropertyField(valueRect, intValueProperty, new GUIContent());
                }

                //Floats
                int numFloats = gameEventObject.FindProperty("eventFloats").arraySize;
                property.FindPropertyRelative("floats").arraySize = numFloats;

                if (numFloats > 0)
                {
                    lineRect.y += 18;
                    EditorGUI.LabelField(lineRect, "    Floats", EditorStyles.boldLabel);
                }

                for (int i = 0; i < numFloats; i++)
                {
                    lineRect.y += 18;

                    SerializedProperty floatNameProperty = gameEventObject.FindProperty(string.Format("eventFloats.Array.data[{0}]", i));
                    valueRect = EditorGUI.PrefixLabel(lineRect, new GUIContent(string.Format("     • {0}", floatNameProperty.stringValue)));

                    property.FindPropertyRelative(string.Format("floats.Array.data[{0}].id", i)).stringValue = floatNameProperty.stringValue;
                    SerializedProperty floatValueProperty = property.FindPropertyRelative(string.Format("floats.Array.data[{0}].value", i));
                    EditorGUI.PropertyField(valueRect, floatValueProperty, new GUIContent());
                }

                //Strings
                int numStrings = gameEventObject.FindProperty("eventStrings").arraySize;
                property.FindPropertyRelative("strings").arraySize = numStrings;

                if (numStrings > 0)
                {
                    lineRect.y += 18;
                    EditorGUI.LabelField(lineRect, "    Strings", EditorStyles.boldLabel);
                }

                for (int i = 0; i < numStrings; i++)
                {
                    lineRect.y += 18;

                    SerializedProperty stringNameProperty = gameEventObject.FindProperty(string.Format("eventStrings.Array.data[{0}]", i));
                    valueRect = EditorGUI.PrefixLabel(lineRect, new GUIContent(string.Format("     • {0}", stringNameProperty.stringValue)));

                    property.FindPropertyRelative(string.Format("strings.Array.data[{0}].id", i)).stringValue = stringNameProperty.stringValue;
                    SerializedProperty stringValueProperty = property.FindPropertyRelative(string.Format("strings.Array.data[{0}].value", i));
                    EditorGUI.PropertyField(valueRect, stringValueProperty, new GUIContent());
                }
            }

            property.serializedObject.ApplyModifiedProperties();

            EditorGUI.EndProperty();
        }