Пример #1
0
 public void CopyFrom(TicCmd cmd)
 {
     this.forwardMove = cmd.forwardMove;
     this.sideMove    = cmd.sideMove;
     this.angleTurn   = cmd.angleTurn;
     this.buttons     = cmd.buttons;
 }
Пример #2
0
        public void BuildTicCmd(TicCmd cmd)
        {
            var keyForward     = IsPressed(config.key_forward);
            var keyBackward    = IsPressed(config.key_backward);
            var keyStrafeLeft  = IsPressed(config.key_strafeleft);
            var keyStrafeRight = IsPressed(config.key_straferight);
            var keyTurnLeft    = IsPressed(config.key_turnleft);
            var keyTurnRight   = IsPressed(config.key_turnright);
            var keyFire        = IsPressed(config.key_fire);
            var keyUse         = IsPressed(config.key_use);
            var keyRun         = IsPressed(config.key_run);
            var keyStrafe      = IsPressed(config.key_strafe);

            weaponKeys[0] = Keyboard.IsKeyPressed(Keyboard.Key.Num1);
            weaponKeys[1] = Keyboard.IsKeyPressed(Keyboard.Key.Num2);
            weaponKeys[2] = Keyboard.IsKeyPressed(Keyboard.Key.Num3);
            weaponKeys[3] = Keyboard.IsKeyPressed(Keyboard.Key.Num4);
            weaponKeys[4] = Keyboard.IsKeyPressed(Keyboard.Key.Num5);
            weaponKeys[5] = Keyboard.IsKeyPressed(Keyboard.Key.Num6);
            weaponKeys[6] = Keyboard.IsKeyPressed(Keyboard.Key.Num7);

            cmd.Clear();

            var strafe  = keyStrafe;
            var speed   = keyRun ? 1 : 0;
            var forward = 0;
            var side    = 0;

            if (config.game_alwaysrun)
            {
                speed = 1 - speed;
            }

            if (keyTurnLeft || keyTurnRight)
            {
                turnHeld++;
            }
            else
            {
                turnHeld = 0;
            }

            int turnSpeed;

            if (turnHeld < PlayerBehavior.SlowTurnTics)
            {
                turnSpeed = 2;
            }
            else
            {
                turnSpeed = speed;
            }

            if (strafe)
            {
                if (keyTurnRight)
                {
                    side += PlayerBehavior.SideMove[speed];
                }
                if (keyTurnLeft)
                {
                    side -= PlayerBehavior.SideMove[speed];
                }
            }
            else
            {
                if (keyTurnRight)
                {
                    cmd.AngleTurn -= (short)PlayerBehavior.AngleTurn[turnSpeed];
                }
                if (keyTurnLeft)
                {
                    cmd.AngleTurn += (short)PlayerBehavior.AngleTurn[turnSpeed];
                }
            }

            if (keyForward)
            {
                forward += PlayerBehavior.ForwardMove[speed];
            }
            if (keyBackward)
            {
                forward -= PlayerBehavior.ForwardMove[speed];
            }

            if (keyStrafeLeft)
            {
                side -= PlayerBehavior.SideMove[speed];
            }
            if (keyStrafeRight)
            {
                side += PlayerBehavior.SideMove[speed];
            }

            if (keyFire)
            {
                cmd.Buttons |= TicCmdButtons.Attack;
            }

            if (keyUse)
            {
                cmd.Buttons |= TicCmdButtons.Use;
            }

            // Check weapon keys.
            for (var i = 0; i < weaponKeys.Length; i++)
            {
                if (weaponKeys[i])
                {
                    cmd.Buttons |= TicCmdButtons.Change;
                    cmd.Buttons |= (byte)(i << TicCmdButtons.WeaponShift);
                    break;
                }
            }

            if (useMouse)
            {
                UpdateMouse();
                var ms = 0.5F * config.mouse_sensitivity;
                var mx = (int)MathF.Round(ms * mouseX);
                var my = (int)MathF.Round(ms * mouseY);
                forward += my;
                if (strafe)
                {
                    side += mx * 2;
                }
                else
                {
                    cmd.AngleTurn -= (short)(mx * 0x8);
                }
            }

            if (forward > PlayerBehavior.MaxMove)
            {
                forward = PlayerBehavior.MaxMove;
            }
            else if (forward < -PlayerBehavior.MaxMove)
            {
                forward = -PlayerBehavior.MaxMove;
            }
            if (side > PlayerBehavior.MaxMove)
            {
                side = PlayerBehavior.MaxMove;
            }
            else if (side < -PlayerBehavior.MaxMove)
            {
                side = -PlayerBehavior.MaxMove;
            }

            cmd.ForwardMove += (sbyte)forward;
            cmd.SideMove    += (sbyte)side;
        }
Пример #3
0
 public void BuildTicCmd(TicCmd cmd)
 {
     cmd.Clear();
 }
 public void BuildTicCmd(TicCmd cmd)
 {
 }
Пример #5
0
        public DoomApplication(IPlatform platform, CommandLineArgs args)
        {
            DoomApplication.Instance = this;

            this.FileSystem = new VirtualFileSystem();

            var wads = this.GetWadPaths(args);

            foreach (var wad in wads)
            {
                this.FileSystem.Add(new WadFileSystem(this.FileSystem.Read(wad)));
            }

            this.config = new Config(platform, "managed-doom.cfg");

            try
            {
                this.config.video_screenwidth  = Math.Clamp(this.config.video_screenwidth, 320, 3200);
                this.config.video_screenheight = Math.Clamp(this.config.video_screenheight, 200, 2000);

                this.window = platform.CreateWindow(ApplicationInfo.Title, this.config);
                this.window.Clear(Color.FromArgb(64, 64, 64));
                this.window.Display();

                this.Resource = new CommonResource();

                this.renderer = platform.CreateRenderer(this.config, this.window, this.Resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    this.sound = platform.CreateSound(this.config);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    this.music = platform.CreateMusic(this.config);
                }

                this.userInput = platform.CreateUserInput(this.config, this.window, args.nomouse.Present);

                this.events = new List <DoomEvent>();

                this.options           = new GameOptions();
                this.options.Renderer  = this.renderer;
                this.options.Sound     = this.sound;
                this.options.Music     = this.music;
                this.options.UserInput = this.userInput;

                this.menu = new DoomMenu(this);

                this.opening = new OpeningSequence(this.options);

                this.cmd = new TicCmd();

                this.game = new DoomGame(this.Resource, this.options);

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

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

                this.sendPause = false;

                this.quit        = false;
                this.quitMessage = null;

                this.CheckGameArgs(args);

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

                this.window.SetFramerateLimit(35);
            }
            catch (Exception e)
            {
                this.Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }