Ejemplo n.º 1
0
    public void SetData(BaseDialogNode dialogNode)
    {
        ResetMessageBox();
        if (dialogNode == null)
        {
            DialogComplete();
        }
        else if (dialogNode is DialogStartNode)
        {
            SetAsDialogStartNode((DialogStartNode)dialogNode);
        }
        else if (dialogNode is DialogNode)
        {
            SetAsDialogNode((DialogNode)dialogNode);
        }
        else if (dialogNode is DialogMultiOptionsNode)
        {
            SetAsMultiOptionsNode((DialogMultiOptionsNode)dialogNode);
        }
        else
        {
            Debug.LogError("Wrong Dialog type Sent Here");
        }

        if (dialogNode != null)
        {
            AssignChars(dialogNode);

            Debug.Log(dialogNode.lawLevel);

            LawController.Instance.level    += dialogNode.lawLevel;
            StressController.Instance.level += dialogNode.stressLevel;
        }
    }
Ejemplo n.º 2
0
 void ReactToNodeAnswer(BaseDialogNode n, string text)
 {
     if (this.answerEventMap.ContainsKey(n))
     {
         this.answerEventMap[n].Invoke(text);
     }
 }
Ejemplo n.º 3
0
 void ReactToNode(BaseDialogNode n)
 {
     if (this.exposeEventMap.ContainsKey(n))
     {
         this.exposeEventMap[n].Invoke();
     }
 }
Ejemplo n.º 4
0
 private void EndDialog()
 {
     inputDelayRemaining = 0;
     currentBoxFinished  = true;
     currentDialogNode   = null;
     currentDialog       = null;
     dialogIsActive      = false;
     EventManager.Notify(EventDefinitions.DIALOG_ENDED);
 }
    private void SetAsBaseDialogNode(BaseDialogNode dialogNode)
    {
        _okButton.ShowButton(true);
        _okButton.SetText(dialogNode.IsNextAvailable() ? EButtonText.NEXT : EButtonText.END);

        _background.sprite        = dialogNode.SayingBackground;
        _characterPortrait.sprite = dialogNode.SayingCharacterPotrait;
        _characterName.text       = dialogNode.SayingCharacterName;
        _sayingText.text          = dialogNode.WhatTheCharacterSays;
    }
Ejemplo n.º 6
0
    private void AssignChars(BaseDialogNode dialogNode)
    {
        if (dialogNode.LeftCharPortrait != null)
        {
            leftCharPortrait.sprite = dialogNode.LeftCharPortrait;
            leftCharPortrait.gameObject.SetActive(true);
        }

        if (dialogNode.RightCharPortrait != null)
        {
            rightCharPortrait.sprite = dialogNode.RightCharPortrait;
            rightCharPortrait.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 7
0
	public void SetData(BaseDialogNode dialogNode)
	{
		ResetMessageBox();
		if(dialogNode == null)
			DialogComplete();
		else if(dialogNode is DialogStartNode)
			SetAsDialogStartNode((DialogStartNode) dialogNode);
		else if(dialogNode is DialogNode)
			SetAsDialogNode((DialogNode) dialogNode);
		else if(dialogNode is DialogMultiOptionsNode)
			SetAsMultiOptionsNode((DialogMultiOptionsNode) dialogNode);
		else
			Debug.LogError("Wrong Dialog type Sent Here");
	}
 public void SetData(BaseDialogNode dialogNode)
 {
     if (dialogNode == null)
     {
         DialogComplete();
     }
     else
     {
         SetAsBaseDialogNode(dialogNode);
         if (dialogNode is DialogMultiOptionsNode)
         {
             SetAsMultiOptionsNode((DialogMultiOptionsNode)dialogNode);
         }
     }
 }
    public void SetData(BaseDialogNode dialogNode)
    {
        ResetMessageBox();
        if (dialogNode == null)
        {
            DialogComplete();
        }
        else if (dialogNode is DialogStartNode)
        {
            SetAsDialogStartNode((DialogStartNode)dialogNode);

            if (dialogNode.SoundDialog != null)
            {
                AudioSource sound = GetComponent <AudioSource>();
                sound.clip = dialogNode.SoundDialog;
                sound.Play();
            }
        }
        else if (dialogNode is DialogNode)
        {
            SetAsDialogNode((DialogNode)dialogNode);

            if (dialogNode.SoundDialog != null)
            {
                AudioSource sound = GetComponent <AudioSource>();
                sound.clip = dialogNode.SoundDialog;
                sound.Play();
            }
        }
        else if (dialogNode is DialogMultiOptionsNode)
        {
            SetAsMultiOptionsNode((DialogMultiOptionsNode)dialogNode);
            if (dialogNode.SoundDialog != null)
            {
                AudioSource sound = GetComponent <AudioSource>();
                sound.clip = dialogNode.SoundDialog;
                sound.Play();
            }
        }
        else
        {
            Debug.LogError("Wrong Dialog type Sent Here");
        }
    }
Ejemplo n.º 10
0
    public void RelayMessage()
    {
        if (Input.GetButtonDown("Submit"))
        {
            string text = inputText.text;
            inputText.text = "";
            (string response, BaseDialogNode next) = this.dialogNode.RecieveText(text);
            this.onNodeAnswered.Invoke(this.dialogNode, text);
            if (response != "")
            {
                this.prompt.SendText(response);
            }
            if (next != null)
            {
                this.dialogNode = next;
            }

            StartCoroutine(this.ProcessNodeDelay());
        }
    }
Ejemplo n.º 11
0
 public void Handle(BaseDialogNode node, StorySystemManager system, ConversationResolver resolver)
 {
     if (node is ConversationStartNode)
     {
         ConversationStartNodeHandler(node, system, resolver);
     }
     else if (node is ConversationEndNode)
     {
         ConversationEndNodeHandler(node, system, resolver);
     }
     else if (node is OptionsDialogNode)
     {
         OptionsDialogNodeHandler(node as OptionsDialogNode);
     }
     else if (node is SimpleDialogNode)
     {
         SimpleDialogHandler(node as SimpleDialogNode);
     }
     else if (node is RandomOutputNode)
     {
         RandomOutputNodeHandler(node as RandomOutputNode);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Handles the different loading patterns based off the type of node selected.
 /// </summary>
 /// <param name="node"></param>
 void LoadNode(BaseDialogNode node)
 {
     if (node is DialogStartNode)
     {
         LoadDialogStartNode((DialogStartNode)node);
     }
     else if (node is DialogNode)
     {
         LoadDialogNode((DialogNode)node);
     }
     else if (node is DialogMultiOptionsNode)
     {
         LoadChoiceNode((DialogMultiOptionsNode)node);
     }
     else if (node == null)
     {
         EndDialog();
         Debug.Log("Dialog Ended Successfully");
     }
     else
     {
         Debug.LogError("Invalid Node Type:");
     }
 }
Ejemplo n.º 13
0
 public void SimpleDialogNodeHandler(BaseDialogNode node, StorySystemManager system, ConversationResolver resolver)
 {
 }
Ejemplo n.º 14
0
    private IEnumerator CrawlDialog()
    {
        currentDialogNode = currentDialog.RootNode;
        UIController.Instance.ActivateDialogUI(color: Color.white);
        dialogIsActive = true;

        while (currentDialogNode != null)
        {
            if (currentDialogNode is SimpleDialogNode)
            {
                #region CommonTasks
                currentBoxFinished = false;

                var simple = currentDialogNode as SimpleDialogNode;

                UIController.Instance.DialogLeftSprite    = simple.leftImage;
                UIController.Instance.DialogRightSprite   = simple.rightImage;
                UIController.Instance.DialogBoxFrameColor = simple.prefixColor == default(Color) ? Color.white : simple.prefixColor;
                string formatedText = FormatText(simple.prefix, simple.Text, simple.prefixColor);

                typingFinished = false;
                StartCoroutine(TypeDialog(formatedText));

                yield return(new WaitUntil(() => typingFinished));

                #endregion CommonTasks

                //Individual node handlers
                #region SelectionDialogNode
                if (simple is SelectionDialogNode selection)
                {
                    yield return(new WaitForSeconds(0.1f)); //just a bit of delay to help accidental skips;

                    int selected = 0;

                    while (!currentBoxFinished)
                    {
                        if (inputDelayRemaining <= 0)
                        {
                            if (Input.GetAxisRaw("Vertical") != 0)
                            {
                                selected += Input.GetAxisRaw("Vertical") > 0 ? -1 : 1;

                                if (selected >= selection.selections.Count)
                                {
                                    selected = 0;
                                }
                                if (selected < 0)
                                {
                                    selected = selection.selections.Count - 1;
                                }

                                inputDelayRemaining = inputDelay;
                            }
                            else if (Input.GetAxisRaw("Submit") > 0 || Input.GetAxisRaw("Interact") > 0)
                            {
                                currentDialogNode   = selection.GetNext(selected);
                                currentBoxFinished  = true;
                                inputDelayRemaining = inputDelay;
                            }

                            UIController.Instance.DialogText = AddSelections(formatedText, selection.selections.ToArray(), selected);
                        }
                        else
                        {
                            inputDelayRemaining -= Time.deltaTime;
                        }

                        yield return(new WaitForEndOfFrame());
                    }
                }
                #endregion SelectionDialogNode
                #region InputDialogNode
                else if (simple is InputDialogNode input)
                {
                    string inputString = input.LastInput;
                    while (!currentBoxFinished)
                    {
                        foreach (char c in Input.inputString)
                        {
                            if (c == '\b') // has backspace/delete been pressed?
                            {
                                if (inputString.Length != 0)
                                {
                                    inputString = inputString.Substring(0, inputString.Length - 1);
                                }
                            }
                            else
                            {
                                inputString += c;
                            }
                        }

                        UIController.Instance.DialogText = AddUserInput(formatedText, inputString);

                        if (inputDelayRemaining <= 0)
                        {
                            if (Input.GetAxisRaw("Submit") > 0)
                            {
                                currentDialogNode   = input.GetNext(inputString);
                                currentBoxFinished  = true;
                                inputDelayRemaining = inputDelay;
                            }
                        }
                        else
                        {
                            inputDelayRemaining -= Time.deltaTime;
                        }

                        yield return(null);
                    }
                }
                #endregion InputDialogNode
                #region SimpleDialogNode
                else
                {
                    yield return(new WaitForSeconds(0.1f)); //just a bit of delay to help accidental skips;

                    while (!currentBoxFinished)
                    {
                        if (inputDelayRemaining <= 0)
                        {
                            if (Input.GetAxisRaw("Submit") > 0 || Input.GetAxisRaw("Interact") > 0)
                            {
                                currentDialogNode   = simple.GetNext();
                                currentBoxFinished  = true;
                                inputDelayRemaining = inputDelay;
                            }
                        }
                        else
                        {
                            inputDelayRemaining -= Time.deltaTime;
                        }

                        yield return(new WaitForEndOfFrame());
                    }
                }
                #endregion SimpleDialogNode
            }
            else
            {
                //For nodes that do not interact with dialog window
                currentDialogNode = currentDialogNode.GetNext();
            }
        }

        EndDialog();
    }