Exemplo n.º 1
0
 public static void InitEditorWindow()
 {
     curWindow = (EncounterNodeEditorWindow)EditorWindow.GetWindow <EncounterNodeEditorWindow> ();            // egy példány kérése
     curWindow.titleContent.text = "Encounter Editor";
     LoadEditorSkin();
     CreateViews();
 }
Exemplo n.º 2
0
        /**
         *
         *
         */

        public static void CreateNewGraph(string name)
        {
            EncounterNodeGraph curGraph = new EncounterNodeGraph();

            if (curGraph != null)
            {
                curGraph.graphName = name;
                curGraph.InitGraph();

                EncounterNodeEditorWindow curWindow = (EncounterNodeEditorWindow)EditorWindow.GetWindow <EncounterNodeEditorWindow> ();

                if (curWindow != null)
                {
                    curWindow.curGraph = curGraph;
                }

                NodeBase nnode = curWindow.CreateNode(NodeType.Start, new Vector2(70f, 70f));
                curWindow.curGraph.startNode = nnode;
                Save();                 //save data file
            }
            else
            {
                EditorUtility.DisplayDialog("Node message:", "Unable to create graph", "OK");
            }
        }
Exemplo n.º 3
0
 public static void InitNodeEditor()
 {
     /**
      * Create a Window for us
      */
     EncounterNodeEditorWindow.InitEditorWindow();
 }
Exemplo n.º 4
0
 static void CreateViews()
 {
     if (curWindow != null)
     {
         curWindow.propertyView = new EncounterNodePropertyView();
         curWindow.workView     = new EncounterNodeWorkView();
     }
     else
     {
         curWindow = (EncounterNodeEditorWindow)EditorWindow.GetWindow <EncounterNodeEditorWindow> ();
     }
 }
Exemplo n.º 5
0
        void ContextCallbackLogic(object obj)
        {
            switch (obj.ToString())
            {
            case "boolNode":
                EncounterNodeEditorWindow.getInstance().CreateNode(NodeType.Bool, mousePos);
                break;

            default:

                break;
            }
        }
Exemplo n.º 6
0
        void ContextCallback(object obj)
        {
            switch (obj.ToString())
            {
            case "0":
                EncounterCreateNodePopupWindow.InitNodePopup();
                break;

            case "load":
                EncounterNodeEditorWindow.LoadGraph();
                break;

            case "unload":
                EncounterNodeEditorWindow.UnloadGraph();
                break;

            case "text node":
                EncounterNodeEditorWindow.getInstance().CreateNode(NodeType.Text, mousePos);
                break;

            case "dialog node":
                EncounterNodeEditorWindow.getInstance().CreateNode(NodeType.Dialog, mousePos);
                break;

            case "branching node":
                EncounterNodeEditorWindow.getInstance().CreateNode(NodeType.Branching, mousePos);
                break;

            case "end node":
                EncounterNodeEditorWindow.getInstance().CreateNode(NodeType.End, mousePos);
                break;

            case "delete":
                EncounterNodeEditorWindow.getInstance().DeleteNode(deleteNodeID);
                break;

            default:

                break;
            }
        }
        void OnGUI()
        {
            GUILayout.Space(20);
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);

            GUILayout.BeginVertical();

            EditorGUILayout.LabelField("Create New Graph", EditorStyles.boldLabel);
            name = EditorGUILayout.TextField("Enter Name:", name);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Create Graph", GUILayout.Height(40)))
            {
                if ((!string.IsNullOrEmpty(name)) && (name != "Enter a name..."))
                {
                    EncounterNodeEditorWindow.CreateNewGraph(name);
                    curPopup.Close();
                }
                else
                {
                    EditorUtility.DisplayDialog("Node message", "Please enter a valid graph name", "OK");
                }
            }
            if (GUILayout.Button("Cancel", GUILayout.Height(40)))
            {
                curPopup.Close();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.Space(20);
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
Exemplo n.º 8
0
        public static void LoadGraph()
        {
            EncounterNodeGraph curGraph = null;
            BinaryFormatter    bf       = new BinaryFormatter();
            FileStream         fs       = File.Open(Application.dataPath + "/EncounterEditor/Database/data.dat", FileMode.Open);

            curGraph = (EncounterNodeGraph)bf.Deserialize(fs);
            fs.Close();

            if (curGraph != null)
            {
                EncounterNodeEditorWindow curWindow = (EncounterNodeEditorWindow)EditorWindow.GetWindow <EncounterNodeEditorWindow> ();

                if (curWindow != null)
                {
                    curWindow.curGraph = curGraph;
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Node message", "Unable load data.dat", "OK");
            }
        }
Exemplo n.º 9
0
        public override void ProcessEvents(Event e)
        {
            base.ProcessEvents(e);

            if (viewRect.Contains(e.mousePosition))
            {
                if (e.button == 0)
                {
                    if (e.type == EventType.MouseDown)
                    {
                        if (curGraph != null)
                        {
                            for (int i = 0; i < curGraph.nodes.Count; ++i)
                            {
                                if (e.button == 0 && e.type == EventType.MouseDown)
                                {
                                    curGraph.nodes[i].isSelected = false;

                                    if (curGraph.nodes[i].nodeRect.Contains(e.mousePosition))
                                    {
                                        EncounterNodeGraph.selectedNode            = curGraph.nodes[i];
                                        EncounterNodeGraph.selectedNode.isSelected = true;
                                        EncounterNodeEditorWindow.getInstance().propertyView._loaded = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (e.type == EventType.MouseDrag)
                    {
                    }
                    if (e.type == EventType.MouseUp)
                    {
                    }
                    if (e.type == EventType.ScrollWheel)
                    {
                    }
                }
                else if (e.button == 1)
                {
                    if (e.type == EventType.MouseDown)
                    {
                        mousePos = e.mousePosition;
                        bool overNode = false;
                        deleteNodeID = 0;
                        if (curGraph != null)
                        {
                            if (curGraph.nodes.Count > 0)
                            {
                                for (int i = 0; i < curGraph.nodes.Count; i++)
                                {
                                    if (curGraph.nodes [i].nodeRect.Contains(mousePos) && (curGraph.nodes[i].nodeType != NodeType.Start))
                                    {
                                        deleteNodeID = i;
                                        overNode     = true;
                                    }
                                }
                            }
                        }

                        if (!overNode)
                        {
                            ProcessContextMenu(e, 0);
                        }
                        else
                        {
                            ProcessContextMenu(e, 1);
                        }
                    }
                }
            }
        }