Пример #1
0
        private void SetCharacterProfilesPictures(DialogueFrame currentFrame, bool color = true)
        {
            SetUpDialogueFrame(currentFrame);
            NameText.text = GetCurrentDialogueCharacter(currentFrame).name;
            NameText.GetComponentInParent <Animator>().SetInteger("Position", (int)currentFrame.personTalkingPosition);
            for (int a = 0; a < characters.Count && a < characterProfiles.Count; a++)
            {
                if (characterProfiles[a] != null)
                {
                    if (a == (int)currentFrame.personTalkingPosition)
                    {
                        characterProfiles[a].sprite = currentFrame.personTalking.GetSprite(currentFrame.expression);

                        characterProfiles[a].GetComponent <ColorLerp>().lerpToAlpha(1.0f);
                    }
                    else
                    {
                        if (characters[a] != null)
                        {
                            characterProfiles[a].sprite = currentFrame.personTalking.GetSprite(currentFrame.expression);
                            characterProfiles[a].GetComponent <ColorLerp>().lerpToAlpha(.5f);
                        }
                        else
                        {
                            characterProfiles[a].GetComponent <ColorLerp>().lerpToColor(new Color(0, 0, 0, 0));
                        }
                    }
                }
            }
        }
Пример #2
0
        private DialogueCharacter GetCurrentDialogueCharacter(DialogueFrame dialogueFrame)
        {
            DialogueCharacter tempCharacter = characters[(int)dialogueFrame.personTalkingPosition];

            if (tempCharacter == null)
            {
                throw new Exception("Can't find dialogue character based on DialoguePosition");
            }
            return(tempCharacter);
        }
Пример #3
0
        private IEnumerator executeFrameCoroutines(DialogueFrame dialogueFrame)
        {
            foreach (GameObject button in optionsButtons)
            {
                Destroy(button);
            }

            yield return(StartCoroutine("slowTextDisplay", dialogueFrame));

            yield return(StartCoroutine("addOptionButtons", dialogueFrame));
        }
Пример #4
0
 private IEnumerator slowTextDisplay(DialogueFrame dialogueFrame)
 {
     DialogueText.text = string.Empty;
     foreach (char newChar in dialogueFrame.dialogueText.ToCharArray())
     {
         if (!char.IsWhiteSpace(newChar))
         {
             source.Play();
         }
         DialogueText.text += newChar;
         yield return(new WaitForSeconds(waitTime));
     }
 }
Пример #5
0
        private IEnumerator addOptionButtons(DialogueFrame dialogueFrame)
        {
            foreach (DialogueOption option in dialogueFrame.options)
            {
                GameObject      button = Instantiate(OptionButtonPrefab, DisplayPanel.transform, false);
                TextMeshProUGUI text   = button.GetComponentInChildren <TextMeshProUGUI>();
                button.GetComponent <OnEvent>().onMouseClick += () => ContinueDialogue();
                button.GetComponent <OnEvent>().onMouseClick += () => option.OnMouseUp();
                button.GetComponent <OnEvent>().onMouseClick += () => dialogueQueue.InsertRange(0, option.addFrames);
                optionsButtons.Add(button);
                text.text = "> <indent=3em> ";

                foreach (char newChar in option.displayText.ToCharArray())
                {
                    text.text += newChar;
                    yield return(new WaitForSeconds(waitTime));
                }
            }
        }
Пример #6
0
 private void SetUpDialogueFrame(DialogueFrame dialogueFrame)
 {
     if (dialogueFrame.personTalkingPosition == DialoguePosition.Null)
     {
         for (int a = 0; a < characters.Count; a++)
         {
             if (dialogueFrame.personTalking == characters[a] && characters[a] != null)
             {
                 dialogueFrame.personTalkingPosition = ((DialoguePosition)a);
             }
         }
         if (dialogueFrame.personTalkingPosition == DialoguePosition.Null)
         {
             throw new Exception("Dialogue Character not found, check the personTalking on the DialogueFrame object");
         }
     }
     if (dialogueFrame.personTalking == null)
     {
         dialogueFrame.personTalking = GetCurrentDialogueCharacter(dialogueFrame);
     }
 }
Пример #7
0
        public void ContinueDialogue()
        {
            if (dialogueQueue.Count != 0)
            {
                DialogueFrame currentFrame = dialogueQueue[0];
                dialogueQueue.RemoveAt(0);
                SetCharacterProfilesPictures(currentFrame);
                StopAllCoroutines();
                if (currentFrame.options.Length > 0)
                {
                    continueButton.SetActive(false);
                }
                else
                {
                    continueButton.SetActive(true);
                }

                StartCoroutine("executeFrameCoroutines", currentFrame);
            }
            else
            {
                endDialogue();
            }
        }