コード例 #1
0
ファイル: Dialoguer.cs プロジェクト: KirinnBR/val-hein
 // Start is called before the first frame update
 void Start()
 {
     currentPort = container.NodeLinks[0];
     for (int i = 0; i < answerTexts.Length; i++)
     {
         var btn = answerTexts[i].GetComponentInChildren <Button>();
         var aux = i;
         btn.onClick.AddListener(() => Answer(aux));
     }
     Ask();
 }
コード例 #2
0
        private void OnButtonClick(NodeLinkData linkData, DialogueCondition conditionToToggle)
        {
            if (conditionToToggle != null)
            {
                conditionToToggle.ToggleValue();
            }

            BaseNodeData nextNode = GetTargetNode(linkData);

            PlayNode(nextNode);
        }
コード例 #3
0
    void updateChoices(string baseNodeGuid)
    {
        // choices should be cleared before adding new chocies
        clearChoices();
        bool validChoice = true;

        //Update choice text to show new available choices
        for (int i = 0; i < _link.Count; i++)
        {
            //for all local link nodes
            if (_link[i].BaseNodeGUID == baseNodeGuid)
            {
                NodeLinkData targetLink = _link[i];
                //if it has lock check
                if (targetLink.lockChecks != null)
                {
                    //for all lock checks
                    for (int a = 0; a < targetLink.lockChecks.Length; a++)
                    {
                        //for all nodes in container targeted by lock check
                        for (int b = 0; b < targetLink.lockChecks[a].targetContainer.NodeLinks.Count; b++)
                        {
                            //check if node is the required node
                            if (targetLink.lockChecks[a].targetContainer.NodeLinks[b].PortName == targetLink.lockChecks[a].CheckNodePortName)
                            {
                                //check that required node have been used and no forbidden nodes have been used
                                if (targetLink.lockChecks[a].targetContainer.NodeLinks[b].used != targetLink.lockChecks[a].used)
                                {
                                    validChoice = false;
                                }
                            }
                        }
                    }
                }



                if (validChoice)
                {
                    _currentChoices.Add(_link[i]);
                }
            }
        }


        for (int i = 0; i < _currentChoices.Count; i++)
        {
            _choiceText[i].text = _currentChoices[i].PortName;
        }
    }
コード例 #4
0
ファイル: Dialoguer.cs プロジェクト: KirinnBR/val-hein
    private void Answer(int index)
    {
        //Testing if the chosen port is a segment of the current node.
        List <NodeLinkData> validPorts = GetAnswerPorts();

        if (validPorts.Count <= index)
        {
            //If there are no segments, then that's the end of conversation.
            //There are 2 ways of ending in here: end of conversation, or there's no reply assigned to the index.
            return;
        }

        currentPort = validPorts[index];

        Ask();
    }
コード例 #5
0
    public void Next(int selectedId = -1)
    {
        Debug.Log("Going next..");
        if (currentNodeLink.nextNodeGuid == null)
        {
            Debug.Log("Dialogue Ended");
            return;
        }

        // If pressing Next on DialogueSingle (no multiple options - one outcome)
        if (selectedId == -1)
        {
            currentNode     = currentContainer.nodesContainer.baseNodesData.Find(x => x.guid == currentNodeLink.nextNodeGuid);
            currentNodeLink = currentContainer.nodesContainer.nodeLinks.Find(x => x.thisNodeGuid == currentNode.guid);
        }
        else // If pressing Next on DialogueOptions (need to find a correspondent option)
        {
            var allNextLinks = currentContainer.nodesContainer.nodeLinks.FindAll(x => x.thisNodeGuid == currentNodeLink.thisNodeGuid);
            currentNodeLink = currentContainer.nodesContainer.nodeLinks.Find(x => x.thisNodeGuid == allNextLinks[selectedId].nextNodeGuid);
            currentNode     = currentContainer.nodesContainer.baseNodesData.Find(x => x.guid == currentNodeLink.thisNodeGuid);
        }

        Debug.Log($"Current Node: {currentNode.nodeType} {currentNode.guid}");

        switch (currentNode.nodeType)
        {
        case NodeType.ChoiceNode:
            var currentNodeDataChoice = currentContainer.nodesContainer.choiceNodesData.Find(x => x.guid == currentNode.guid);
            var allNextLinks          = currentContainer.nodesContainer.nodeLinks.FindAll(x => x.thisNodeGuid == currentNodeLink.thisNodeGuid);
            dialogueOptions.SetupDialogue(currentNodeDataChoice.speaker, currentNodeDataChoice.dialogueText, allNextLinks);
            break;

        case NodeType.DialogueNode:
            var currentNodeDataDialogue = currentContainer.nodesContainer.dialogueNodesData.Find(x => x.guid == currentNode.guid);
            dialogueSingle.SetupDialogue(currentNodeDataDialogue.speaker, currentNodeDataDialogue.dialogueTexts);
            break;

        case NodeType.EndNode:
            Debug.Log("Dialogue Ended");
            break;

        case NodeType.StartNode:
            Debug.Log("Dialogue Started, but how..");
            break;
        }
    }
コード例 #6
0
    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();
    }
コード例 #7
0
    public void choiceInput(int tempChoice)
    {
        NodeLinkData choice = _currentChoices[tempChoice];

        //Go through lock targets and update lock and disable status
        choice.used = true;


        //Update text display to show new target node
        for (int i = 0; i < _textData.Count; i++)
        {
            if (_textData[i].NodeGUID == choice.TargetNodeGuid)
            {
                _dialogue.text = _textData[i].DialogueText;
                Debug.Log(_dialogue.text);

                updateChoices(_textData[i].NodeGUID);
            }
        }
    }
コード例 #8
0
        private BaseNodeData GetTargetNode(NodeLinkData nodeLink)
        {
            switch (nodeLink.targetNodeType)
            {
            case NodeType.NotSet:
                return(null);

            case NodeType.Entry:
                return(null);

            case NodeType.Condition:
                return(dialogueContainer.conditionNodeData.Find(
                           node => node.guid == nodeLink.targetNodeGuid));

            case NodeType.Dialogue:
                return(dialogueContainer.dialogueNodeData.Find(node =>
                                                               node.guid == nodeLink.targetNodeGuid));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #9
0
        private void GenerateChoiceButtons(DialogueNodeData node)
        {
            List <NodeLinkData> nodeLinks = GetLinks(node.guid);

            if (nodeLinks.Count != node.responses.Count)
            {
                Debug.LogError(
                    $"Dialogue Node {node.guid} has mismatched number of links and responses. Aborting conversation.");
                dialoguePanel.gameObject.SetActive(false);
                return;
            }

            for (var i = 0; i < node.responses.Count; i++)
            {
                NodeLinkData      link              = nodeLinks[i];
                string            currentResponse   = node.responses[i];
                DialogueCondition conditionToToggle = node.conditionsToToggle[i];
                Button            button            = Instantiate(choiceButtonPrefab, choicesContentAreaTransform);
                button.GetComponentInChildren <TMP_Text>().text = currentResponse;
                button.onClick.AddListener(() => OnButtonClick(link, conditionToToggle));
            }
        }
コード例 #10
0
ファイル: Level.cs プロジェクト: savik-games/SeriousGameJam
    void StartNewPatient()
    {
        //dialogLog.ClearLog();
        dialogSelect.Clear();

        currPatient = Instantiate(patients[currPatientId]);

        AudioSource callAS = AudioManager.Instance.PlayLoop(callSound, 0.15f);

        AudioManager.Instance.Play(systemMessageSound);
        dialogLog.AddToLog(DialogLogUI.LogEntryType.Servise, $"Call with <i>{currPatient.name}</i> started", onShowLog: () => {
        });

        dialogSelect.AddButton("start", () => {
            AudioManager.Instance.ChangeASVolume(callAS, 0.0f, 0.25f);
            Destroy(callAS.gameObject, 1.0f);

            dialogSelect.Clear();
            NodeLinkData narrativeData = currPatient.dialogue.NodeLinks.First();             //Entrypoint node
            ProceedToNarrative(narrativeData.TargetNodeGUID);
        });
    }
コード例 #11
0
    protected BaseNodeData GetNextNode(BaseNodeData _baseNodeData)
    {
        NodeLinkData nodeLinkData = dialogueContainer.NodeLinkDatas.Find(edge => edge.BaseNodeGuid == _baseNodeData.NodeGuid);

        return(GetNodeByGuid(nodeLinkData.TargetNodeGuid));
    }
コード例 #12
0
    // Getting next node by its link data
    protected BaseNodeData GetNextNode(BaseNodeData baseNodeData)
    {
        NodeLinkData nodeLinkData = currentDialogue.NodeLinkDatas.Find(egde => egde.BaseNodeGuid == baseNodeData.NodeGuid);

        return(GetNodeByGuid(nodeLinkData.TargetNodeGuid));
    }