public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);

            float origX     = pos.x;
            float origWidth = pos.width;

            SerializedProperty runTargetProp = DrawRunTargetAndCallMethod(ref pos, prop, 125);

            SerializedProperty numCheckProp = prop.FindPropertyRelative("numericalCheck");

            pos.width = numericalCheckWidth;
            numCheckProp.enumValueIndex = EditorGUI.Popup(pos, numCheckProp.enumValueIndex, numericalCheckOptions);
            pos.x += pos.width;

            SerializedProperty useGlobalValueThresholdProp = prop.FindPropertyRelative("useGlobalValueThreshold");
            bool useGlobalValueThreshold = useGlobalValueThresholdProp.boolValue;


            if (useGlobalValueThreshold)
            {
                pos.width = 100;
                GlobalGameValues.DrawGlobalValueSelector(pos, prop.FindPropertyRelative("globalValueThresholdName"));
                pos.x += 75;
            }
            else
            {
                pos.width = 60;
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("threshold"), GUITools.noContent, true);
                pos.x += pos.width;
            }

            GUITools.DrawToolbarDivider(pos.x, pos.y);
            pos.x += GUITools.toolbarDividerSize;

            GUITools.DrawIconToggle(useGlobalValueThresholdProp, useGlobalValueGUI, pos.x, pos.y);
            pos.x += GUITools.iconButtonWidth;

            SerializedProperty trueIfSubjectNullProp = prop.FindPropertyRelative("trueIfSubjectNull");

            GUITools.DrawIconToggle(trueIfSubjectNullProp, new GUIContent("[?]", "Consider True If Subject Is Null Or Method Check Fails"), pos.x, pos.y);
            pos.x += GUITools.iconButtonWidth;

            SerializedProperty orProp = prop.FindPropertyRelative("or");

            GUITools.DrawIconToggle(orProp, new GUIContent(orProp.boolValue ? "||" : "&&"), pos.x, pos.y, GUITools.white, GUITools.white);
            pos.x += GUITools.iconButtonWidth;

            DrawEnd(ref pos, prop, origX, origWidth, runTargetProp);

            EditorGUI.EndProperty();
        }
Beispiel #2
0
        // public bool IsTrue (GameObject subject, GameObject target) {
        public bool IsTrue(Dictionary <string, object> checkObjects)
        {
            object[] suppliedParameters;


            // GameObject obj;
            // if (!Messaging.PrepareForMessageSend(callMethod, runTarget, subject, target, referenceTarget, parameters, out obj, out suppliedParameters))
            object obj;

            if (!Messaging.PrepareForMessageSend(callMethod, runTarget, checkObjects, runtimeSubjectName, referenceTarget, parameters, out obj, out suppliedParameters))
            {
                return(trueIfSubjectNull);
            }
            // return false;

            float returnValue;

            if (runTarget == RunTarget.Static)
            {
                if (!Messaging.CallStaticMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(trueIfSubjectNull);
                }
                // return false;
            }
            else
            {
                if (!obj.CallMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(trueIfSubjectNull);
                }
                // return false;
            }

            float checkThreshold = threshold;

            if (useGlobalValueThreshold)
            {
                checkThreshold = GlobalGameValues.GetGlobalValue(globalValueThresholdName);
            }

            return(CheckValue(returnValue, threshold));
        }
        public bool IsTrue(GameObject subject, GameObject target)
        {
            object[]   suppliedParameters;
            GameObject obj;

            if (!Messaging.PrepareForMessageSend(callMethod, runTarget, subject, target, referenceTarget, parameters, out obj, out suppliedParameters))
            {
                return(false);
            }

            float returnValue;

            if (runTarget == RunTarget.Static)
            {
                if (!Messaging.CallStaticMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }
            else
            {
                if (!obj.CallMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }

            float checkThreshold = threshold;

            if (useGlobalValueThreshold)
            {
                checkThreshold = GlobalGameValues.GetGlobalValue(globalValueThresholdName);
            }

            return(CheckValue(returnValue, threshold));
        }
Beispiel #4
0
 public void SetVolume()
 {
     Debug.Log("Setting volume: " + VolumeSlider.value);
     PlayerPrefs.SetFloat("volume", VolumeSlider.value);
     GlobalGameValues.SetVolume(VolumeSlider.value);
 }
Beispiel #5
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);

            float origX     = pos.x;
            float origWidth = pos.width;

            pos.width = 65;

            SerializedProperty runTargetProp = prop.FindPropertyRelative("runTarget");

            EditorGUI.PropertyField(pos, runTargetProp, GUITools.noContent, true);

            pos.x += pos.width;

            pos.width = 125;

            GUITools.StringFieldWithDefault(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("callMethod"), "Call Method");
            pos.x += pos.width;


            SerializedProperty numCheckProp = prop.FindPropertyRelative("numericalCheck");

            pos.width = numericalCheckWidth;
            numCheckProp.enumValueIndex = EditorGUI.Popup(pos, numCheckProp.enumValueIndex, numericalCheckOptions);
            pos.x += pos.width;

            SerializedProperty useGlobalValueThresholdProp = prop.FindPropertyRelative("useGlobalValueThreshold");
            bool useGlobalValueThreshold = useGlobalValueThresholdProp.boolValue;


            if (useGlobalValueThreshold)
            {
                pos.width = 100;

                GlobalGameValues.DrawGlobalValueSelector(pos, prop.FindPropertyRelative("globalValueThresholdName"));
            }
            else
            {
                pos.width = 60;
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("threshold"), GUITools.noContent, true);
            }
            pos.x += pos.width;

            GUITools.DrawToolbarDivider(pos.x, pos.y);
            pos.x += GUITools.toolbarDividerSize;

            useGlobalValueThreshold = GUITools.DrawToggleButton(useGlobalValueThresholdProp, useGlobalValueGUI, pos.x, pos.y, GUITools.blue, GUITools.white);
            pos.x += GUITools.iconButtonWidth;

            bool showParameters = GUITools.DrawToggleButton(prop.FindPropertyRelative("showParameters"), new GUIContent("P", "Show Parameters"), pos.x, pos.y, GUITools.blue, GUITools.white);

            pos.x += GUITools.iconButtonWidth;

            SerializedProperty orProp = prop.FindPropertyRelative("or");

            orProp.boolValue = GUITools.DrawToggleButton(orProp.boolValue, new GUIContent(orProp.boolValue ? "||" : "&&"), pos.x, pos.y, GUITools.white, GUITools.white);


            if (runTargetProp.enumValueIndex == (int)RunTarget.Reference)
            {
                pos.y    += EditorGUIUtility.singleLineHeight;
                pos.x     = origX;
                pos.width = origWidth;

                EditorGUI.LabelField(pos, "Reference:");

                pos.x     += 65;
                pos.width -= 65;
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("referenceTarget"), GUITools.noContent, true);
            }


            pos.y    += EditorGUIUtility.singleLineHeight;
            pos.x     = origX;
            pos.width = origWidth;

            if (showParameters)
            {
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("parameters"), true);
            }
            else
            {
                SerializedProperty paramsProp = prop.FindPropertyRelative("parameters");

                if (paramsProp.FindPropertyRelative("list").arraySize > 0)
                {
                    pos.x     += GUITools.iconButtonWidth;
                    pos.width -= GUITools.iconButtonWidth;

                    ConditionsParametersDrawer.DrawFlat(pos, paramsProp);
                }
            }

            EditorGUI.EndProperty();
        }
Beispiel #6
0
        public bool IsTrue(GameObject subject, GameObject target)
        {
            if (string.IsNullOrEmpty(callMethod) || string.IsNullOrWhiteSpace(callMethod))
            {
                Debug.LogWarning("Call Method is blank...");
                return(false);
            }

            GameObject obj = subject;

            switch (runTarget)
            {
            case RunTarget.Subject: obj = subject; break;

            case RunTarget.Target: obj = target; break;

            case RunTarget.Reference: obj = referenceTarget; break;

            case RunTarget.Static: obj = null; break;
            }

            if (obj == null && runTarget != RunTarget.Static)
            {
                Debug.LogWarning("RunTarget: " + runTarget.ToString() + " is null, can't call condition method: " + callMethod);
                return(false);
            }

            object[] suppliedParameters = new object[0];

            if (parameters.Length > 0)
            {
                List <object> parametersList = new List <object>();
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i] != null)
                    {
                        parametersList.Add(parameters[i].GetParamObject());
                    }
                }
                suppliedParameters = parametersList.ToArray();
            }

            float returnValue;

            if (runTarget == RunTarget.Static)
            {
                if (!SystemTools.CallStaticMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }
            else
            {
                if (!obj.CallMethod(callMethod, suppliedParameters, out returnValue))
                {
                    return(false);
                }
            }

            float checkThreshold = threshold;

            if (useGlobalValueThreshold)
            {
                checkThreshold = GlobalGameValues.GetGlobalValue(globalValueThresholdName);
            }

            return(CheckValue(returnValue, threshold));
        }
Beispiel #7
0
 public void Start()
 {
     Debug.Log("Menu start, volume: " + PlayerPrefs.GetFloat("volume"));
     GlobalGameValues.SetVolume(PlayerPrefs.GetFloat("volume"));
 }