Example #1
0
    public void buildDialogueBox(DAS_DialogueBox dialogueBox, DAS_Dialogue dialogue, int phraseIndex = 0)
    {
        active = true;
        dialogueController.dialogueInCourse = true;
        disableOptions(dialogueBox);
        // If current dialogue has options, activate the bigger box
        if (dialogue.options.Length > 0)
        {
            dialogueBox.dialogueWithOptions.SetActive(true);
            dialogueBox.dialogueNoOptions.SetActive(false);
            // If single option, enable single option box
            if (dialogue.options.Length == 1)
            {
                dialogueBox.singleOptionBox.SetActive(true);
                dialogueBox.singleOptionText.text = dialogue.options[0].phrase;
            }
            // If two options, enable center option boxes
            else if (dialogue.options.Length == 2)
            {
                dialogueBox.option1CenterBox.SetActive(true);
                dialogueBox.option2CenterBox.SetActive(true);
                dialogueBox.option1CenterText.text = dialogue.options[0].phrase;
                dialogueBox.option2CenterText.text = dialogue.options[1].phrase;
            }
            // If more than two options, enable corresponding boxes
            else
            {
                dialogueBox.option1Box.SetActive(true);
                dialogueBox.option2Box.SetActive(true);
                dialogueBox.option3Box.SetActive(true);
                dialogueBox.option1Text.text = dialogue.options[0].phrase;
                dialogueBox.option2Text.text = dialogue.options[1].phrase;
                dialogueBox.option3Text.text = dialogue.options[2].phrase;
                if (dialogue.options.Length > 3)
                {
                    dialogueBox.option4Box.SetActive(true);
                    dialogueBox.option4Text.text = dialogue.options[3].phrase;
                }
            }
        }
        // If there is no option, active smaller box
        else
        {
            dialogueBox.dialogueWithOptions.SetActive(false);
            dialogueBox.dialogueNoOptions.SetActive(true);
        }

        // If current dialogue inherits style, use photo and title of this
        if (dialogue.inheritStyle)
        {
            assignPhotoAndTexts(dialogueBox, this.photo, this.title, dialogue.phrases[phraseIndex]);
        }
        else // If it doesnt inherit, use photo and title of current dialogue
        {
            assignPhotoAndTexts(dialogueBox, dialogue.photo, dialogue.title, dialogue.phrases[phraseIndex]);
        }
    }
Example #2
0
 // Disable all option boxes
 public void disableOptions(DAS_DialogueBox diagBox)
 {
     diagBox.option1Box.SetActive(false);
     diagBox.option2Box.SetActive(false);
     diagBox.option3Box.SetActive(false);
     diagBox.option4Box.SetActive(false);
     diagBox.option1CenterBox.SetActive(false);
     diagBox.option2CenterBox.SetActive(false);
     diagBox.singleOptionBox.SetActive(false);
 }
Example #3
0
 public void assignPhotoAndTexts(DAS_DialogueBox diagBox, Sprite photo, string title, string phrase)
 {
     // If there is a coroutine running the typing animation, stop it
     if (currentCoroutine != null)
     {
         StopCoroutine(currentCoroutine);
     }
     if (photo)
     {
         diagBox.photo.sprite          = photo;
         diagBox.photo.enabled         = true;
         diagBox.titlePhoto.enabled    = true;
         diagBox.titleNoPhoto.enabled  = false;
         diagBox.titlePhoto.text       = title;
         diagBox.phrasePhoto.enabled   = true;
         diagBox.phraseNoPhoto.enabled = false;
         // If dialogue animatePhrases is checked, start coroutine with animation process
         if (dialogues[currentDialogueIndex].animatePhrases)
         {
             currentCoroutine = animatePhrase(diagBox.phrasePhoto, phrase, phraseSpeed);
             StartCoroutine(currentCoroutine);
         }
         // Else, just display the plain text
         else
         {
             diagBox.phrasePhoto.text = phrase;
         }
     }
     else
     {
         diagBox.photo.enabled         = false;
         diagBox.titlePhoto.enabled    = false;
         diagBox.titleNoPhoto.enabled  = true;
         diagBox.titleNoPhoto.text     = title;
         diagBox.phrasePhoto.enabled   = false;
         diagBox.phraseNoPhoto.enabled = true;
         // If dialogue animatePhrases is checked, start coroutine with animation process
         if (dialogues[currentDialogueIndex].animatePhrases)
         {
             currentCoroutine = animatePhrase(diagBox.phraseNoPhoto, phrase, phraseSpeed);
             StartCoroutine(currentCoroutine);
         }
         // Else, just display the plain text
         else
         {
             diagBox.phraseNoPhoto.text = phrase;
         }
     }
 }