Exemplo n.º 1
0
        internal Command ToGameObject(ChatRuntime rt)
        {
            ChatParser  parser = rt.Parser();
            LineContext lc     = new LineContext(parser, actor, command, text, label, meta);
            var         cmd    = parser.CreateCommand(lc);

            if (cmd is Ask)
            {
                Ask ask = (Dialogic.Ask)cmd;
                for (int i = 0; i < options.Length; i++)
                {
                    var parts = options[i].Split(OPT_DELIM);
                    if (parts.Length != 2)
                    {
                        throw new DialogicException
                                  ("Bad option:" + options[i]);
                    }
                    Opt opt = new Opt();
                    parts[1] = parts[1].TrimFirst(Ch.LABEL);
                    opt.Init(parts[0], Ch.LABEL + parts[1], null);
                    ask.AddOption(opt);
                }
            }
            return(cmd);
        }
Exemplo n.º 2
0
        internal Chat ToGameObject(ChatRuntime rt)
        {
            ChatParser  parser = rt.Parser();
            LineContext lc     = new LineContext(parser, null, "CHAT", text, null, meta);
            Chat        chat   = (Dialogic.Chat)parser.CreateCommand(lc);

            chat.Staleness(this.staleness);
            chat.Resumable(this.resumable);
            chat.Interruptable(this.interruptable);
            chat.ResumeAfterInterrupting(this.resumeAfterInt);
            chat.StalenessIncr(this.stalenessIncr);

            chat.cursor    = this.cursor;
            chat.lastRunAt = this.lastRunAt;
            chat.allowSmoothingOnResume = this.allowSmoothingOnResume;

            chat.commands = new List <Command>(this.commands.Count);
            this.commands.ForEach(cmd => cmd.ToGameObject(rt));

            return(chat);
        }