public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); prevKbs = currentKbs; currentKbs = Keyboard.GetState(); foreach (Keys k in keysToCheck) { if (checkKey(k)) { addKeyToString(k); } } contButton.Update(mouse.rectangle); if (contButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { if (!string.IsNullOrEmpty(name) && !name.Contains("_")) { buttonconfirm.Play(); ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(new GamePlayScreen(this.gamediff, name), null); } else { buttonerror.Play(); } } mouse.Update(); }
public override void HandleInput(InputState input) { mouse.Update(); if (mouse.newLeftClick) { ExitScreen(); } }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); mouse.Update(); exitButton.Update(mouse.rectangle); if (exitButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { exitButton.sound.Play(); ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(new MainMenuScreen(), null); } }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); mouse.Update(); easyButton.Update(mouse.rectangle); if (easyButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { ExitScreen(); } hardButton.Update(mouse.rectangle); if (hardButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { ExitScreen(); System.Threading.Thread.Sleep(100); ScreenManager.AddScreen(new MainMenuScreen(), null); } }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); mouse.Update(); exitButton.Update(mouse.rectangle); if (exitButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { exitButton.sound.Play(); ExitScreen(); if (player.level < 3) { ScreenManager.AddScreen(new GamePlayScreen(GameDifficulty.EASY_MODE, player.name, player.score, player._lives, player._health, player.level + 1), null); } else { ScreenManager.AddScreen(new GameOverScreen(player, GameOverScreen.gameOverType.COMPLETE), null); } } }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); mouse.Update(); easyButton.Update(mouse.rectangle); if (easyButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { easyButton.sound.Play(); ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(new NameEntryScreen(GameDifficulty.EASY_MODE), null); } hardButton.Update(mouse.rectangle); if (hardButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { hardButton.sound.Play(); ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(new NameEntryScreen(GameDifficulty.HARD_MODE), null); } }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); mouse.Update(); highscoresButton.Update(mouse.rectangle); if (highscoresButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { click.Play(); ExitScreen(); ScreenManager.AddScreen(new HighScoreScreen(), null); } newGameButton.Update(mouse.rectangle); if (newGameButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { click.Play(); ExitScreen(); ScreenManager.AddScreen(new ModeSelectScreen(), null); } exitButton.Update(mouse.rectangle); if (exitButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { click.Play(); ExitScreen(); ScreenManager.Game.Exit(); } helpButton.Update(mouse.rectangle); if (helpButton.Intersects(mouse.rectangle) && mouse.newLeftClick) { click.Play(); ExitScreen(); ScreenManager.AddScreen(new InstructionsScreen(), null); } }
public void Update(GameTime gameTime, List <TileObject> t, Camera cam) { //Calculate Sprite Rotation _playerPrevPos = _playerPos; Vector2 direction = _playerPos - _mouse.position; direction.Normalize(); _playerRot = (float)Math.Atan2(direction.Y, direction.X) + (float)(Math.PI * 0.5f); previous = current; current = Keyboard.GetState(); if (isAlive) { if (current.IsKeyDown(Keys.W) && !collision(new Vector2(0, -3), t) && !cam.isMovingUp) { if (_playerPos.Y >= 0 + _playerRec.Height / 2) { _playerPos.Y -= 3; } } if (current.IsKeyDown(Keys.S) && !collision(new Vector2(0, 3), t) && !cam.isMovingDown) { if (_playerPos.Y <= 600 - _playerRec.Height / 2) { _playerPos.Y += 3; } } if (current.IsKeyDown(Keys.A) && !collision(new Vector2(-3, 0), t) && !cam.isMovingLeft) { if (_playerPos.X >= 0 + _playerRec.Width / 2) { _playerPos.X -= 3; } } if (current.IsKeyDown(Keys.D) && !collision(new Vector2(3, 0), t) && !cam.isMovingRight) { if (_playerPos.X <= 800 - _playerRec.Width / 2) { _playerPos.X += 3; } } } if (_mouse.newLeftClick) { if (bulletList.Count < MAX_SHOTS) { bulletList.Add(new Bullet(_bulletTexture, _mouse.position, this._playerPos)); shot.Play(); } } if (bulletList != null) { foreach (Bullet b in bulletList) { b.Update(); } removeBullets(bulletList); } if (_health <= 0) { isAlive = false; pSprite = dieSprite; } if (_playerPos == _playerPrevPos && !cam.isMovingUp && !cam.isMovingDown && !cam.isMovingLeft && !cam.isMovingRight && isAlive) { pmState = PlayerMovementState.IDLE; } else if (_playerPos != _playerPrevPos && isAlive) { pmState = PlayerMovementState.WALKING; } if (pmState == PlayerMovementState.IDLE && isAlive) { pSprite = idleSprite; } if (pmState == PlayerMovementState.WALKING && isAlive) { pSprite = moveSprite; } if (!isAlive & pSprite.isFinished) { dieSprite = new AnimatedSprite(die, AnimatedSprite.AnimType.FLASH, 1, 2, 0.5f, new Vector2(200, 200), 2.5f); _playerPos = new Vector2(150, 150); _lives--; isAlive = true; _health = 100; pState = PlayerState.ALIVE; pmState = PlayerMovementState.IDLE; } _playerRec.X = (int)_playerPos.X; _playerRec.Y = (int)_playerPos.Y; pSprite.Update(gameTime); _mouse.Update(); }