Пример #1
0
    void DrawSave()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Save Path");
        EditorGUILayout.EndHorizontal();
        //enter path
        path = EditorGUILayout.TextField(path);

        if (GUILayout.Button("Save", GUILayout.Height(40)))
        {
            dialogueOption opt;
            //make sure the nodes have an exit
            for (int i = 0; i < dialogue._nodes.Count; i++)
            {
                if (dialogue._nodes[i]._options.Count == 0)
                {
                    opt       = new dialogueOption();
                    opt._dest = -1;
                    dialogue._nodes[i]._options.Add(opt);
                }
            }
            Save(path);
            this.Close();
            //Debug.Log("Saved to " +path);
        }
    }
Пример #2
0
    bool updateButton(Node node, dialogueOption option, int index)
    {
        if (option._req != null && option._req != "")
        {
            //if the dictionary[option._req] == false, return
            if (!tasks[option._req])
            {
                return(false);
            }
        }

        GameObject newButton = (GameObject)Instantiate(buttonPrefab);

        newButton.transform.SetParent(ParentPanel, false);
        newButton.transform.localScale = new Vector3(1, 1, 1);

        newButton.GetComponentInChildren <Text>().text = option._text;
        Button tmpButton = newButton.GetComponent <Button>();

        tmpButton.onClick.AddListener(delegate {
            setSelect(option._dest);
        });

        options[index] = newButton;

        //display the options in displayOptions
        newButton.SetActive(false);
        return(true);
    }
Пример #3
0
    //update the butotn info
    bool updateButton(Node node, dialogueOption option, int index)
    {
        //check if there's a requirement for this option to be available
        if (option._req != null && option._req != "")
        {
            //if the dictionary[option._req] == false, return
            if (!tasks[option._req])
            {
                return(false);
            }
        }

        //create a new button, set its parent and set its scale
        GameObject newButton = (GameObject)Instantiate(buttonPrefab);

        newButton.transform.SetParent(ParentPanel, false);
        newButton.transform.localScale = new Vector3(1, 1, 1);

        //set the button's text
        newButton.GetComponentInChildren <Text>().text = option._text;
        Button tmpButton = newButton.GetComponent <Button>();

        //add an event listener to the button, once it's selected, go to the
        //dialogue option's destination node
        tmpButton.onClick.AddListener(delegate {
            setSelect(option._dest);
        });

        options[index] = newButton;

        //display the options in displayOptions
        newButton.SetActive(false);
        return(true);
    }
Пример #4
0
    //for opening the window for the first time
    public static void OpenWindow(dialogueOption o = null, Node p = null)
    {
        option = o;
        parent = p;

        if (option != null)
        {
            //set values
            text = option._text;
            req  = option._req;
            dest = option._dest;
        }
        window         = (OptionSettings)GetWindow(typeof(OptionSettings));
        window.minSize = new Vector2(300, 300);
        window.Show();
    }
Пример #5
0
 public void removeDialogueOption(dialogueOption option)
 {
     _options.Remove(option);
 }
Пример #6
0
 public void addDialogueOption(dialogueOption option)
 {
     _options.Add(option);
 }
Пример #7
0
    void DrawBody()
    {
        GUILayout.BeginArea(mainSection);

        //if windowstotattach is 2 and the connecting node isn't parented to that
        if (windowsToAttach.Count == 2 &&
            !(nodeConnections[windowsToAttach[0]].Contains(windowsToAttach[1])))
        {
            attachedWindows.Add(windowsToAttach[0]);
            attachedWindows.Add(windowsToAttach[1]);

            //create new dialogueOption
            //then open up dialogue window editor
            dialogueOption opt = new dialogueOption();
            OptionSettings.OpenWindow(opt, nodes[windowsToAttach[0]]);
            opt._dest = windowsToAttach[1];

            //add the dialogue option to the thingy thing
            nodes[windowsToAttach[0]]._options.Add(opt);

            nodeConnections[windowsToAttach[0]].Add(windowsToAttach[1]);

            windowsToAttach = new List <int>();
        }

        if (attachedWindows.Count >= 2)
        {
            for (int i = 0; i < attachedWindows.Count; i += 2)
            {
                DrawNodeCurve(windows[attachedWindows[i]], windows[attachedWindows[i + 1]]);
            }
        }

        if (redrawLinks)
        {
            Debug.Log("Redrawing");
            for (int i = 0; i < nodes.Count; i++)
            {
                //Debug.Log("Node " + i);
                for (int j = 0; j < nodeConnections[i].Count; j++)
                {
                    //Debug.Log("EY");
                    DrawNodeCurve(windows[i], windows[nodeConnections[i][j]]);
                }
            }
            redrawLinks = false;
        }

        //for the node editor
        //mark beginning area for all popup windows
        BeginWindows();

        //iterate over the contained windows and draw them
        for (int i = 0; i < windows.Count; i++)
        {
            windows[i] = GUI.Window(i, windows[i], DrawNodeWindow, "Node " + i);
        }

        EndWindows();

        GUILayout.EndArea();
    }