Ejemplo n.º 1
0
    public void Start()
    {
        //SpellCreator.Event e = EventSaver.LoadEventAsXML(testeventname);
        //e.Execute();

        SpellCreator.Event ev = EventSaver.LoadEventAsObject(testeventname);
        ev.Execute();
    }
Ejemplo n.º 2
0
    public static void CreateEvent(string _name)
    {
        // make sure to save old, shouldn't be neccessary anymore
        if (editingEvent != null)
        {
            if (editingEvent.eventName != null)
            {
                EventSaver.SaveEventAsObject(editingEvent);
            }
        }

        editingEvent           = ScriptableObject.CreateInstance <SpellCreator.Event>();
        editingEvent.eventName = _name;

        EventSaver.SaveEventAsObject(editingEvent);
        createEventText = "";

        //FIX Make the new event the selected event
    }
Ejemplo n.º 3
0
    void OnGUI()
    {
        if (upIcon == null)
        {
            upIcon = (Texture)AssetDatabase.LoadAssetAtPath(IconPath + "upIcon.png", typeof(Texture));
        }
        if (downIcon == null)
        {
            downIcon = (Texture)AssetDatabase.LoadAssetAtPath(IconPath + "downIcon.png", typeof(Texture));
        }


        scrollPos = GUILayout.BeginScrollView(scrollPos);


        GUILayout.Label("Event", "boldLabel");

        //Select Event
        var directory = new DirectoryInfo(EventSaver.SAVED_DATA_DIR);
        var files     = directory.GetFiles();

        if (files.Length > 0)
        {
            //FIX Move this outside OnGui()

            List <string> options = new List <string>();

            string[] guids = AssetDatabase.FindAssets("t:Event", new string[] { EventSaver.SAVED_DATA_DIR.TrimEnd('/') });;
            foreach (string guid in guids)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(guid);
                options.Add(assetPath.Replace(EventSaver.SAVED_DATA_DIR, "").Replace(".asset", ""));
            }



            selectedEvent = EditorGUILayout.Popup("Event:", selectedEvent, options.ToArray());

            if (editingEvent == null)
            {
                editingEvent = EventSaver.LoadEventAsObject(options[selectedEvent]);
            }
            else if (editingEvent.eventName != options[selectedEvent])
            {
                editingEvent = EventSaver.LoadEventAsObject(options[selectedEvent]);
            }
            //FIX Save selected to file for later
        }


        if (editingEvent != null)
        {
            GUILayout.Label("Path: " + EventSaver.SAVED_DATA_DIR + editingEvent.eventName + ".asset");
        }

        //Create Event
        Separator(5, 2);
        createEventText = EditorGUILayout.TextField("New Event:", createEventText);
        if (GUILayout.Button("Create") && createEventText != "")
        {
            CreateEvent(createEventText);
        }



        //Actions
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); //Used as divider
        GUILayout.Label("Actions", "boldLabel");


        Separator(5, 2);
        if (editingEvent != null)
        {
            if (editingEvent.actions != null)
            {
                foreach (Action action in editingEvent.actions)
                {
                    if (action != null)
                    {
                        if (ActionWindow(action))
                        {
                            break;
                        }
                    }
                }
            }
        }

        //Add Action
        if (!addActionClicked)
        {
            if (GUILayout.Button("Add Action"))
            {
                addActionClicked = true;
            }
        }
        else
        {
            if (editingEvent.actions != null)
            {
                AddActionWindow();
            }
        }


        GUILayout.EndScrollView();
    }