Пример #1
0
        public static bool ShowEditor()
        {
            dialogueContainer = Selection.activeObject as DialogueContainer;

            if (dialogueContainer)
            {
                ShowWindow(dialogueContainer);
                return(true);
            }

            return(false);
        }
Пример #2
0
 public void LoadGraph(string FileName)
 {
     _containerCache = Resources.Load <DialogueContainer>(FileName);
     if (_containerCache == null)
     {
         EditorUtility.DisplayDialog("YOU F*****G IDIOT", "The target dialogue graph does not exist, or is not present in the Resources folder, you moron.", "I'M SORRY PLEASE FORGIVE ME I FAILED I'M A FAILURE I-");
         return;
     }
     ClearGraph();
     CreateNodes();
     ConnectNodes();
 }
Пример #3
0
        public void LoadNarrative(string fileName)
        {
            _dialogueContainer = Resources.Load <DialogueContainer>(fileName);
            if (_dialogueContainer == null)
            {
                EditorUtility.DisplayDialog("File Not Found", "Target Narrative Data does not exist!", "OK");
                return;
            }

            ClearGraph();
            GenerateDialogueNodes();
            ConnectDialogueNodes();
        }
Пример #4
0
    public void LoadGraph(string fileName)
    {
        _containerCache = Resources.Load <DialogueContainer>(fileName);
        if (_containerCache == null)
        {
            EditorUtility.DisplayDialog("File Not Found", "Target dialogue graph file does not exist!", "OK");
            return;
        }

        ClearGraph();
        CreateNodes();
        ConnectNodes();
    }
Пример #5
0
        public void LoadNarrative(string filePath)
        {
            _dialogueContainer = AssetDatabase.LoadAssetAtPath <DialogueContainer>(filePath);
            if (_dialogueContainer == null)
            {
                EditorUtility.DisplayDialog("File Not Found", "Target Narrative Data does not exist!", "OK");
                return;
            }

            ClearGraph();
            GenerateDialogueNodes();
            ConnectDialogueNodes();
        }
Пример #6
0
    public void SaveBooleanGetFlagNodes(DialogueContainer dialogueContainer)
    {
        foreach (var booleanGetFlagNode in BooleanGetFlagNodes.Where(node => !node.EntryPoint))
        {
            dialogueContainer.BooleanGetFlagNodeData.Add(new BooleanGetFlagNodeData
            {
                Guid     = booleanGetFlagNode.GUID,
                FlagName = booleanGetFlagNode.FlagName,
                Position = booleanGetFlagNode.GetPosition().position
            });
        }

        return;
    }
Пример #7
0
    public static DialogueContainer Load(TextAsset file)
    {
        //Loads the file
        TextAsset _xml = file;

        XmlSerializer     serializer = new XmlSerializer(typeof(DialogueContainer));        //Create a serializer
        StringReader      reader     = new StringReader(_xml.text);                         //Create a reader for the file
        DialogueContainer dialogues  = serializer.Deserialize(reader) as DialogueContainer; //Deserialize the XML file and put them in the dialogues

        reader.Close();                                                                     //Close the file

        //Return the dialogues
        return(dialogues);
    }
    public static DialogueContainer LoadFromXML(string path)
    {
        TextAsset xml = Resources.Load <TextAsset>(path);

        XmlSerializer serializer = new XmlSerializer(typeof(DialogueContainer));

        StringReader reader = new StringReader(xml.text);

        DialogueContainer dialogues = serializer.Deserialize(reader) as DialogueContainer;

        reader.Close();

        return(dialogues);
    }
    void NextDialogue(DialogueContainer nextDialogue)
    {
        myText.text   = "";
        dialogueIndex = 0;
        timer         = 0.0f;
        letterIndex   = 0;

        if (freezePlayer == true)
        {
            characterCtrl.SetActive(true);
        }

        nextDialogue.LoadDialogue();
    }
Пример #10
0
    public override void UseAbility()
    {
        DialogueContainer AreaInfo = OverworldController.AreaInfo;

        if (AreaInfo != null)
        {
            CutsceneDeconstruct complexCutscene = ScriptableObject.CreateInstance <CutsceneDeconstruct>();
            complexCutscene.Deconstruct(AreaInfo, GetComponent <FriendlyNPCClass>().ObjectInfo.ObjectName, gameObject);
        }
        else
        {
            Debug.Log("No info for this area.");
        }
    }
 private void CreateConditionNodeData(DialogueContainer container)
 {
     container.conditionNodeData.Clear();
     foreach (ConditionNode conditionNode in conditionNodes)
     {
         container.conditionNodeData.Add(new ConditionNodeData
         {
             guid            = conditionNode.Guid,
             position        = conditionNode.GetPosition().position,
             conditionToTest = conditionNode.ConditionToTest,
             type            = conditionNode.type
         });
     }
 }
Пример #12
0
        public void LoadGraph(string fileName)
        {
            containerCache = Resources.Load <DialogueContainer>($"DialogueSystem/{fileName}");

            if (containerCache is null)
            {
                EditorUtility.DisplayDialog("File Not Found", "Target Dialogue graph file does not exits!", "OK");
                return;
            }

            ClearGraph();
            CreateNodes();
            ConnectNodes();
            CreateExposedProperties();
        }
Пример #13
0
    private static void CreateNodes(DialogueGraphView graphView, DialogueContainer dialogueContainer)
    {
        foreach (var nodeData in dialogueContainer.DialogueNodeData)
        {
            var tempNode = graphView.CreateDialogueNode(nodeData.DialogueText, nodeData.Position);
            tempNode.Load(nodeData);
            graphView.AddElement(tempNode);

            //添加端口
            var nodePorts = dialogueContainer.NodeLinks.Where(x => x.FromNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => graphView.AddChoicePort(tempNode, x.PortName));
        }

        graphView.EntryNode.Load(dialogueContainer.EntryNodeData, true);
    }
Пример #14
0
    public void SaveSetFlagNodes(DialogueContainer dialogueContainer)
    {
        foreach (var setFlagNode in SetFlagNodes.Where(node => !node.EntryPoint))
        {
            dialogueContainer.SetFlagNodeData.Add(new SetFlagNodeData
            {
                Guid     = setFlagNode.GUID,
                FlagName = setFlagNode.FlagName,
                FlagTag  = setFlagNode.FlagTag,
                Position = setFlagNode.GetPosition().position
            });
        }

        return;
    }
Пример #15
0
    public void SaveDialogueNodes(DialogueContainer dialogueContainer)
    {
        foreach (var dialogueNode in DialogueNodes.Where(node => !node.EntryPoint))
        {
            dialogueContainer.DialogueNodeData.Add(new DialogueNodeData
            {
                Guid         = dialogueNode.GUID,
                DialogueText = dialogueNode.DialogueText,
                TargetPlayer = dialogueNode.TargetPlayer,
                Position     = dialogueNode.GetPosition().position
            });
        }

        return;
    }
Пример #16
0
    public void SaveAnimationTriggerNodes(DialogueContainer dialogueContainer)
    {
        foreach (var animationTriggerNode in AnimationTriggerNodes.Where(node => !node.EntryPoint))
        {
            dialogueContainer.AnimationTriggerNodeData.Add(new AnimationTriggerNodeData
            {
                Guid         = animationTriggerNode.GUID,
                TriggerName  = animationTriggerNode.TriggerName,
                TargetPlayer = animationTriggerNode.TargetPlayer,
                Position     = animationTriggerNode.GetPosition().position
            });
        }

        return;
    }
Пример #17
0
        public void LoadGraph(string fileName)
        {
            m_dialogueContainerSavedData = Resources.Load <DialogueContainer>(fileName);

            if (m_dialogueContainerSavedData == null)
            {
                EditorUtility.DisplayDialog("File Not Found", "Target dialogue graph file does not exist.", "OK");
                return;
            }

            ClearGraph();
            CreateNodes();
            ConnectNodes();
            CreateExposedProperties();
        }
Пример #18
0
        private void SaveCommentBlocks(DialogueContainer dialogueContainer)
        {
            foreach (var block in CommentBlocks)
            {
                var nodes = block.containedElements.Where(x => x is DialogueNode).Cast <DialogueNode>().Select(x => x.GUID)
                            .ToList();

                dialogueContainer.CommentBlockData.Add(new CommentBlockData
                {
                    ChildNodes = nodes,
                    Title      = block.title,
                    Position   = block.GetPosition().position
                });
            }
        }
Пример #19
0
        /// <summary>
        /// This will get all the data from a Dialogue Container and will translate it to a usable graph and view
        /// </summary>
        /// <param name="fileName"></param>
        public void LoadGraph(DialogueContainer dialogue)
        {
            if (dialogue == null)
            {
                return;
            }
            _containerCache = dialogue;

            ClearGraph();
            CreateNodes();
            ConnectNodes();
            CreateExposedProperties();

            _targetGraph.SetBlackBoardRect(_containerCache.blackBoardRect);
            _targetGraph.SetMiniMapRect(_containerCache.minimapRect);
        }
Пример #20
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         RaycastHit hit;
         Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 100.0f, Color.yellow);
         if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, interactDistance))
         {
             if (hit.transform.gameObject.tag == "NPC")
             {
                 DialogueContainer dialogue = hit.transform.gameObject.GetComponent <DialogueContainer>();
                 dialogueDisplay.DisplayDialogue(dialogue.dialogue);
             }
         }
     }
 }
Пример #21
0
    public void StartDialogue(DialogueContainer dialogue, TextMeshProUGUI header, TextMeshProUGUI body, GameObject interlocutor)
    {
        sentences.Clear();
        isConversationActive = true;
        dialogueHeader       = header;
        dialogueHeader.text  = dialogue.name;
        dialogueBody         = body;
        this.interlocutor    = interlocutor;

        foreach (string sentence in dialogue.sentences)
        {
            // Add all the sentences in the dialogue to the queue
            sentences.Enqueue(sentence);
        }

        DisplayNextSentence();
    }
Пример #22
0
    public void SaveNodeLinks(DialogueContainer dialogueContainer)
    {
        var connectedPorts = Edges.Where(x => x.input.node != null).ToArray();

        for (var i = 0; i < connectedPorts.Length; i++)
        {
            var outputNode = connectedPorts[i].output.node as NodeTemplate;
            var inputNode  = connectedPorts[i].input.node as NodeTemplate;

            dialogueContainer.NodeLinks.Add(new NodeLinkData
            {
                BaseNodeGuid   = outputNode.GUID,
                PortName       = connectedPorts[i].output.portName,
                TargetNodeGuid = inputNode.GUID
            });
        }
    }
Пример #23
0
    public void SaveMoveToPosNodes(DialogueContainer dialogueContainer)
    {
        foreach (var moveToPosNode in MoveToPosNodes.Where(node => !node.EntryPoint))
        {
            dialogueContainer.MoveToPosNodeData.Add(new MoveToPosNodeData
            {
                Guid            = moveToPosNode.GUID,
                TargetObject    = moveToPosNode.TargetObject,
                ReferenceObject = moveToPosNode.ReferenceObject,
                PosOffset       = moveToPosNode.PosOffset,
                Wait            = moveToPosNode.Wait,
                Position        = moveToPosNode.GetPosition().position
            });
        }

        return;
    }
    public void PlayDialogue(string dialogueName)
    {
        var dialogueIndex = dialoguesContainer.FindIndex(x => x.dialogueName.Equals(dialogueName));

        Debug.Log($"Playing Dialogue {dialogueName} ({dialogueIndex})");

        if (dialogueIndex == -1)
        {
            return;
        }

        currentContainer = dialoguesContainer[dialogueIndex];
        currentNode      = currentContainer.nodesContainer.baseNodesData.Find(x => x.nodeType == NodeType.StartNode);
        currentNodeLink  = currentContainer.nodesContainer.nodeLinks.Find(x => x.thisNodeGuid == currentNode.guid);
        Debug.Log($"Current Node: {currentNode.nodeType} {currentNode.guid}");

        Next();
    }
Пример #25
0
    // Update is called once per frame
    public void OpenDialogue(DialogueContainer dialogueContainer, Text[] choices)
    {
        _currentContainer = dialogueContainer;
        _link             = _currentContainer.NodeLinks;
        _conditions       = _currentContainer.ExposedProperties;
        _textData         = _currentContainer.DialogueNodeData;
        _choiceText       = choices;


        _currentChoices = new List <NodeLinkData>();

        int listSize = _textData.Count;

        // Dialogue.text = textData[listSize - 1].DialogueText;
        _dialogue.text = _textData[0].DialogueText;
        // updateChoices(textData[listSize - 1].NodeGUID);
        updateChoices(_textData[0].NodeGUID);
    }
Пример #26
0
        /// <summary>
        /// This will get all the data from a Dialogue Container and will translate it to a usable graph and view
        /// </summary>
        /// <param name="fileName"></param>
        public void LoadGraph(string fileName)
        {
            _containerCache = Resources.Load <DialogueContainer>($"Dialogues/{fileName}");

            if (_containerCache == null)
            {
                EditorUtility.DisplayDialog(title: "File Not Found", message: "Target dialogue graph file does not exist", ok: "OK");
                return;
            }

            ClearGraph();
            CreateNodes();
            ConnectNodes();
            CreateExposedProperties();

            _targetGraph.SetBlackBoardRect(_containerCache.blackBoardRect);
            _targetGraph.SetMiniMapRect(_containerCache.minimapRect);
        }
        private void CreateNodes(DialogueContainer container)
        {
            foreach (DialogueNodeData nodeData in container.dialogueNodeData)
            {
                DialogueNode tempNode = targetGraphView.CreateDialogueNode(nodeData);
                tempNode.Guid = nodeData.guid;
                tempNode.SetPosition(new Rect(nodeData.position, BaseNode.DefaultNodeSize));
                targetGraphView.AddElement(tempNode);
            }

            foreach (ConditionNodeData nodeData in container.conditionNodeData)
            {
                ConditionNode tempNode = targetGraphView.CreateConditionNode(nodeData);
                tempNode.Guid = nodeData.guid;
                tempNode.SetPosition(new Rect(nodeData.position, BaseNode.DefaultNodeSize));
                targetGraphView.AddElement(tempNode);
            }
        }
        public ConversationTree(
            DialogueContainer dialogueContainer,
            string dialogueOwnerName,
            GameObject dialogueCamera,
            List <DialogueEvent> events
            )
        {
            this.dialogueContainer = dialogueContainer;
            this.dialogueOwnerName = dialogueOwnerName;
            this.dialogueCamera    = dialogueCamera;
            this.events            = events;

            if (currentBaseNodeGuid == null)
            {
                // First baseNodeGuid is the default "NEXT" whic has always a target node guid associated with it.
                // Advance the dialogue in the first entry using targetNodeGuid.
                AdvanceDialogue(dialogueContainer.NodeLinks[0].TargetNodeGuid);
            }
        }
        private void ClearGraph(DialogueContainer container)
        {
            foreach (Node node in targetGraphView.nodes.ToList())
            {
                // If the entry node, reset the GUID and continue.
                if (node is EntryNode entry)
                {
                    entry.Guid = container.entryNode.guid;
                    entry.SetPosition(new Rect(container.entryNode.position, BaseNode.DefaultNodeSize));
                }
                else // disconnect the node, then remove the node.
                {
                    Edges.Where(edge => edge.input.node == node).ToList()
                    .ForEach(edge => targetGraphView.RemoveElement(edge));

                    targetGraphView.RemoveElement(node);
                }
            }
        }
Пример #30
0
    public void LoadGraph(string filename)
    {
        _containerCache = Resources.Load <DialogueContainer>(filename);
        if (_containerCache == null)
        {
            EditorUtility.DisplayDialog("File Not Found", "Target dialogue graph file does not exist!", "OK");
        }

        ClearGraph();
        CreateDialogueNodes();
        CreateAnimationTriggerNodes();
        CreateGetFlagNodes();
        CreateSetFlagNodes();
        CreateBooleanGetFlagNodes();
        CreateBooleanSetFlagNodes();
        CreateMoveToPosNodes();
        AllNodes = CombineAllLists();
        ConnectNodes();
        //CreateExposedProperties();
    }