Ejemplo n.º 1
0
 public void StartLink(DialogueNode dialogueNode, float offSetY)
 {
     dialogueNode.exitList.Add(this);
     DialogueEditor.AddLinkNode(this);
     previousNode        = dialogueNode;
     linkState           = LinkState.creating;
     previousNodeOffSetY = offSetY;
 }
Ejemplo n.º 2
0
 public override void DrawWindow()
 {
     if (GUILayout.Button("Close", GUILayout.Width(60)))
     {
         editing = false;
         DialogueEditor.DeletteNode(this);
     }
     text = EditorGUILayout.TextArea(text, GUILayout.Height(windowRect.height));
 }
Ejemplo n.º 3
0
 public void SetTarget(BaseNode node)
 {
     if (node == null || previousNode == node)
     {
         DialogueEditor.DeletteNode(this);
         return;
     }
     targetNode = node as DialogueNode;
     ((DialogueNode)node).enterList.Add(this);
     linkState = LinkState.enable;
 }
        private void OnGUI()
        {
            Event e = Event.current;

            mousePosition = e.mousePosition;

            if (position.Contains(mousePosition))
            {
                DialogueEditor editor = EditorWindow.GetWindow <DialogueEditor>();
                editor.wantsMouseMove = true;
            }
            UserInput(e);
            DrawWindows();
        }
Ejemplo n.º 5
0
        public override void DrawCurve()
        {
            Rect targetRect   = new Rect();
            Rect previousRect = previousNode.windowRect;

            previousRect.y += previousNodeOffSetY;

            if (previousNode == null)
            {
                DialogueEditor.DeletteNode(this);
            }

            if (linkState == LinkState.creating)
            {
                DialogueEditor.DrawNodeCurve(previousRect, DialogueEditor.mousePosition, true, Color.cyan);
            }
            else if (linkState == LinkState.enable)
            {
                if (targetNode == null)
                {
                    DialogueEditor.DeletteNode(this);
                }
                targetRect = targetNode.windowRect;


                int indexOnEnterList = 0;
                for (int i = 0; i < targetNode.enterList.Count; i++)
                {
                    if (targetNode.enterList[i] == this)
                    {
                        indexOnEnterList = i;
                        break;
                    }
                }

                targetRect.y += targetNode.windowRect.height / (targetNode.enterList.Count + 1) * (indexOnEnterList + 1);


                targetRect.width  = 1;
                targetRect.height = 1;
                DialogueEditor.DrawNodeCurve(previousRect, targetRect, true, Color.cyan);
            }
        }
Ejemplo n.º 6
0
        private void DrawDialogueText()
        {
            var style = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
            };

            EditorGUILayout.LabelField("DialogueText", style, GUILayout.ExpandWidth(true));

            GUILayout.BeginHorizontal();
            dialogueText.text = EditorGUILayout.TextField(dialogueText.text, GUILayout.Height(20));
            if (GUILayout.Button("E", GUILayout.Width(20)))
            {
                DialogueEditor.AddDialogueTextEdit(dialogueText, new Vector2(windowRect.xMax + 40, windowRect.y));
                dialogueText.editing = true;
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            dialogueText.noAnswers = GUILayout.Toggle(dialogueText.noAnswers, "No Anwser");
            if (dialogueText.noAnswers)
            {
                if (GUILayout.Button("L", GUILayout.Width(20)))
                {
                    dialogueText.linkNode = CreateInstance <LinkNode>();
                    dialogueText.linkNode.StartLink(this, 70);
                }
                if (dialogueText.linkNode != null && dialogueText.linkNode.linkState == LinkNode.LinkState.disable)
                {
                    dialogueText.linkNode.linkState = LinkNode.LinkState.enable;
                }
            }
            else
            {
                if (dialogueText.linkNode != null)
                {
                    dialogueText.linkNode.linkState = LinkNode.LinkState.disable;
                }
            }
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 7
0
        private void DrawAnswers()
        {
            EditorGUILayout.Separator();
            var style = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
            };

            EditorGUILayout.LabelField("Answers", style, GUILayout.ExpandWidth(true));

            EditorGUI.BeginDisabledGroup(dialogueText.noAnswers);
            if (GUILayout.Button("Add answer"))
            {
                Answer answer = CreateInstance <Answer>();
                answers.Add(answer);
            }
            int indexAnwser = 0;

            foreach (Answer answer in answers)
            {
                GUILayout.BeginHorizontal();
                answer.text = EditorGUILayout.TextField(answer.text, GUILayout.Height(20));
                if (GUILayout.Button("E", GUILayout.Width(20)))
                {
                    DialogueEditor.AddAnwserEdit(answer, new Vector2(windowRect.xMax + 40, windowRect.y));
                    answer.editing = true;
                }
                if (GUILayout.Button("L", GUILayout.Width(20)))
                {
                    answer.linkNode = CreateInstance <LinkNode>();
                    answer.linkNode.StartLink(this, 135 + exitList.Count * 20);
                }
                GUILayout.EndHorizontal();
                indexAnwser++;
            }
            EditorGUI.EndDisabledGroup();
        }
        static void ShowEditor()
        {
            DialogueEditor editor = EditorWindow.GetWindow <DialogueEditor>();

            editor.minSize = new Vector2(300, 300);
        }