Beispiel #1
0
    IEnumerator TrackTextDisplay()
    {
        while (true)
        {
            if (dialoguePaused)
            {
                yield return(null);

                continue;
            }

            if (dialogueQueue.Count > 0)
            {
                DialogueClass diag = dialogueQueue.Peek();

                if (diag.displayTime != null && diag.Text.Length > 1 && textPos < diag.displayTime.Length)
                {
                    yield return(new WaitForSecondsRealtime(diag.displayTime[textPos]));

                    textPos++;
                    //Debug.Log(textPos);
                }
                else
                {
                    yield return(null);
                }
            }
            else
            {
                yield return(null);
            }
        }
    }
Beispiel #2
0
    public DialogueClass AddDialogue(int listIndex)
    {
        Debug.Log("Dialogue added");
        if (listIndex < Dialogue.Count)
        {
            foreach (DialogueClass dialogue in Dialogue)
            {
                if (dialogue.Index == listIndex)
                {
                    DialogueClass pickedDialogue = dialogue;
                    if (dialogue.alternatives != null && dialogue.alternatives.Length > 0)
                    {
                        int randomIndex = Random.Range(0, dialogue.alternatives.Length + 1);

                        if (randomIndex > 0)
                        {
                            pickedDialogue = Dialogue[dialogue.alternatives[randomIndex - 1]];
                        }
                    }

                    dialogueQueue.Enqueue(pickedDialogue);
                    return(pickedDialogue);
                }
            }
        }
        else
        {
            Debug.LogError("Index out of range.");
        }

        return(null);
    }
Beispiel #3
0
 public void initiateDialogue(Collider other)
 {
     dialogueInstance = other.gameObject.GetComponent <DialogueClass>();
     isDialogue       = true;
     if (dialogueInstance.stopMovement)
     {
         isRunning = false;
     }
 }
    public void NewMonologue(string words)
    {
        dialogue = new DialogueClass(words);

        newDialogue = true;
        finished    = false;
        displayText = "";

        monologue = true;
    }
    private void OnNext()
    {
        DialogueClass _dialogueClass = dialogue.dialogueClass;

        if (currentLineNumber + 1 < _dialogueClass.speakerDialogue.Length)
        {
            currentLineNumber++;

            //int _expressionNumber = 1;

            //_expressionNumber = (int)_dialogueClass.setExpression[currentLineNumber];


            //changeExpression = _expressionNumber;

            //Debug.Log(changeExpression);

            //SetExpression();


            SpeakerAsset _currentSpeakerInfo = _dialogueClass.speakerInfo[currentLineNumber];
            switch (_dialogueClass.location[currentLineNumber])
            {
            case (DialogueBoxPosition.Left):
            {
                imagePoints[0].enabled = true;

                /*if(_dialogueClass.holdExpression[currentLineNumber] == false)
                 * {
                 *  imagePoints[0].sprite = _currentSpeakerInfo.expressionSprites[_expressionNumber];
                 * }*/
                namePoints[0].text = _currentSpeakerInfo.speakerName;

                break;
            }

            case (DialogueBoxPosition.Right):
            {
                imagePoints[1].enabled = true;

                /*if (_dialogueClass.holdExpression[currentLineNumber] == false)
                 * {
                 *  imagePoints[1].sprite = _currentSpeakerInfo.expressionSprites[_expressionNumber];
                 * }*/
                namePoints[1].text = _currentSpeakerInfo.speakerName;
                break;
            }
            }
        }
        else
        {
            Debug.Log("No More Lines");
        }
    }
    public void NewChoice(string words, string option1, string option2, string option3)
    {
        dialogue    = new DialogueClass(words);
        monologue   = false;
        newDialogue = true;
        finished    = false;
        displayText = "";

        // Choice 1 and choice 2 are required. Choice 3 is optional. Max of 3 choices
        choice1 = new ChoiceClass(option1, 1);
        choice2 = new ChoiceClass(option2, 2);
        choice3 = new ChoiceClass(option3, 3);
    }
Beispiel #7
0
    public void StartDialogue(DialogueClass npcDialogue, int dialogueParameter)
    {
        endedDialogue = false;
        textBox.SetActive(true);
        npcNameText.text = npcDialogue.npcName;
        linesOfDialogue.Clear();
        foreach (string line in npcDialogue.dialogueAmount[dialogueParameter].linesOfDialogue)
        {
            linesOfDialogue.Enqueue(line);
        }

        ShowNextLine();
    }
    // Start is called before the first frame update
    void Start()
    {
        currentLineNumber = -1;
        this.textTyper.PrintCompleted.AddListener(this.HandlePrintCompleted);
        this.textTyper.CharacterPrinted.AddListener(this.HandleCharacterPrinted);

        //this.printNextButton.onClick.AddListener(this.HandlePrintNextClicked);
        //this.printNoSkipButton.onClick.AddListener(this.HandlePrintNoSkipClicked);

        DialogueClass _dialogueClass = dialogue.dialogueClass;

        string[] _tempArray = new string[_dialogueClass.speakerDialogue.Length];



        for (int i = 0; i < _dialogueClass.speakerDialogue.Length; i++)
        {
            _tempArray[i] = AlignToSide(i) + _dialogueClass.speakerDialogue[i];


            //dialogueLines.Enqueue(_tempArray[i]);
        }

        foreach (string s in _tempArray)
        {
            dialogueLines.Enqueue(s);
        }

        /*foreach (string s in _dialogueClass.speakerDialogue)
         * {
         *  dialogueLines.Enqueue(s);
         * }*/

        /*dialogueLines.Enqueue("Hello! My name is... <delay=0.5>NPC</delay>. Got it, <i>bub</i>?");
         * dialogueLines.Enqueue("You can <b>use</b> <i>uGUI</i> <size=40>text</size> <size=20>tag</size> and <color=#ff0000ff>color</color> tag <color=#00ff00ff>like this</color>.");
         * dialogueLines.Enqueue("bold <b>text</b> test <b>bold</b> text <b>test</b>");
         * dialogueLines.Enqueue("You can <size=40>size 40</size> and <size=20>size 20</size>");
         * dialogueLines.Enqueue("You can <color=#ff0000ff>color</color> tag <color=#00ff00ff>like this</color>.");
         * dialogueLines.Enqueue("Sample Shake Animations: <anim=lightrot>Light Rotation</anim>, <anim=lightpos>Light Position</anim>, <anim=fullshake>Full Shake</anim>\nSample Curve Animations: <animation=slowsine>Slow Sine</animation>, <animation=bounce>Bounce Bounce</animation>, <animation=crazyflip>Crazy Flip</animation>");*/

        ShowScript();

        SetExpression();
    }
Beispiel #9
0
    public void Load(string File)
    {
        Dialogue = Serializer.Load <DialogueClass>(File);

        /* Dialogue = new DialogueClass();
         *
         * MessageBox m1 = new MessageBox(1, "Ah... You're Finally awake!", 2);
         * MessageBox m2 = new MessageBox(2, "You've been unconscious for a while now!", 3);
         *
         * Decision d1 = new Decision(20, "Where Am i?", 5);
         * Decision d2 = new Decision(21, "Who Am i?", 6);
         * Decision d3 = new Decision(22, "Who are you?", 7);
         * Decision d4 = new Decision(23, "What gender Am I", 8);
         * List<Decision> list1 = new List<Decision>();
         * list1.Add(d1);
         * list1.Add(d2);
         * list1.Add(d3);
         * list1.Add(d4);
         * DecisionBox db1 = new DecisionBox(3, list1, "Any questions, honey?");
         *
         * MessageBox m3 = new MessageBox(5, "You are in a Hospital!", 3);
         * MessageBox m4 = new MessageBox(6, "You are @name", 3);
         * MessageBox m5 = new MessageBox(7, "I'm a nurse here. My name is jennifer.", 3);
         * MessageBox m6 = new MessageBox(11, "UhOh. Something doofy happened!", 3);
         *
         * ConditionalBox cB = new ConditionalBox(8, "@gender == #Male", 9, 10, 11);
         *
         * MessageBox m7 = new MessageBox(9, "You are a Man", 3);
         * MessageBox m8 = new MessageBox(10, "You are a Woman", -1);
         *
         * Dialogue.AddDialogBox(m1);
         * Dialogue.AddDialogBox(m2);
         * Dialogue.AddDialogBox(m3);
         * Dialogue.AddDialogBox(m4);
         * Dialogue.AddDialogBox(m5);
         * Dialogue.AddDialogBox(m6);
         * Dialogue.AddDialogBox(m7);
         * Dialogue.AddDialogBox(m8);
         * Dialogue.AddDialogBox(cB);
         * Dialogue.AddDialogBox(db1);
         * Dialogue.SetFirstBox(1);
         *
         * Serializer.Save<DialogueClass>(File, Dialogue);*/
    }
    public void SetExpression()
    {
        Enum.TryParse(changeExpression.ToString(), out Expression expression);

        //Switch for additional effects, such as a screen shake or a sound
        switch (expression)
        {
        case (Expression.Neutral):
        {
            break;
        }

        case (Expression.Angry):
        {
            break;
        }

        case (Expression.Smug):
        {
            break;
        }

        case (Expression.Think):
        {
            break;
        }

        default:
        {
            break;
        }
        }

        int _expressionNumber = (int)expression;

        changeExpression = _expressionNumber;

        DialogueClass _dialogueClass      = dialogue.dialogueClass;
        SpeakerAsset  _currentSpeakerInfo = _dialogueClass.speakerInfo[currentLineNumber];

        switch (_dialogueClass.location[currentLineNumber])
        {
        case (DialogueBoxPosition.Left):
        {
            imagePoints[0].enabled = true;
            //if (_dialogueClass.holdExpression[currentLineNumber] == false)
            //{
            imagePoints[0].sprite = _currentSpeakerInfo.expressionSprites[_expressionNumber];
            //}
            namePoints[0].text = _currentSpeakerInfo.speakerName;

            break;
        }

        case (DialogueBoxPosition.Right):
        {
            imagePoints[1].enabled = true;
            //if (_dialogueClass.holdExpression[currentLineNumber] == false)
            //{
            imagePoints[1].sprite = _currentSpeakerInfo.expressionSprites[_expressionNumber];
            //}
            namePoints[1].text = _currentSpeakerInfo.speakerName;
            break;
        }
        }


        //Debug.Log("Expression: " + expression);
    }
Beispiel #11
0
 public void initiateDialogueInsideBattle(Collider other)
 {
     dialogueInstance   = other.gameObject.GetComponent <DialogueClass>();
     isDialogueInBattle = true;
 }
Beispiel #12
0
 public void GenerateNewDialogue()
 {
     NewDialogue.Index = Dialogue.Count;
     Dialogue.Add(NewDialogue);
     NewDialogue = new DialogueClass();
 }
Beispiel #13
0
 public void AddDialogue(DialogueClass dialogue)
 {
     Debug.Log("Dialogue added");
     dialogueQueue.Enqueue(dialogue);
 }