Beispiel #1
0
        private void OutputDispatched(object sender, EventArgs <string> eventArgs)
        {
            // 語調フィルタからの解析
            var script = _parlance.Filter(eventArgs.Value);

            // スクリプトの解析と再生
            foreach (var token in Token.Parse(script))
            {
                PlayToken(token);
            }
        }
Beispiel #2
0
        private void PlayToken(Token token)
        {
            switch (token.Tag)
            {
            // 発言系
            case Tags.None:
            case Tags.Unknown:
                _baloon.StopTimeoutCountdown();
                _baloon.Show();
                _baloon.Append(token.Surface);
                break;

            case Tags.Clear:
                _baloon.Clear();
                break;

            case Tags.NewLine:
                _baloon.NewLine();
                break;

            case Tags.Anchor:
                switch (token.Span)
                {
                case SpanModes.Enter:
                    _baloon.BeginAnchor(OnAnchorClick, token);
                    break;

                case SpanModes.Exit:
                    _baloon.EndAnchor();
                    break;
                }
                break;

            case Tags.Image:
                _baloon.AppendImage(token.Option);
                break;

            // システム系
            case Tags.Wait:
            {
                double wait;
                if (double.TryParse(token.Option, out wait) && wait > 0)
                {
                    Thread.Sleep((int)(wait * 1000));
                }
            }
            break;

            case Tags.Command:
                OnCommand(token.Option);
                break;

            case Tags.Demeanor:
                OnDemeanor(token.Option);
                break;

            // End of Script
            case Tags.EndOfScript:
                _baloon.StartTimeoutCountdown();
                SpinWait.SpinUntil(() => !_baloon.IsVisible);
                break;
            }
        }