Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     dialogue          = GetComponent <DialogueTree> ();
     stress            = GetComponent <StressingOut> ();
     eye               = GetComponent <EyeContact> ();
     conversationLevel = 50f;
 }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        DialogueTree tree = (DialogueTree)target;

        foreach (DialogueNode node in tree.nodes)
        {
            int outputCount        = node.GetOutputCount();
            int missingOutputCount = node.choices.Count - outputCount;

            if (missingOutputCount > 0)
            {
                for (int i = 0; i < missingOutputCount; i++)
                {
                    node.AddDynamicOutput(typeof(DialogueNode), fieldName: "Choice_" + (outputCount + i));
                }
            }
            else if (missingOutputCount < 0)
            {
                for (int i = 1; i < -missingOutputCount + 1; i++)
                {
                    node.RemoveDynamicPort("Choice_" + (outputCount - i));
                }
            }
        }
    }
Esempio n. 3
0
 public DialogueTree(string data)
 {
     left    = null;
     right   = null;
     diaData = data;
     //branches = new List<DialogueBranch>();
 }
    private void StartConvorsation(DialogueCharacter character)
    {
        DialogueTree tree = character.GetDialogue();

        tree.SetCharacters(new CharacterInfo[] { info, character.GetCharacter() });
        player.PlayTree(tree);
    }
Esempio n. 5
0
    public void StartDialogue(DialogueCharacter character, Action OnSpecificDialogueEnded = null)
    {
        DialogueTree tree = character.GetDialogue();

        tree.SetCharacters(new CharacterInfo[] { playerInfo, character.GetCharacter() });
        player.PlayTree(tree, OnSpecificDialogueEnded);
    }
Esempio n. 6
0
    IEnumerator RunTree(DialogueTree t, DialogueNode n)
    {
        reading = true;
        yield return(StartCoroutine(RunNode(n)));

        if (n.specs.waitForPlayerInput)
        {
            int choice = -1;
            while (choice < 0)
            {
                choice = DialogueChoiceInput();
                yield return(new WaitForEndOfFrame());
            }

            n.ChangePointer(choice);
        }

        if (n.pointer > -1)
        {
            if (t.ValidNode(n.pointer))
            {
                StartCoroutine(RunTree(t, t.GetNode(n.pointer)));
            }
        }
        else
        {
            Debug.Log("Exit Dialogue Tree");
            dialogueMenu.CloseMenu();
            reading = false;
        }
    }
    override public Node Cast2Node(DialogueTree _dt)
    {
        StartNode n = new StartNode(_dt, myPos);

        n.nodeName = name;
        return(n);
    }
    public SubNode Cast2SubNode(DialogueTree _dt, Node preNode)
    {
        if (myOption != "")
        {
            return(new SubNode(_dt, myPos, myOption, preNode));
        }
        else
        {
            List <ConditionUnit> conditionUnits = new List <ConditionUnit> ();
            foreach (string str in diverConditions)
            {
                conditionUnits.Add(new ConditionUnit(str));
            }
            foreach (ConditionUnit con in conditionUnits)
            {
                string charName = con.condition.Split(new char[] { '(', ')' }) [0];
                if (charName != "Plot")
                {
                    con.myQuestion = (QuestionNode)_dt.GetNodeByName(charName);
                }
            }

            return(new SubNode(_dt, myPos, conditionUnits, preNode));
        }
    }
Esempio n. 9
0
    //=======================More Node Components======================
    //put load here

    //update the state of the tree
    //clear everything that's been drawn and redraw the tree
    //go through the whole list of nodes and draw the stuff from there
    static public void UpdateTree(DialogueTree d)
    {
        redrawLinks = true;

        dialogue = d;
        //Debug.Log(dialogue._nodes.Count);
        //reset the node lists
        //this could actually take a while, optimize
        nodes   = dialogue._nodes;
        options = new List <dialogueOption>();

        windows         = new List <Rect>();
        nodeConnections = new Dictionary <int, List <int> >();

        //attach the windows
        for (int i = 0; i < dialogue._nodes.Count; i++)
        {
            //Debug.Log("AAAA");
            windows.Add(new Rect(10, 10, 100, 100));
            nodeConnections[i] = new List <int>();
        }

        //iterate and draw node curves and remake the node connection array
        for (int i = 0; i < dialogue._nodes.Count; i++)
        {
            for (int j = 0; j < dialogue._nodes[i]._options.Count; j++)
            {
                if (nodes[i]._options[j]._dest != -1)
                {
                    //DrawNodeCurve(windows[i], windows[nodes[i]._options[j]._dest]);
                    nodeConnections[i].Add(nodes[i]._options[j]._dest);
                }
            }
        }
    }
Esempio n. 10
0
 public DialogueTree()
 {
     diaData = null;
     left    = null;
     right   = null;
     // branches = new List<DialogueBranch>();
 }
Esempio n. 11
0
        internal static DialogueTree LinkDialogueTree(DialogueTree tree)
        {
            // ENTRY
            foreach (DialogueText text in tree.Entry.Text)
            {
                LinkText(tree, text);
            }

            LinkAction(tree, tree.Entry.Action);

            // DIALOGUES
            foreach (Dialogue dialogue in tree.Dialogues)
            {
                foreach (DialogueText text in dialogue.Text)
                {
                    LinkText(tree, text);
                }

                LinkAction(tree, dialogue.Action);
            }

            // ACTION SETS
            foreach (ActionSet action in tree.Actions)
            {
                LinkAction(tree, action.Action);
            }

            return(tree);
        }
        //static because it's also used from DialogueTreeController
        public static void ShowActorParameters(DialogueTree dialogue)
        {
            EditorUtils.TitledSeparator("Dialogue Actor Parameters");
            EditorGUILayout.HelpBox("Enter the Key-Value pair for Dialogue Actors involved in the Dialogue.\nReferencing a DialogueActor is optional.", MessageType.Info);

            GUILayout.BeginVertical("box");

            if (GUILayout.Button("Add Actor Parameter"))
            {
                dialogue.actorParameters.Add(new DialogueTree.ActorParameter("actor parameter name"));
            }

            EditorGUILayout.LabelField("INSTIGATOR <--Replaced by the Actor starting the Dialogue");

            for (var i = 0; i < dialogue.actorParameters.Count; i++)
            {
                var reference = dialogue.actorParameters[i];
                GUILayout.BeginHorizontal();
                if (dialogue.actorParameters.Where(r => r != reference).Select(r => r.name).Contains(reference.name))
                {
                    GUI.backgroundColor = Color.red;
                }
                reference.name      = EditorGUILayout.TextField(reference.name);
                GUI.backgroundColor = Color.white;
                reference.actor     = (IDialogueActor)EditorGUILayout.ObjectField(reference.actor as Object, typeof(DialogueActor), true);
                if (GUILayout.Button("X", GUILayout.Width(18)))
                {
                    dialogue.actorParameters.Remove(reference);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }
Esempio n. 13
0
    public void StartConversation(string npcName)
    {
        if (StoredDialogue.ContainsKey(npcName))
        {
            Dialogue            dialogue = StoredDialogue[npcName];
            List <DialogueTree> trees    = dialogue.trees.Where(x => x.read == false).OrderBy(x => x.treeid).ToList();
            for (int i = 0; i < trees.Count; i++)
            {
                bool result = true;
                try
                {
                    result = CheckCondition(trees[i].condition);
                }
                catch
                {
                    string message = String.Format("Could not parse condition '{0}' conversation for '{1}' in tree {2}",
                                                   trees[i].condition, npcName, i);
                    Debug.LogWarning(message);
                }

                if (result)
                {
                    CurrentTree      = trees[i];
                    CurrentTreeIndex = i;
                    CurrentStep      = 0;
                    CurrentNPC       = npcName;
                    Globals.DialogueCanvasController.Initialise(Player.GetComponent <PlayerDetails>().PlayerName, npcName);
                    Globals.GameState = GameStates.InDialogue;
                    ShowCurrentConversationStep();

                    break;
                }
            }
        }
    }
 public void StartDialogue(DialogueTree tree)     //function that initiates dialogue
 {
     currentGameState = GameState.DialogueActive; //sets current game state to dialogue active
     treeToRun        = tree;                     //sets the tree that we're running to the tree in the parameter
     // timeManager.modifier = 0f; //stops time from decreasing
     lineComplete = false;                        //fix dialogue loading bug
 }
    private void ShowSaveLoadButtons()
    {
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Save") && tree != null && tree.root.Data != null)
        {
            savedTree = savedTree.ExportInstance(tree);
            EditorUtility.SetDirty(savedTree);

            CalculateNodeIDs();

            Debug.Log("Saved tree");
        }

        if (GUILayout.Button("Load"))
        {
            Cleanup();
            lastSavedTree = savedTree;
            SerializableTree treeInstance = savedTree.InstantiateTree();
            tree = treeInstance.ImportTree();
            if (tree == null)
            {
                tree = DialogueTester.CreateTestTree(treeInstance.gameObject.transform);
                Debug.Log("Created new tree");
            }
        }

        GUILayout.EndHorizontal();
    }
Esempio n. 16
0
    private void DrawControls()
    {
        GUIContent content = new GUIContent("Character");

        EditorGUI.LabelField(new Rect(5, 5, 60, 15), content);
        tree.characterFile = (DialogueManager.Character)EditorGUI.EnumPopup(
            new Rect(70, 5, 90, 15), tree.characterFile, EditorStyles.popup);
        content = new GUIContent("Type");
        EditorGUI.LabelField(new Rect(5, 25, 60, 15), content);
        tree.type = (DialogueTree.Type)EditorGUI.EnumPopup(
            new Rect(70, 25, 90, 15), tree.type, EditorStyles.popup);
        content = new GUIContent("Dialogue Scene");
        EditorGUI.LabelField(new Rect(5, 45, 100, 20), content);
        tree.scene = EditorGUI.IntField(new Rect(100, 45, 60, 15), tree.scene);
        content    = new GUIContent("Load Dialogue");
        if (GUI.Button(new Rect(5, 65, 150, 20), content))
        {
            DialogueTree d = DialogueWriter.LoadTree(Path.Combine(tree.GetDirectory(), tree.GetFileName()));
            if (d != null)
            {
                tree.Nodes          = d.Nodes;
                tree.Connections    = d.Connections;
                needsConnectionFuse = true;
            }
        }
        content = new GUIContent("Save Dialogue");
        if (GUI.Button(new Rect(5, 90, 150, 20), content))
        {
            DialogueWriter.WriteTree(tree, tree.GetFileName(), tree.GetDirectory());
        }
        if (needsConnectionFuse)
        {
            FuseConnections();
        }
    }
Esempio n. 17
0
 public DialogueTree(int id)
 {
     this.id = id;
     diaData = null;
     left    = null;
     right   = null;
     //branches = new List<DialogueBranch>();
 }
Esempio n. 18
0
    static void Init()
    {
        DialogueTree window = (DialogueTree)GetWindow(typeof(DialogueTree));

        window.minSize      = new Vector2(400, 250);
        window.titleContent = new GUIContent("Dialogue Tree");
        window.Show();
    }
Esempio n. 19
0
 public DialogueTree(string data, int id, DialogueTree left, DialogueTree right)
 {
     diaData    = data;
     this.id    = id;
     this.left  = left;
     this.right = right;
     //branches = new List<DialogueBranch>();
 }
Esempio n. 20
0
 override public void Reconnect(DialogueTree _dt)
 {
     if (nextKey == "END")
     {
         return;
     }
     _dt.GetNodeByName(name).SetConnect(_dt.GetNodeByName(GetNameWithoutChar(nextKey)));
 }
Esempio n. 21
0
 //private float startingTimer = 1.5f;
 void Start()
 {
     tree = GetComponent <DialogueTree>();
     RollInterval();
     myCollider = GetComponent <Collider2D>();
     anim       = GetComponent <Animator>();
     SelectTarget();
 }
Esempio n. 22
0
 private void OnEnable()
 {
     tree = new DialogueTree();
     ClickInPointEvent     = OnClickInPoint;
     ClickOutPointEvent    = OnClickOutPoint;
     RemoveNodeEvent       = OnClickRemoveNode;
     RemoveConnectionEvent = OnClickRemoveConnection;
 }
Esempio n. 23
0
    // Activate dialogue tree

    public void ActivateDialogueTree(DialogueTree dialogueTree)
    {
        currentDialogueTree = dialogueTree;

        CreateDialogueTreeUI();

        Debug.Log(JsonUtility.ToJson(currentDialogueTree));
    }
Esempio n. 24
0
 public DialogueOption(string text, DialogueNode dest, DialogueTree dialogueTree)
 {
     this.text = text;
     this.dest = dest;
     command   = new DialogueCommand(null, DialogOrder.none);
     origin    = dialogueTree.CurrentNode;
     dialogueTree.AddOption(this);
 }
Esempio n. 25
0
 public DialogueOption(string text, DialogueNode dest, DialogueCommand command, DialogueTree dialogueTree)
 {
     this.text    = text;
     this.dest    = dest;
     this.command = command;
     origin       = dialogueTree.CurrentNode;
     dialogueTree.AddOption(this);
 }
    public static DialogueTree LoadFromFile(string name)
    {
        DialogueTree tree = new DialogueTree {
            root = CreateNodeFromFile(Application.streamingAssetsPath + "//DialogueTrees//" + name + "//", "_root.txt")
        };

        return(tree);
    }
Esempio n. 27
0
    protected override Status OnExecute(Component agent, IBlackboard bb)
    {
        tempStatement = new Statement(SmartLocalization.LanguageManager.Instance.GetTextValue(statement.text + "." + count));
        tempStatement = tempStatement.BlackboardReplace(bb);

        DialogueTree.RequestSubtitles(new SubtitlesRequestInfo(finalActor, tempStatement, OnStatementFinish));
        return(Status.Running);
    }
Esempio n. 28
0
 //for opening the window
 static public void OpenWindow(bool s, DialogueTree d = null)
 {
     saving         = s;
     dialogue       = d;
     window         = (TreeManager)GetWindow(typeof(TreeManager));
     window.minSize = new Vector2(300, 300);
     window.Show();
 }
Esempio n. 29
0
        protected override void OnExecute()
        {
            var index         = Random.Range(0, statements.Count);
            var statement     = statements[index];
            var tempStatement = statement.BlackboardReplace(blackboard);
            var info          = new SubtitlesRequestInfo((IDialogueActor)agent, tempStatement, EndAction);

            DialogueTree.RequestSubtitles(info);
        }
Esempio n. 30
0
    // Comienza el diálogo "dialogueTree", mostrando en pantalla su texto y mostrando en "OptionsPosition" las opciones
    public void StartDialogue(DialogueTree dialogueTree, Vector3?pathsDisplayPosition = null)
    {
        animator.SetBool("isOpen", true);
        CurrentDialogueTree  = dialogueTree;
        PathsDisplayPosition = pathsDisplayPosition;

        CurrentDialogue = CurrentDialogueTree.Root;
        DialogueUpdate();
    }
		void OnDialogueFinished(DialogueTree dialogue){

			StopAllCoroutines();
			displayText = null;
			if (currentActor != null)
				currentActor.speech = null;

			currentOptions = null;
			StopCoroutine("GUICountDown");

			enabled = false;
		}
Esempio n. 32
0
 void Awake() { if (instance == null) instance = this; }
		void OnDialogueStarted(DialogueTree dialogue){
			//We could do something here...
		}
		void OnDialoguePaused(DialogueTree dialogue){
			OnDialogueFinished(dialogue);
		}