Esempio n. 1
0
        public void MoveNext(string ExitPort)
        {
            DialogueGraph fmGraph = graph as DialogueGraph;

            if (fmGraph.current != this)
            {
                Debug.LogWarning("Node isn't active");
                return;
            }

            NodePort exitPort = GetOutputPort(ExitPort);

            if (exitPort == null)
            {
                Debug.Log("Invalid exit port '" + exitPort + "' for node " + name);
                return;
            }

            if (!exitPort.IsConnected)
            {
                fmGraph.current = null;
                return;
            }


            DialogueNodeBase node = exitPort.Connection.node as DialogueNodeBase;

            node.OnEnter();
        }
        public override void Execute()
        {
            switch (scope)
            {
            case DialoguePropertyScope.Local:
                if (relative)
                {
                    int oldValue = DialogueGraph.localProperties.Get <int>(key);
                    DialogueGraph.localProperties.Set(key, oldValue + value);
                }
                else
                {
                    DialogueGraph.localProperties.Set(key, value);
                }
                break;

            case DialoguePropertyScope.Global:
                if (relative)
                {
                    int oldValue = DialogueManager.Instance.globalProperties.Get <int>(key);
                    DialogueManager.Instance.globalProperties.Set(key, oldValue + value);
                }
                else
                {
                    DialogueManager.Instance.globalProperties.Set(key, value);
                }
                break;
            }

            DialogueGraph.ExecuteNextNode();
        }
Esempio n. 3
0
 //Reset to defaults on awake (for reloading levels)
 void Awake()
 {
     dialogueGraph   = null;
     NPCstate        = 1;
     isTalking       = false;
     playerColliding = false;
 }
Esempio n. 4
0
        public override void MoveNext()
        {
            // Do not continue if the player hasn't made a choice
            if (choice != 0 && choice != 1)
            {
                Debug.LogWarning("Cannot continue, no choice has been made");
                return;
            }

            DialogueGraph fmGraph = (DialogueGraph)graph;

            if (fmGraph.GetCurrent() != this)
            {
                Debug.LogWarning("Node isn't active");
                return;
            }

            NodePort exitPort = GetOutputPort(choice == 0 ? "out1" : "out2");

            if (!exitPort.IsConnected)
            {
                Debug.LogWarning("Node isn't connected");
                return;
            }

            DialogueNode node = (DialogueNode)exitPort.Connection.node;

            node.OnEnter();
        }
Esempio n. 5
0
 //Reset to defaults on awake (for reloading levels)
 void Awake()
 {
     dialogueGraph = null;
     NPCstate = 1;
     isTalking = false;
     playerColliding = false;
 }
Esempio n. 6
0
    // starts the game
    public void Begin()
    {
        m_roundIndex = 0;

        // create graphs and set them
        DialogueGraph graph = GetSequenceGraph(m_roundIndex);

        m_sequence[m_roundIndex].graph = graph;
        dialogueController.RunGraph(graph);
        dialogueController.SetArt(GetCharacter(m_roundIndex));

        // set the items
        var itemsThisRun = new List <string>();

        for (int i = 0; i < 5; i++)
        {
            string name = m_sequence[i].item.name;
            if (itemsThisRun.Contains(name))
            {
                continue;
            }
            else
            {
                itemsThisRun.Add(name);
            }
        }

        dialogueController.SetItems(itemsThisRun.ToArray());

        // toggle the panels
        selectionPanel.SetActive(false);
        interrogationPanel.SetActive(true);
    }
Esempio n. 7
0
 private void HandleDialogueGraphEnd()
 {
     currentDialogueGraph.Stop();
     currentDialogueGraph = null;
     GaugesDecisionMaker  = null;
     ChatNodeCoroutinesManager.StopAllCoroutines();
 }
Esempio n. 8
0
 public override void OnBodyGUI()
 {
     base.OnBodyGUI();
     DialogueNode  node  = (DialogueNode)target;
     DialogueGraph graph = (DialogueGraph)node.graph;
     //if (GUILayout.Button("Set as entry point")) graph.SetEntryPoint(node);
 }
Esempio n. 9
0
        private static void SaveGraphToEditor(DialogueGraph graph)
        {
            var path = AssetDatabase.GetAssetPath(graph);
            var guid = AssetDatabase.AssetPathToGUID(path);

            EditorPrefs.SetString(PREF_ASSET_GUID, guid);
        }
Esempio n. 10
0
    public static bool OnOpenAsset(int instanceID, int line)

    {
        //Get the instanceID of the DialogueGraphContainer to find it in the project.
        string            assetPath = AssetDatabase.GetAssetPath(instanceID);
        DialogueContainer dgc       = AssetDatabase.LoadAssetAtPath <DialogueContainer>(assetPath);

        if (dgc != null)

        {
            //Debug.Log($"Opening graph \"{dgc .name}\"");

            DialogueGraph window = GetWindow <DialogueGraph>();

            window.titleContent = new GUIContent($"{dgc.name} (Dialogue Graph)");

            //Once the window is opened, we load the content of the scriptable object.
            //Even if the new name doesn't show up in the TextField, we need to assign the _fileName

            //to load the appropriate file.
            window._fileName = dgc.name;
            window.RequestDataOperation(false);
            return(true);
        }

        //If object not found, won't open anything since we need the object to draw the window.
        return(false);
    }
Esempio n. 11
0
 public void RunGraph(DialogueGraph graph)
 {
     m_graph       = graph;
     m_currentNode = m_graph.startingNode;
     PresentNode(m_graph.startingNode);
     disabled.Clear();
 }
Esempio n. 12
0
        public override void MoveNext()
        {
            DialogueGraph fmGraph = graph as DialogueGraph;

            if (fmGraph.current != this)
            {
                Debug.LogWarning("Node isn't active");
                return;
            }



            int totalWeight = 0;

            for (int i = 0; i < exits.Count; i++)
            {
                totalWeight += exits[i];
            }

            int randomWeight = Random.Range(0, totalWeight + 1);

            string exitName = "exits 0";

            for (int i = 0; i < exits.Count; i++)
            {
                randomWeight -= exits[i];

                if (randomWeight <= 0)
                {
                    exitName = "exits " + i;
                    break;
                }
            }

            var exitPort = this.GetOutputPort(exitName);



            if (exitPort == null)
            {
                Debug.Log("Invalid exit port '" + exitPort + "' for node " + name);
            }

            if (!exitPort.IsConnected)
            {
                fmGraph.current = null;
                return;
            }


            int index = Random.Range(0, exitPort.ConnectionCount);

            var exitNode = exitPort.GetConnection(index);


            DialogueNodeBase node = exitNode.node as DialogueNodeBase;

            node.OnEnter();
        }
Esempio n. 13
0
        public override void OnEnter()
        {
            base.OnEnter();

            DialogueGraph fmGraph = graph as DialogueGraph;

            UnityEngine.Debug.Log("[" + argumentId + "]" + "(" + fmGraph.valueRegistry.Get(argumentId) + ") " + InfoText);
        }
Esempio n. 14
0
 public void InitSetup(int graphID)
 {
     diaGraph    = diaRef.GetDiaGraphByID(graphID);
     startNode   = diaGraph.GetHead();
     currentNode = startNode;
     goatText    = startNode.lines;
     TextDisplay.SetActive(true);
 }
Esempio n. 15
0
        public override void Trigger()
        {
            DialogueGraph dialogueGraph = ((DialogueGraph)graph);

            dialogueGraph.GameManager.ChatNodeCoroutinesManager.StopAllCoroutines();
            dialogueGraph.HandleChatNodeChange(this);
            dialogueGraph.GameManager.ChatNodeCoroutinesManager.StartCoroutine(
                ContinueConversation());
        }
Esempio n. 16
0
        private void SetGraph(DialogueGraph graph)
        {
            GraphCrud = new GraphCrud(graph, this);
            BuildNodes(graph);

            GraphData   = graph;
            MouseEvents = new InputController(this);
            SaveGraphToEditor(graph);
        }
    private void AddSearchWindow(DialogueGraph editorWindow)
    {
        searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>();
        searchWindow.Configure(editorWindow, this);
        nodeCreationRequest = context =>
                              SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), searchWindow);

        searchWindow.tree = CreateMenuOptions();
    }
Esempio n. 18
0
        private void BuildNodes(DialogueGraph graph)
        {
            DataToNode.Clear();

            Nodes = graph.Nodes
                    .Select(i => CreateNodeInstance(i as NodeDataBase))
                    .ToList();

            BuildNodeConnections();
        }
Esempio n. 19
0
 // Use this for initialization
 void Start()
 {
     isTalking       = false;
     playerColliding = false;
     NPCstate        = 1;
     Parser          = new XmlParser(xml);
     dialogueGraph   = (DialogueGraph)Parser.GetGraph();
     currentNode     = GetStartNode(NPCstate);
     m = new GameConditionManager();
 }
Esempio n. 20
0
 public override void Execute()
 {
     if (Compare())
     {
         DialogueGraph.ExecuteNextNode();
     }
     else
     {
         DialogueGraph.ExecuteNextNode(0, "elseNext");
     }
 }
Esempio n. 21
0
 private void Update()
 {
     if (dialogueGraph != null)
     {
         dialogueGraph.Execute();
         if (dialogueGraph.state == RunningState.Stop)
         {
             dialogueGraph = null;
         }
     }
 }
    public void StartDialogue(DialogueGraph dialogue)
    {
        ClearButtons();
        this.dialogue       = dialogue;
        currentDialogueNode = (DialogueNode)dialogue.GetStartNode();

        animator.SetBool("IsOpen", true);

        nameText.text = currentDialogueNode.NPCName;

        DisplayNextSentence();
    }
Esempio n. 23
0
    public static bool OnOpenAsset(int instanceID, int line)
    {
        string         assetPath        = AssetDatabase.GetAssetPath(instanceID);
        DialogueScript scriptableObject = AssetDatabase.LoadAssetAtPath <DialogueScript>(assetPath);

        if (scriptableObject != null)
        {
            DialogueGraph.OpenDialogueGraphWindow(scriptableObject);
            return(true);
        }
        return(false); //let unity open it.
    }
Esempio n. 24
0
    public void ChangeGraph()
    {
        CloseGraph();
        InitChatNode();
        InitOption();
        //  ChangeState(State.OFF);

        dialogueGraph = dias[i];
        i++;
        if (dialogueGraph)
        {
            StartCoroutine(wait1());
        }
    }
        public override void OnInspectorGUI()
        {
            DialogueContainer dialogueContainer = target as DialogueContainer;

            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("Open Visual Editor"))
            {
                DialogueGraph.ShowWindow(dialogueContainer);
            }

            DrawDefaultInspector();
            EditorGUILayout.EndVertical();
        }
Esempio n. 26
0
        public override void MoveNext()
        {
            DialogueGraph fmGraph = graph as DialogueGraph;

            string exitPortName  = "exitTrue";
            string argumentValue = fmGraph.stringRegistry.Get(RegistryName);

            if (!argumentValue.Equals(String))
            {
                exitPortName = "exitFalse";
            }

            MoveNext(exitPortName);
        }
Esempio n. 27
0
        public override void MoveNext()
        {
            DialogueGraph fmGraph = graph as DialogueGraph;

            string exitPortName  = "exitTrue";
            int    argumentValue = fmGraph.valueRegistry.Get(argumentID);

            if (argumentValue == 0)
            {
                exitPortName = "exitFalse";
            }

            MoveNext(exitPortName);
        }
Esempio n. 28
0
        private void Start()
        {
            inputManager = new InputManager(meController);
            ChatNodeCoroutinesManager = gameObject.AddComponent <ChatNodeCoroutinesManager>();
            dialogueManager           = new DialogueManager(dialogueTextMesh, dialogueTimerTextMesh, dialogueHeadshotAnimator,
                                                            language, ChatNodeCoroutinesManager);
            currentDialogueGraph = null;

            Modifiers.SetConstants(modifiersCollector);
            FriendZonesConstants.SetConstants(friendZonesConstantsCollector);
            friendZonesController.InitializeFriendZones();

            HandleInitialDialogueGraph();
        }
    void Start()
    {
        //jsonFiles = Directory.GetFiles(@"C:\Users\carlic2\Documents\Zaire's Shit\Unity Projects\HashBringingHashBrowns\Assets\Dialogue Sytem\Dialogue Data");
        TextAsset temp = Resources.Load <TextAsset>("DialogueData/MainFile");

        //foreach (string s in jsonFiles)
        //{
        //if(Path.GetExtension(s) == ".json"){
        dia = JsonHelper.FromJson <DialogueNode>(temp.text);

        //}
        // }
        foreach (DialogueNode d in dia)
        {
            Node tempNode = new Node(d);

            allNodes.Add(tempNode);
        }

        foreach (Node t in allNodes)
        {
            foreach (int d in t.adjNodeIDs)
            {
                Node tempNode = FindByID(d);
                if (tempNode != null)
                {
                    t.addLink(tempNode);
                }
            }
        }

        List <Node> hNodes  = FindHeads();
        List <Node> sNodes  = FindSingles();
        int         countId = 0;

        foreach (Node h in hNodes)
        {
            DialogueGraph tempGraph = new DialogueGraph(h, countId);
            allDialogue.Add(tempGraph);
            countId++;
        }

        foreach (Node s in sNodes)
        {
            DialogueGraph tempGraph = new DialogueGraph(s, countId);
            allDialogue.Add(tempGraph);
            countId++;
        }
    }
Esempio n. 30
0
        public override void Execute()
        {
            switch (scope)
            {
            case DialoguePropertyScope.Local:
                DialogueGraph.localProperties.Set(key, value);
                break;

            case DialoguePropertyScope.Global:
                DialogueManager.Instance.globalProperties.Set(key, value);
                break;
            }

            DialogueGraph.ExecuteNextNode();
        }
Esempio n. 31
0
 // Use this for initialization
 void Start()
 {
     isTalking = false;
     playerColliding = false;
     NPCstate = 1;
     Parser = new XmlParser(xml);
     dialogueGraph = (DialogueGraph)Parser.GetGraph();
     currentNode = GetStartNode(NPCstate);
     m =  new GameConditionManager();
 }
Esempio n. 32
0
    public DialogueGraph ConvoGraph()
    {
        s.Start ();
        DialogueGraph convoGraph = new DialogueGraph();
        XmlNodeList dialogues = xml.DocumentElement.SelectNodes ("/conversation/dialogue");

        /*
         * Loops through all the dialogue nodes first without
         * processing any replies, this is because to be able
         * to link the player questions to corresponding replies
         * the dialogues need to be accessible in the graph before
         * they can be linked to.
         */
        foreach (XmlNode dialogueNode in dialogues)
        {
            DialogueNode dNode = new DialogueNode();
            if(dialogueNode.Attributes["actorname"].Value != null)
            {
                dNode.SetActorName(dialogueNode.Attributes["actorname"].Value);
            }
            if(dialogueNode.Attributes["actordialogue"].Value !=null)
            {
                dNode.SetDialogue(dialogueNode.Attributes["actordialogue"].Value);
            }
            if(dialogueNode.Attributes["id"].Value != null)
            {
                dNode.SetID (int.Parse (dialogueNode.Attributes["id"].Value));
            }
            if(dialogueNode.Attributes["state"].Value != null)
            {
                dNode.SetState(int.Parse(dialogueNode.Attributes["state"].Value));
            }

            convoGraph.AddNode(dNode);
        }

        /*
         * Loops back through the dialogue nodes only
         * looking at the child node replies
         */
        foreach(XmlNode dialogueNode in dialogues)
        {
            foreach (XmlNode childNode in dialogueNode.ChildNodes)
            {
                if(childNode.Name.ToUpper().Equals("REPLIES"))
                {
                    foreach (XmlNode replyNode in childNode.ChildNodes)
                    {
                        DialogueNode repNode = new DialogueNode();
                        if(replyNode.Attributes["text"].Value != null)
                        {
                            repNode.SetDialogue(replyNode.Attributes["text"].Value);
                        }
                        if(replyNode.Attributes["condition"].Value !=null)
                        {
                            repNode.SetCondition(replyNode.Attributes["condition"].Value);
                        }
                        if(replyNode.Attributes["goto"].Value != null)
                        {
                            if(replyNode.Attributes["goto"].Value.Equals ("-9999"))
                            {
                                //Ends the Conversation
                                UnityEngine.Debug.Log("CONVO OVER");
                                if(replyNode.Attributes["nextstate"].Value !=null)
                                {
                                    repNode.SetNextState(int.Parse (replyNode.Attributes["nextstate"].Value));
                                }
                            }
                            else
                            {
                                int id = int.Parse(replyNode.Attributes["goto"].Value);
                                convoGraph.AddEdge(repNode, convoGraph.FindNode(id));
                            }
                        }

                        convoGraph.AddNode (repNode);
                        convoGraph.AddEdge (convoGraph.FindNode(int.Parse(dialogueNode.Attributes["id"].Value)),repNode);
                        UnityEngine.Debug.Log(dialogueNode.Attributes["id"].Value + " to " + repNode.GetDialogue());
                    }
                }
            }
        }
        s.Stop();
        UnityEngine.Debug.Log("Time Elapsed for " + convoGraph.GetNodeList()[0].GetActorName() + ": " + s.Elapsed + "\nTotal Nodes: " + convoGraph.GetNodeList().Count.ToString());
        return convoGraph;
    }