Example #1
0
 public AddItemEditor()
 {
     this.ge = ScriptableObject.CreateInstance <SerializableGameEvent> ();
     ge.Name = this.EventName;
     ge.setParameter("item", null);
     ge.setParameter("inventory", null);
 }
 public ChangeSwitchEventEditor()
 {
     this.ge = ScriptableObject.CreateInstance <SerializableGameEvent>();
     ge.Name = this.EventName;
     ge.setParameter("switch", "");
     ge.setParameter("value", true);
 }
Example #3
0
    public void draw()
    {
        SerializableGameEvent ge = (SerializableGameEvent)node.Content;

        string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
        int      editorSelected = 0;

        for (int i = 1; i < editors.Length; i++)
        {
            if (editors [i].ToLower() == ge.Name.ToLower())
            {
                editorSelected = i;
            }
        }

        int was = editorSelected;

        editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
        if (currentEditor == null || was != editorSelected)
        {
            if (currentEditor != null)
            {
                currentEditor.detachEvent(ge);
            }

            ge.Name       = "";
            currentEditor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);
            currentEditor.useEvent(ge);
        }

        currentEditor.draw();

        /**
         *  Game event synchronization
         * */

        if (!(ge.getParameter("synchronous") is bool))
        {
            ge.setParameter("synchronous", false);
        }
        ge.setParameter("synchronous", EditorGUILayout.Toggle("Synchronous",
                                                              (ge.getParameter("synchronous") == null)?false:(bool)ge.getParameter("synchronous")));

        if ((bool)ge.getParameter("synchronous"))
        {
            EditorGUILayout.HelpBox("Notice that if there is no EventFinished event, the game will stuck.", MessageType.Warning);
        }

        /**
         * Synchronization end
         * */

        node.Content = currentEditor.Result;

        if (Event.current.type != EventType.layout)
        {
            node.ChildSlots = 1;
        }
    }
Example #4
0
 public void detachEvent(SerializableGameEvent ge)
 {
     if ((string)ge.getParameter("switch") == "")
     {
         ge.removeParameter("switch");
         ge.removeParameter("value");
     }
 }
 public void detachEvent(SerializableGameEvent ge)
 {
     if (ge.getParameter("item") == null)
     {
         ge.removeParameter("item");
     }
     if (ge.getParameter("inventory") == null)
     {
         ge.removeParameter("inventory");
     }
 }
Example #6
0
 public void useEvent(SerializableGameEvent ge)
 {
     this.ge      = ge;
     this.ge.Name = this.EventName;
     if (ge.getParameter("switch") == null)
     {
         ge.setParameter("switch", "");
     }
     if (ge.getParameter("value") == null)
     {
         ge.setParameter("value", true);
     }
 }
    //int selectedTexture;
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();

        serializedObject.Update();

        SerializedProperty cell       = serializedObject.FindProperty("destination");
        SerializedProperty modep      = serializedObject.FindProperty("mode");
        SerializedProperty gep        = serializedObject.FindProperty("sge");
        SerializedProperty checkablep = serializedObject.FindProperty("checkable");

        EditorGUILayout.PropertyField(cell);

        modep.intValue = GUILayout.Toolbar(modep.intValue, new string[] { "Always", "Event trigger", "Checkable" });

        switch (modep.intValue)
        {
        case 1: {
            SerializableGameEvent ge = gep.objectReferenceValue as SerializableGameEvent;

            if (ge == null)
            {
                ge = ScriptableObject.CreateInstance <SerializableGameEvent> ();
            }

            string[] editors        = EventEditorFactory.Intance.CurrentEventEditors;
            int      editorSelected = 0;
            if (ge.Name == null)
            {
                ge.Name = "";
            }
            for (int i = 1; i < editors.Length; i++)
            {
                if (editors [i].ToLower() == ge.Name.ToLower())
                {
                    editorSelected = i;
                }
            }
            int was = editorSelected;

            editorSelected = EditorGUILayout.Popup(editorSelected, EventEditorFactory.Intance.CurrentEventEditors);
            if (was != editorSelected && editorSelected == 0)
            {
                ge.Name = "";
            }
            EventEditor editor = EventEditorFactory.Intance.createEventEditorFor(editors[editorSelected]);
            editor.useEvent(ge);

            editor.draw();
            ge = editor.Result;

            gep.objectReferenceValue = ge;
        }
        break;

        case 2: {
            Checkable c              = (Checkable)checkablep.objectReferenceValue;
            string[]  editors        = ForkEditorFactory.Intance.CurrentForkEditors;
            int       editorSelected = EditorGUILayout.Popup(
                ForkEditorFactory.Intance.ForkEditorIndex(c),
                ForkEditorFactory.Intance.CurrentForkEditors
                );

            ForkEditor editor = ForkEditorFactory.Intance.createForkEditorFor(editors[editorSelected]);

            editor.useFork(c);

            editor.draw();

            checkablep.objectReferenceValue = editor.Result;
        } break;
        }


        if (EditorGUI.EndChangeCheck())
        {
        }

        serializedObject.ApplyModifiedProperties();
    }
 public DefaultEventEditor()
 {
     this.ge = ScriptableObject.CreateInstance <SerializableGameEvent>();
 }