Beispiel #1
0
        public Player()
        {
            this.cmd = new TicCmd();

            this.powers = new int[(int)PowerType.Count];

            this.playerSprites = new PlayerSpriteDef[(int)PlayerSprite.Count];

            for (var i = 0; i < this.playerSprites.Length; i++)
            {
                this.playerSprites[i] = new PlayerSpriteDef();
            }
        }
Beispiel #2
0
        public Player(int number)
        {
            this.number = number;

            this.name = Player.defaultPlayerNames[number];

            this.cmd = new TicCmd();

            this.powers = new int[(int)PowerType.Count];
            this.cards  = new bool[(int)CardType.Count];

            this.frags = new int[Player.MaxPlayerCount];

            this.playerSprites = new PlayerSpriteDef[(int)PlayerSprite.Count];

            for (var i = 0; i < this.playerSprites.Length; i++)
            {
                this.playerSprites[i] = new PlayerSpriteDef();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Advance the game one frame.
        /// </summary>
        public UpdateResult Update(TicCmd cmd)
        {
            // Do player reborns if needed.
            var player = this.options.Player;

            if (player.PlayerState == PlayerState.Reborn)
            {
                this.DoReborn();
            }

            // Do things to change the game state.
            while (this.gameAction != GameAction.Nothing)
            {
                switch (this.gameAction)
                {
                case GameAction.LoadLevel:
                    this.DoLoadLevel();

                    break;

                case GameAction.NewGame:
                    this.DoNewGame();

                    break;

                case GameAction.LoadGame:
                    this.DoLoadGame();

                    break;

                case GameAction.SaveGame:
                    this.DoSaveGame();

                    break;

                case GameAction.Completed:
                    this.DoCompleted();

                    break;

                case GameAction.Victory:
                    this.DoFinale();

                    break;

                case GameAction.WorldDone:
                    this.DoWorldDone();

                    break;

                case GameAction.Nothing:
                    break;
                }
            }

            player.Cmd.CopyFrom(cmd);

            // Check for turbo cheats.
            if (cmd.ForwardMove > GameConst.TurboThreshold && (this.world.LevelTime & 31) == 0 && ((this.world.LevelTime >> 5) & 3) == 0)
            {
                player.SendMessage("player is turbo!");
            }

            // Check for special buttons.
            if ((player.Cmd.Buttons & TicCmdButtons.Special) != 0)
            {
                if ((player.Cmd.Buttons & TicCmdButtons.SpecialMask) == TicCmdButtons.Pause)
                {
                    this.paused = !this.paused;

                    if (this.paused)
                    {
                        this.options.Sound.Pause();
                    }
                    else
                    {
                        this.options.Sound.Resume();
                    }
                }
            }

            // Do main actions.
            var result = UpdateResult.None;

            switch (this.gameState)
            {
            case GameState.Level:
                if (!this.paused || this.world.FirstTicIsNotYetDone)
                {
                    result = this.world.Update();

                    if (result == UpdateResult.Completed)
                    {
                        this.gameAction = GameAction.Completed;
                    }
                }

                break;

            case GameState.Intermission:
                result = this.intermission.Update();

                if (result == UpdateResult.Completed)
                {
                    this.gameAction = GameAction.WorldDone;

                    if (this.world.SecretExit)
                    {
                        player.DidSecret = true;
                    }

                    if (DoomApplication.Instance.IWad == "doom2" ||
                        DoomApplication.Instance.IWad == "freedoom2" ||
                        DoomApplication.Instance.IWad == "plutonia" ||
                        DoomApplication.Instance.IWad == "tnt")
                    {
                        switch (this.options.Map)
                        {
                        case 6:
                        case 11:
                        case 20:
                        case 30:
                            this.DoFinale();
                            result = UpdateResult.NeedWipe;

                            break;

                        case 15:
                        case 31:
                            if (this.world.SecretExit)
                            {
                                this.DoFinale();
                                result = UpdateResult.NeedWipe;
                            }

                            break;
                        }
                    }
                }

                break;

            case GameState.Finale:
                result = this.finale.Update();

                if (result == UpdateResult.Completed)
                {
                    this.gameAction = GameAction.WorldDone;
                }

                break;
            }

            this.gameTic++;

            if (result == UpdateResult.NeedWipe)
            {
                return(UpdateResult.NeedWipe);
            }
            else
            {
                return(UpdateResult.None);
            }
        }