Exemplo n.º 1
0
        private void HandleCharacterEvent(Domain.Character character, EventType type)
        {
            switch (type)
            {
            case EventType.Start:
                if (roster.ContainsKey(character.Id))
                {
                    Debug.LogWarning(string.Format(
                                         "Duplicated id '{0}' in roster for {1} and {2}",
                                         character.Id, character.Name, roster[character.Id].Name
                                         ));
                }
                roster[character.Id] = character;
                break;

            case EventType.End:
                if (!roster.ContainsKey(character.Id))
                {
                    Debug.LogWarning(string.Format(
                                         "Missing id '{0}' in roster.",
                                         character.Id
                                         ));
                }
                else
                {
                    roster.Remove(character.Id);
                }
                break;
            }
        }
Exemplo n.º 2
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);
            }
        }