Пример #1
0
        public DoomApplication(CommandLineArgs args)
        {
            config = new Config(ConfigUtilities.GetConfigPath());

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = new VideoMode((uint)config.video_screenwidth, (uint)config.video_screenheight);
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

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

                resource = new CommonResource(GetWadPaths(args), !args.nodeh.Present);

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);

                events = new List <DoomEvent>();

                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

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

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

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

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);

                window.Closed      += (sender, e) => window.Close();
                window.KeyPressed  += KeyPressed;
                window.KeyReleased += KeyReleased;

                if (!args.timedemo.Present)
                {
                    window.SetFramerateLimit(35);
                }

                mouseGrabbed = false;
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Пример #2
0
        public DoomApplication(CommandLineArgs args, String[] configLines, HttpClient http, Stream wadStream,
                               IJSRuntime jsRuntime, IJSInProcessRuntime jSInProcessRuntime, WebAssemblyJSRuntime webAssemblyJSRuntime,
                               string wadUrl)
        {
            Http                 = http;
            WadStream            = wadStream;
            JsRuntime            = jsRuntime;
            JSInProcessRuntime   = jSInProcessRuntime;
            WebAssemblyJSRuntime = webAssemblyJSRuntime;
            configLines          = new string[] {
                "video_screenwidth=320",
                "video_screenHeight=200",
            };
            config = new Config(configLines);

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = VideoMode.CanvasMode;
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

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

                // resource = new CommonResource(GetWadPaths(args));
                resource = new CommonResource(new string[] { wadUrl });

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);



                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

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

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

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

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Пример #3
0
 public Map(CommonResource resorces, World world)
     : this(resorces.Wad, resorces.Textures, resorces.Flats, world)
 {
 }
Пример #4
0
        public World(CommonResource resorces, GameOptions options, DoomGame game)
        {
            this.options = options;
            this.game    = game;

            if (game != null)
            {
                random = game.Random;
            }
            else
            {
                random = new DoomRandom();
            }

            map = new Map(resorces, this);

            thinkers         = new Thinkers(this);
            specials         = new Specials(this);
            thingAllocation  = new ThingAllocation(this);
            thingMovement    = new ThingMovement(this);
            thingInteraction = new ThingInteraction(this);
            mapCollision     = new MapCollision(this);
            mapInteraction   = new MapInteraction(this);
            pathTraversal    = new PathTraversal(this);
            hitscan          = new Hitscan(this);
            visibilityCheck  = new VisibilityCheck(this);
            sectorAction     = new SectorAction(this);
            playerBehavior   = new PlayerBehavior(this);
            itemPickup       = new ItemPickup(this);
            weaponBehavior   = new WeaponBehavior(this);
            monsterBehavior  = new MonsterBehavior(this);
            lightingChange   = new LightingChange(this);
            statusBar        = new StatusBar(this);
            autoMap          = new AutoMap(this);
            cheat            = new Cheat(this);

            options.IntermissionInfo.TotalFrags = 0;
            options.IntermissionInfo.ParTime    = 180;

            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                options.Players[i].KillCount   = 0;
                options.Players[i].SecretCount = 0;
                options.Players[i].ItemCount   = 0;
            }

            // Initial height of view will be set by player think.
            options.Players[options.ConsolePlayer].ViewZ = Fixed.Epsilon;

            totalKills   = 0;
            totalItems   = 0;
            totalSecrets = 0;

            LoadThings();

            // If deathmatch, randomly spawn the active players.
            if (options.Deathmatch != 0)
            {
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    if (options.Players[i].InGame)
                    {
                        options.Players[i].Mobj = null;
                        thingAllocation.DeathMatchSpawnPlayer(i);
                    }
                }
            }

            specials.SpawnSpecials();

            levelTime    = 0;
            doneFirstTic = false;
            secretExit   = false;
            completed    = false;

            validCount = 0;

            displayPlayer = options.ConsolePlayer;

            dummy = new Mobj(this);

            options.Music.StartMusic(Map.GetMapBgm(options), true);
        }
Пример #5
0
 public World(CommonResource resorces, GameOptions options) : this(resorces, options, null)
 {
 }
Пример #6
0
        public World(CommonResource resorces, GameOptions options, Player[] players)
        {
            Options = options;
            Players = players;

            map = new Map(resorces, this);

            random = options.Random;

            validCount = 0;

            thinkers = new Thinkers(this);
            specials = new Specials(this);

            thingAllocation  = new ThingAllocation(this);
            thingMovement    = new ThingMovement(this);
            thingInteraction = new ThingInteraction(this);
            mapCollision     = new MapCollision(this);
            mapInteraction   = new MapInteraction(this);
            pathTraversal    = new PathTraversal(this);
            hitscan          = new Hitscan(this);
            visibilityCheck  = new VisibilityCheck(this);
            sectorAction     = new SectorAction(this);
            playerBehavior   = new PlayerBehavior(this);
            itemPickup       = new ItemPickup(this);
            weaponBehavior   = new WeaponBehavior(this);
            monsterBehavior  = new MonsterBehavior(this);
            lightingChange   = new LightingChange(this);
            statusBar        = new StatusBar(this);
            autoMap          = new AutoMap(this);

            totalKills              = 0;
            totalItems              = 0;
            totalSecrets            = 0;
            options.wminfo.maxFrags = 0;
            options.wminfo.ParTime  = 180;
            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                players[i].KillCount   = 0;
                players[i].SecretCount = 0;
                players[i].ItemCount   = 0;
            }

            // Initial height of PointOfView
            // will be set by player think.
            players[consoleplayer].ViewZ = new Fixed(1);

            LoadThings();

            // if deathmatch, randomly spawn the active players
            if (options.Deathmatch != 0)
            {
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    if (players[i].InGame)
                    {
                        players[i].Mobj = null;
                        G_DeathMatchSpawnPlayer(i);
                    }
                }
            }

            SpawnSpecials();
        }