Beispiel #1
0
        public void Update(GameTime gameTime, KeyboardState keyboardState, KeyboardState lastKeyboardState, MouseState mouseState, MouseState lastMouseState, Game1 game1)
        {
            HandleInput(gameTime, keyboardState, lastKeyboardState, mouseState, game1);
            camera.UpdateView();
            teleporter.Update(gameTime);
            game1.IsMouseVisible = false;

            foreach (KeyValuePair <string, Key> key in UsedKeys)
            {
                if (key.Key != "mouse" && key.Key != "lmouse")
                {
                    key.Value.Update(keyboardState, lastKeyboardState);
                }
                else
                {
                    key.Value.Update(mouseState, lastMouseState);
                }
            }

            #region blink
            if (timeBeforeStart.TotalMilliseconds >= MiSe_BeforeStart)
            {
                blink.Update(gameTime.ElapsedGameTime);
            }
            else
            {
            }
            #endregion

            game1.Window.Title = camera.position + "    " + camera.yaw + "," + camera.pitch;
        }
Beispiel #2
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, GameTime gameTime, FontLoader fontLoader)
        {
            if (gameTime.TotalGameTime.TotalMilliseconds <= LoadingTime + TimeBeforeUserCanContinue)
            {
                loading.Draw(graphics, spriteBatch);
            }

            else if (!(timePressed.TotalMilliseconds < DummyTimeSpan.TotalMilliseconds) && !isGoingToMenu)
            {
                spriteBatch.Begin();

                //if (!didClick) { Game1.PlaySound("back"); didClick = true; }
                string     output = "Press Any Key";
                SpriteFont font   = fontLoader.GetFont("OpenSans", false, 14);
                spriteBatch.DrawString(font, output, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight * 40 / 55), Color.White, 0, font.MeasureString(output) / 2, 1.2f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0);

                blackTex.SetData(new Color[] { new Color(0, 0, 0, PressAlpha) });
                spriteBatch.Draw(blackTex, new Rectangle(0, 0, 1000000, 20000000), Color.Black);
                spriteBatch.Draw(Title, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight * 9 / 10) / 2, null, Color.White, 0, new Vector2(650, 332) / 2, 1.3f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0);

                spriteBatch.End();
            }

            if (isGoingToMenu)
            {
                spriteBatch.Begin();
                if (logoAnimation.TotalMilliseconds >= timeBeforeMoving)
                {
                    logoAnim.Update(gameTime.ElapsedGameTime);
                }

                spriteBatch.Draw(logo, logoAnim.GetV2(0), null, Color.White * MathHelper.Clamp((float)logoAnimation.TotalMilliseconds / logoFadeInTime, 0, 1), 0, logoOrigin, logoAnim.GetV2(1), SpriteEffects.None, 0);
                spriteBatch.End();
            }

            graphics.GraphicsDevice.BlendState        = BlendState.Opaque;
            graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        }
Beispiel #3
0
        public void Update(GameTime gameTime, Game1 game1, MouseState state, MouseState lState, KeyboardState keystate, KeyboardState lastKeyState)
        {
            game1.IsMouseVisible = true;
            time      += gameTime.ElapsedGameTime;
            soundTime += gameTime.ElapsedGameTime;
            backGroundAlphaAnimation.Update(gameTime.ElapsedGameTime);


            int lastSelected = selected;

            #region input
            if (UsedKeys["down"].isPressed() && time.TotalMilliseconds >= 200)
            {
                selected++;
                if (selected > 5)
                {
                    if (time.TotalMilliseconds >= 300)
                    {
                        selected = 1;
                        time     = TimeSpan.Zero;
                    }
                    else
                    {
                        selected = 5;
                    }
                }
                else
                {
                    time = TimeSpan.Zero;
                }
            }
            else if (UsedKeys["up"].isPressed() && time.TotalMilliseconds >= 200)
            {
                selected--;
                if (selected < 1)
                {
                    if (time.TotalMilliseconds >= 300)
                    {
                        selected = 5;
                        time     = TimeSpan.Zero;
                    }
                    else
                    {
                        selected = 1;
                    }
                }
                else
                {
                    time = TimeSpan.Zero;
                }
            }

            for (int i = 0; i < TextPositions.Length; i++)
            {
                if (Game1.isHover(state, TextPositions[i]))
                {
                    if (state.X != lState.X || state.Y != lState.Y)
                    {
                        selected = i + 1;
                        time     = TimeSpan.Zero;
                    }
                    if (UsedKeys["mouse"].isPressed())
                    {
                        Game1.PlaySound("click");
                        switch (selected)
                        {
                        case 1:
                            if (!isMainMenu)
                            {
                                Game1.PlaySound("back");
                                game1.ChangeGameState(GameState.Playing);
                            }
                            else
                            {
                                if (!isFirstTime)
                                {
                                    game1.RestartGame(); isFirstTime = false;
                                }
                                game1.ChangeGameState(GameState.Loading);
                            }
                            //backGroundMusic.Stop();
                            break;

                        case 4: if (!isMainMenu)
                            {
                                game1.ChangeGameState(GameState.Menu);
                            }
                            break;

                        case 5: game1.ExitGame();
                            break;
                        }
                    }
                }
            }

            if (UsedKeys["enter"].isPressed())
            {
                if (!(selected == 1 && !isMainMenu))
                {
                    Game1.PlaySound("click");
                }
                switch (selected)
                {
                case 1:
                    if (!isMainMenu)
                    {
                        Game1.PlaySound("back");
                        game1.ChangeGameState(GameState.Playing);
                    }
                    else
                    {
                        if (!isFirstTime)
                        {
                            game1.RestartGame(); isFirstTime = false;
                        }
                        game1.ChangeGameState(GameState.Loading);
                    }
                    //backGroundMusic.Stop();
                    break;

                case 4: if (!isMainMenu)
                    {
                        game1.ChangeGameState(GameState.Menu);
                    }
                    break;

                case 5: game1.ExitGame();
                    break;
                }
            }
            #endregion

            if (soundTime.TotalMilliseconds >= 20)
            {
                if (lastSelected != selected)
                {
                    Game1.PlaySound("button");
                    soundTime = TimeSpan.Zero;
                }
            }

            if (!isMainMenu)
            {
                if (UsedKeys["escape"].isPressed())
                {
                    Game1.PlaySound("back");
                    game1.ChangeGameState(GameState.Playing);
                }
            }
            foreach (KeyValuePair <string, Key> key in UsedKeys)
            {
                if (key.Key != "mouse")
                {
                    key.Value.Update(keystate, lastKeyState);
                }
                else
                {
                    key.Value.Update(state, lState);
                }
            }
        }