示例#1
0
        public void ResetWorldForStartingNewLife()
        {
            Point roomStart = GetContainingRoom(this._player.Position).Location;

            this._worldWindow.ResetPosition(new Vector2(roomStart.X, roomStart.Y));
            this._player.Reset();

            MoveNearbyMonstersToASafeDistance();

            GlobalServices.SoundPlayer.Play(GameSound.PlayerStartsNewLife);
            this._worldReturnType = WorldReturnType.Normal;
            GlobalServices.PlayerInput.Enabled = true;
        }
示例#2
0
        private void WorldCompleted(WorldCompleted worldCompleted)
        {
            foreach (IMonster monster in GlobalServices.GameState.DistinctItemsOfType <IMonster>())
            {
                monster.InstantlyExpire();
            }

            GlobalServices.SoundPlayer.PlayWithCallback(GameSound.PlayerFinishesWorld,
                                                        (sender, args) => this._worldReturnType = WorldReturnType.FinishedWorld);

            GlobalServices.PlayerInput.Enabled = false;

            GlobalServices.Game.Components.Add(new FlashEffectTimer(this));
        }
示例#3
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool doesScreenHaveFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, doesScreenHaveFocus, coveredByOtherScreen);

            if (this._isGamePaused || !this.IsActive)
            {
                gameTime = new GameTime();
            }

            GlobalServices.SoundPlayer.ActiveSoundService.Update();

            if (!this._isGamePaused && gameTime.ElapsedGameTime != TimeSpan.Zero)
            {
                // ReSharper disable once PossibleNullReferenceException
                WorldReturnType worldReturnType = this._world.Update(gameTime);
                switch (worldReturnType)
                {
                case WorldReturnType.FinishedWorld:
                    //this._world = null;
                    //this._livesRemaining++;
                    // todo this isn't the ideal place for this
                    VolumeControl.Instance.SaveState();
                    this.ScreenManager.Game.Exit();
                    break;

                case WorldReturnType.LostLife:
                    var screenWipe = new ScreenWipe();
                    screenWipe.Wiped += LostLife;
                    ScreenManager.AddScreen(screenWipe, this.ControllingPlayer);
                    break;
                }
            }

            if (gameTime.IsRunningSlowly)
            {
                string text = $"{gameTime.TotalGameTime}: Running slowly";
                System.Diagnostics.Trace.WriteLine(text);
            }
        }
示例#4
0
 private void LostLife(LifeLost lifeLost)
 {
     GlobalServices.SoundPlayer.PlayWithCallback(GameSound.PlayerDies,
                                                 (sender, args) => this._worldReturnType = WorldReturnType.LostLife);
 }