Esempio n. 1
0
        public Doom(CommandLineArgs args, Config config, GameContent content, IVideo video, ISound sound, IMusic music, IUserInput userInput)
        {
            video     = video ?? NullVideo.GetInstance();
            sound     = sound ?? NullSound.GetInstance();
            music     = music ?? NullMusic.GetInstance();
            userInput = userInput ?? NullUserInput.GetInstance();

            this.args      = args;
            this.config    = config;
            this.content   = content;
            this.video     = video;
            this.sound     = sound;
            this.music     = music;
            this.userInput = userInput;

            if (args.deh.Present)
            {
                DeHackEd.ReadFiles(args.deh.Value);
            }

            if (!args.nodeh.Present)
            {
                DeHackEd.ReadDeHackEdLump(content.Wad);
            }

            events = new List <DoomEvent>();

            options             = new GameOptions();
            options.GameVersion = content.Wad.GameVersion;
            options.GameMode    = content.Wad.GameMode;
            options.MissionPack = content.Wad.MissionPack;
            options.Video       = video;
            options.Sound       = sound;
            options.Music       = music;
            options.UserInput   = userInput;

            menu = new DoomMenu(this);

            opening = new OpeningSequence(content, options);

            cmds = new TicCmd[Player.MaxPlayerCount];
            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                cmds[i] = new TicCmd();
            }
            game = new DoomGame(content, options);

            wipeEffect = new WipeEffect(video.WipeBandCount, video.WipeHeight);
            wiping     = false;

            currentState = DoomState.None;
            nextState    = DoomState.Opening;
            needWipe     = false;

            sendPause = false;

            quit        = false;
            quitMessage = null;

            mouseGrabbed = false;

            CheckGameArgs();
        }
Esempio n. 2
0
 public void LoadGame(int slotNumber)
 {
     game.LoadGame(slotNumber);
     nextState = DoomState.Game;
 }
Esempio n. 3
0
        public UpdateResult Update()
        {
            DoEvents();

            if (!wiping)
            {
                menu.Update();

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

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

                    currentState = nextState;
                }

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

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

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

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

                case DoomState.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)
            {
                if (wipeEffect.Update() == UpdateResult.Completed)
                {
                    wiping = false;
                }
            }

            sound.Update();

            CheckMouseState();

            return(UpdateResult.None);
        }
Esempio n. 4
0
 public void EndGame()
 {
     nextState = DoomState.Opening;
 }
Esempio n. 5
0
 public void NewGame(GameSkill skill, int episode, int map)
 {
     game.DeferedInitNew(skill, episode, map);
     nextState = DoomState.Game;
 }
Esempio n. 6
0
        private void CheckGameArgs()
        {
            if (args.warp.Present)
            {
                nextState       = DoomState.Game;
                options.Episode = args.warp.Value.Item1;
                options.Map     = args.warp.Value.Item2;
                game.DeferedInitNew();
            }
            else if (args.episode.Present)
            {
                nextState       = DoomState.Game;
                options.Episode = args.episode.Value;
                options.Map     = 1;
                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 = DoomState.Game;
                game.LoadGame(args.loadgame.Value);
            }

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

            if (args.timedemo.Present)
            {
                nextState    = DoomState.DemoPlayback;
                demoPlayback = new DemoPlayback(content, options, args.timedemo.Value);
            }
        }