コード例 #1
0
        private void CheckGameArgs(CommandLineArgs args)
        {
            if (args.warp.Present)
            {
                nextState       = ApplicationState.Game;
                options.Episode = args.warp.Value.Item1;
                options.Map     = args.warp.Value.Item2;
                game.DeferedInitNew();
            }

            if (args.skill.Present)
            {
                options.Skill = (GameSkill)(args.skill.Value - 1);
            }

            if (args.deathmatch.Present)
            {
                options.Deathmatch = 1;
            }

            if (args.altdeath.Present)
            {
                options.Deathmatch = 2;
            }

            if (args.fast.Present)
            {
                options.FastMonsters = true;
            }

            if (args.respawn.Present)
            {
                options.RespawnMonsters = true;
            }

            if (args.nomonsters.Present)
            {
                options.NoMonsters = true;
            }

            if (args.loadgame.Present)
            {
                nextState = ApplicationState.Game;
                game.LoadGame(args.loadgame.Value);
            }

            if (args.playdemo.Present)
            {
                nextState    = ApplicationState.DemoPlayback;
                demoPlayback = new DemoPlayback(resource, options, args.playdemo.Value);
            }

            if (args.timedemo.Present)
            {
                nextState    = ApplicationState.DemoPlayback;
                demoPlayback = new DemoPlayback(resource, options, args.timedemo.Value);
            }
        }
コード例 #2
0
        private UpdateResult Update()
        {
            if (!wiping)
            {
                menu.Update();

                if (nextState != currentState)
                {
                    if (nextState != ApplicationState.Opening)
                    {
                        opening.Reset();
                    }

                    if (nextState != ApplicationState.DemoPlayback)
                    {
                        demoPlayback = null;
                    }

                    currentState = nextState;
                }

                if (quit)
                {
                    return(UpdateResult.Completed);
                }

                if (needWipe)
                {
                    needWipe = false;
                    StartWipe();
                }
            }

            if (!wiping)
            {
                switch (currentState)
                {
                case ApplicationState.Opening:
                    if (opening.Update() == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    break;

                case ApplicationState.DemoPlayback:
                    var result = demoPlayback.Update();
                    if (result == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    else if (result == UpdateResult.Completed)
                    {
                        Quit("FPS: " + demoPlayback.Fps.ToString("0.0"));
                    }
                    break;

                case ApplicationState.Game:
                    userInput.BuildTicCmd(cmds[options.ConsolePlayer]);
                    if (sendPause)
                    {
                        sendPause = false;
                        cmds[options.ConsolePlayer].Buttons |= (byte)(TicCmdButtons.Special | TicCmdButtons.Pause);
                    }
                    if (game.Update(cmds) == UpdateResult.NeedWipe)
                    {
                        StartWipe();
                    }
                    break;

                default:
                    throw new Exception("Invalid application state!");
                }
            }

            if (wiping)
            {
                var result = wipe.Update();
                renderer.RenderWipe(this, wipe);
                if (result == UpdateResult.Completed)
                {
                    wiping = false;
                }
            }
            else
            {
                renderer.Render(this);
            }

            options.Sound.Update();

            CheckMouseState();

            return(UpdateResult.None);
        }