コード例 #1
0
ファイル: Version4.cs プロジェクト: Bigtalljosh/Devoxelation
        public override void Update(GameTime gameTime, bool covered)
        {
            InputManager input = ScreenManager.InputSystem;

            elapsedTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (elapsedTime > 1000.0f)
            {
                fps         = totalFrames;
                totalFrames = 0;
                elapsedTime = 0;
            }

            //Exit Key
            KeyboardState keyboard = Keyboard.GetState();

            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) || keyboard.IsKeyDown(Keys.Escape))
            {
                Remove();
                ScreenManager.AddScreen(new MainMenu());
            }

            //Camera rotations >.<
            cx = px + (float)Math.Sin(pt) * 5.0f;
            cy = py + (float)Math.Cos(pt) * 5.0f;

            #region Mouse

            //Mouse values/Center
            KeyboardState keyState   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();
            centerX = ScreenManager.Game.Window.ClientBounds.Width / 2;
            centerY = ScreenManager.Game.Window.ClientBounds.Height / 2;
            Mouse.SetPosition(centerX, centerY);

            //Mouse functions
            if (mouseState.X < centerX)
            {
                pt += 0.07f;
            }

            if (mouseState.X > centerX)
            {
                pt -= 0.07f;
            }

            if (mouseState.Y < centerY)
            {
                cz += 0.1f;
            }

            if (mouseState.Y > centerY)
            {
                cz -= 0.1f;
            }
            #endregion

            #region Keyboard
            //Keyboard movements

            if (keyState.IsKeyDown(Keys.Add))
            {
                ay -= 0.1f;
                ap -= 0.1f;
                cz -= 0.1f;
            }

            if (keyState.IsKeyDown(Keys.Subtract))
            {
                ay += 0.1f;
                ap += 0.1f;
                cz += 0.1f;
            }

            if (keyState.IsKeyDown(Keys.W))
            {
                px += (float)Math.Sin(pt) * 0.3f;
                py += (float)Math.Cos(pt) * 0.3f;
            }

            if (keyState.IsKeyDown(Keys.S))
            {
                px += (float)Math.Sin(pt) * -0.3f;
                py += (float)Math.Cos(pt) * -0.3f;
            }

            if (keyState.IsKeyDown(Keys.Space) && ScreenManager.GraphicsDevice.RasterizerState == RasterizerState.CullClockwise)
            {
                ScreenManager.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
                raster = ScreenManager.GraphicsDevice.RasterizerState.ToString();
            }
            else if (keyState.IsKeyDown(Keys.Space) && ScreenManager.GraphicsDevice.RasterizerState == RasterizerState.CullCounterClockwise)
            {
                ScreenManager.GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
                raster = ScreenManager.GraphicsDevice.RasterizerState.ToString();
            }

            #endregion

            // Only Update the game when the game is UNPAUSED
            base.Update(gameTime, covered);

            //Pause Key
            if (TotalElapsedTime >= KeyPressCheckDelay)
            {
                if (input.MenuCancel)
                {
                    GameState = GameStates.Paused;
                }
            }

            else
            {
                //***********************LOGIC FOR Pause HERE************************
                //UnPause
                if (TotalElapsedTime >= KeyPressCheckDelay)
                {
                    // UnPause the current game
                    if (input.MenuCancel || input.MenuSelect)
                    {
                    }
                }
            }
        }
コード例 #2
0
 public override void Remove()
 {
     // After the ScreenTime variable counts to 0, loads the next screen then removes current from stack.
     ScreenManager.AddScreen(new UniversitySplash());
     base.Remove();
 }
コード例 #3
0
 public override void Remove()
 {
     // After the ScreenTime variable counts to 0, loads the next screen then removes current from stack.
     ScreenManager.AddScreen(new ControllerSelectScreen());
     base.Remove();
 }