示例#1
0
        public static void Engage(Character top, Character bottom, string name = "(start)")
        {
            if (sceneList == null)
            {
                sceneList = Mix.GetTokenTree("dialogue.tml", true);
            }

            SceneSystem.top    = top;
            SceneSystem.bottom = bottom;
            SceneSystem.actors = new[] { top, bottom };
            var dreaming = top.HasToken("dream");

            if (name.Contains('\xE064'))
            {
                name = name.Remove(name.LastIndexOf('\xE064'));
            }

            var openings = sceneList.Where(x => x.Name == "scene" && x.GetToken("name").Text == name).ToList();

            if (openings.Count == 0)
            {
                MessageBox.Notice(string.Format("Could not find a proper opening for scene name \"{0}\". Aborting.", name), true, "Uh-oh.");
                return;
            }
            var firstScene = openings.FirstOrDefault(i => SexManager.LimitsOkay(actors, i));
            var scenes     = new List <Token>()
            {
                firstScene
            };

            if (firstScene.HasToken("random"))
            {
                var randomKey = firstScene.GetToken("random").Text;
                foreach (var s in openings.Where(i => i != firstScene && i.HasToken("random") && i.GetToken("random").Text == randomKey && SexManager.LimitsOkay(actors, i)))
                {
                    scenes.Add(s);
                }
            }
            var scene = scenes.PickOne();

            var message = i18n.Viewpoint(ExtractParagraphsAndScripts(scene), SceneSystem.top, SceneSystem.bottom);
            var actions = ExtractActions(scene);

            if (actions.Count == 1)
            {
                var target = actions.First().Key;
                actions.Clear();
                actions.Add(target, "==>");
            }

            if (bottom == NoxicoGame.Me.Player.Character && !letBottomChoose)
            {
                if (actions.Count == 0)
                {
                    MessageBox.Notice(message, true, bottom.Name.ToString(true));
                }
                else
                {
                    var randomAction = actions.Keys.ToArray().PickOne();
                    actions.Clear();
                    actions.Add(randomAction, "==>");
                    MessageBox.List(message, actions, () => { Engage(SceneSystem.top, SceneSystem.bottom, (string)MessageBox.Answer); }, false, true, bottom.GetKnownName(true, true));
                }
            }
            else
            {
                letBottomChoose = false;
                if (actions.Count == 0)
                {
                    MessageBox.Notice(message, !dreaming, bottom.GetKnownName(true, true));
                }
                else
                {
                    MessageBox.List(message, actions, () => { Engage(SceneSystem.top, SceneSystem.bottom, (string)MessageBox.Answer); }, false, !dreaming, bottom.GetKnownName(true, true));
                }
            }

            if (dreaming)
            {
                new UIPNGBackground(Mix.GetBitmap("dream.png")).Draw();
            }
            else
            {
                NoxicoGame.Me.CurrentBoard.Redraw();
                NoxicoGame.Me.CurrentBoard.Draw();
            }
        }