예제 #1
0
        IEnumerator <WaitForSeconds> _PlayText(Domain.Text txt)
        {
            this.txt = txt;
            Convo.SetActive(false);
            NextButton.gameObject.SetActive(false);
            Domain.Character chr = CharacterRoster.Get(txt.Actor);
            if (chr.Avatar)
            {
                Avatar.sprite          = chr.Avatar;
                Avatar.color           = Color.white;
                AvatarBackground.color = chr.Color;
                AvatarBackground.gameObject.SetActive(true);
                Avatar.gameObject.SetActive(true);
            }
            else
            {
                Avatar.gameObject.SetActive(false);
                AvatarBackground.gameObject.SetActive(false);
            }
            CharacterName.text    = chr.Name;
            CharacterNameBg.color = chr.Color;
            yield return(new WaitForSeconds(txt.Delay));

            Convo.SetActive(true);

            Lines.text = "";
            for (int lineIndex = 0; lineIndex < txt.Lines.Length; lineIndex++)
            {
                if (lineIndex > 0)
                {
                    Lines.text += "\n";
                }
                Domain.TextLine line = txt.Lines[lineIndex];
                if (line.Delay > 0f)
                {
                    yield return(new WaitForSeconds(line.Delay));
                }
                Lines.text += line.Text;
            }

            if (txt.Choices.Length > 0)
            {
                if (OnChoices != null)
                {
                    OnChoices(txt.Choices, EmitChoice);
                }
                else
                {
                    Debug.LogError(string.Format("SceneManager has no-one to take care of choices, story halts at: {0}", txt.ToJSON()));
                }
            }
            else
            {
                NextButton.gameObject.SetActive(true);
            }
        }
예제 #2
0
 private void Start()
 {
     if (_instance && _instance == this)
     {
         Destroy(this);
     }
     else if (!_instance)
     {
         _instance = this;
     }
 }