예제 #1
0
        /// <summary>
        /// Undoes StartNewGame() so that a new game can be created.
        /// </summary>
        private void ClearGame()
        {
            GameState.ClearGame();
            PainStaticMaker.ClearGame();
            LoseScreen.ClearGame();
            _shiftInterface.ClearGame();

            Objects.ClearGame();
        }
예제 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            float deltaTime = ((float)gameTime.ElapsedGameTime.TotalMilliseconds) * 0.001f;

            //must call once BEFORE any keyboard/mouse operations
            InputManager.Update(deltaTime);

            updateGameState();

            if (GameState.Mode == GameState.GameMode.EXITED)
            {
                return;
            }
            else if (GameState.Mode == GameState.GameMode.PREGAME)
            {
            }
            else if (GameState.Mode == GameState.GameMode.NORMAL)
            {
                normalGameUpdate(deltaTime);
            }
            else if (GameState.Mode == GameState.GameMode.SHIFTING)
            {
                _shiftInterface.Update(deltaTime);
            }
            else if (GameState.Mode == GameState.GameMode.PAUSED)
            {
                //update stuff for the pause menu
            }
            else if (GameState.Mode == GameState.GameMode.GAMEOVERWIN)
            {
                //quack goes the duck
            }
            else if (GameState.Mode == GameState.GameMode.GAMEOVERLOSE)
            {
                _backgroundMusic.Stop();
                LoseScreen.Update(deltaTime);
                Objects.MainCamera.Update(deltaTime);
                PainStaticMaker.Update(deltaTime);
            }

            base.Update(gameTime);
        }
예제 #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.StartNewGame will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _hudManager.Initialize();

            //set up the black pixel used for clearing the screen
            _blackPx = new Texture2D(_graphics.GraphicsDevice, 1, 1);
            uint[] px = { 0xFFFFFFFF };
            _blackPx.SetData <uint>(px);

            InputManager.Initialize();

            SoundEffectManager.Initilize();

            //initial menu music
            _backgroundMusic = new MusicController();
            _backgroundMusic.Enqueue("Predatory Instincts_ElevatorRemix");
            _backgroundMusic.Play();

            PainStaticMaker.Initialize();

            _mouseDrawer.Initialize();

            CharacterType.Initialize();
            ParticleType.Initialize();

            LoseScreen.Initialize();

            GameState.Initilize();
            StartNewGame();

            _shiftInterface.Initialize(_spriteBatch);

            base.Initialize();
        }
예제 #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            /**** Draw Game Objects ****/
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            //Draw real game
            drawObjects(gameTime);

            _spriteBatch.End();


            /**** Draw Glow Effects ****/
            //Using BlendState.Additive will make things drawn in this section only brighten, never darken.
            //This means colors will be intensified, and look like glow

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);

            //Draw real game
            drawGlows(gameTime);

            PainStaticMaker.DrawStatic(_spriteBatch);

            _spriteBatch.End();



            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            /**** Draw HUD ****/
            _hudManager.Draw_HUD(_spriteBatch);

            Objects.DrawMinimap(Objects.MainCamera);


            /**** Draw Special State Objects ****/

            if (GameState.Mode == GameState.GameMode.PAUSED)
            {
                drawPauseOverlay();
            }
            else if (GameState.Mode == GameState.GameMode.GAMEOVERWIN)
            {
                drawGameoverWinOverlay();
            }
            else if (GameState.Mode == GameState.GameMode.GAMEOVERLOSE)
            {
                LoseScreen.Draw(_spriteBatch);
            }
            else if (GameState.Mode == GameState.GameMode.PREGAME)
            {
                drawStartMenuOverlay(gameTime);
            }
            else if (GameState.Mode == GameState.GameMode.SHIFTING)
            {
                _shiftInterface.Draw();
                Objects.DrawOnShiftInterface(_shiftInterface);
            }

            _mouseDrawer.drawMouse(_spriteBatch);

            _spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #5
0
        private void updateGameState()
        {
            //Allows the game to exit
            if (InputManager.IsKeyDown(Keys.Escape))
            {
                ClearGame();
                GameState.Mode = GameState.GameMode.EXITED;
                this.Exit();
                return;
            }


            //menu screen progression
            if (GameState.Mode == GameState.GameMode.PREGAME && InputManager.IsMouseClicked())
            {
                //game music
                _backgroundMusic.Stop();
                _backgroundMusic.ClearQueue();
                _backgroundMusic.Enqueue("01 Cryogenic Dreams");
                _backgroundMusic.Enqueue("05 Rapid Cognition");
                _backgroundMusic.Enqueue("10 Disappear");
                _backgroundMusic.Play();
                GameState.Mode = GameState.GameMode.NORMAL;
            }
            if ((GameState.Mode == GameState.GameMode.GAMEOVERWIN || (GameState.Mode == GameState.GameMode.GAMEOVERLOSE && LoseScreen.TimerFinished())) && InputManager.IsMouseClicked())
            {
                ResetGame();
                _backgroundMusic.Stop();
                _backgroundMusic.ClearQueue();
                _backgroundMusic.Enqueue("Predatory Instincts_ElevatorRemix");
                _backgroundMusic.Play();
                GameState.Mode = GameState.GameMode.PREGAME;
            }

            //pause/unpause
            if (InputManager.IsKeyClicked(Keys.P) && GameState.Mode == GameState.GameMode.PAUSED)
            {
                GameState.Mode = GameState.GameMode.NORMAL;
                SoundEffectManager.ResumeSound("shift");
            }
            else if (InputManager.IsKeyClicked(Keys.P) && GameState.Mode == GameState.GameMode.NORMAL)
            {
                GameState.Mode = GameState.GameMode.PAUSED;
                SoundEffectManager.PauseSound("shift");
            }

            //shifting interface
            if (InputManager.IsKeyClicked(Keys.Space) && GameState.Mode == GameState.GameMode.SHIFTING)
            {
                GameState.Mode = GameState.GameMode.NORMAL;
                SoundEffectManager.ResumeSound("shift");
            }
            else if (InputManager.IsKeyClicked(Keys.Space) && GameState.Mode == GameState.GameMode.NORMAL)
            {
                GameState.Mode = GameState.GameMode.SHIFTING;
                SoundEffectManager.PauseSound("shift");
            }

            //you died
            if (Objects.MainPlayer == null || Objects.MainPlayer.ShouldBeKilled)
            {
                GameState.Mode = GameState.GameMode.GAMEOVERLOSE;
                SoundEffectManager.StopInstances();
            }
            if (GameState.AllObjectivesCollected)
            {
                GameState.Mode = GameState.GameMode.GAMEOVERWIN;
                SoundEffectManager.StopInstances();
            }
        }