Esempio n. 1
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)
 {
     if (ShouldClose)
     {
         Exit();
     }
     KeyHelper.Update();
     RenderHandler.Update();
     MouseHandler.Update();
     if (KeyHelper.CheckTap(Keys.OemTilde))
     {
         DialogueHandler.Start(TestHelper.GetTestDialogues());
     }
     if (KeyHelper.CheckTap(Keys.D3))
     {
         ((PlayerManager)PlayerCharacter.Manager).Inventory.AddToInventory(new Flight());
     }
     if (KeyHelper.CheckTap(Keys.D2))
     {
         ((PlayerManager)PlayerCharacter.Manager).Inventory.AddToInventory(new RegularHealingPotion());
     }
     if (KeyHelper.CheckTap(Keys.D1))
     {
         ((PlayerManager)PlayerCharacter.Manager).Inventory.AddToInventory(new RegularSpeedPotion());
     }
     if (KeyHelper.CheckHeld(Keys.D0))
     {
         PlayerManager.Health--;
     }
     GameTimeMilliseconds = gameTime.ElapsedGameTime.TotalMilliseconds;
     GameTimeSeconds      = gameTime.ElapsedGameTime.TotalSeconds;
     base.Update(gameTime);
 }
Esempio n. 2
0
 public void CheckKeys()
 {
     if (South)
     {
         InAir = false;
     }
     if (RenderHandler.CurrentGameState == GAMESTATE.ACTIVE)
     {
         if (KeyHelper.CheckHeld(Keys.A))
         {
             velocity.X -= velocity.X > -terminalVelocity.X ? moveSpeed : 0;
             if (!InAir)
             {
                 animate.Switch(PlayerManager.movingPlayerSprite, SpriteRectangle);
             }
             if (!Game.PlayerManager.EquippedWeapon.Sprite.Visible)
             {
                 animate.Flipped = true;
             }
         }
         if (KeyHelper.CheckHeld(Keys.D))
         {
             velocity.X += velocity.X < terminalVelocity.X ? moveSpeed : 0;
             if (!InAir)
             {
                 animate.Switch(PlayerManager.movingPlayerSprite, SpriteRectangle);
             }
             if (!Game.PlayerManager.EquippedWeapon.Sprite.Visible)
             {
                 animate.Flipped = false;
             }
         }
         if (KeyHelper.CheckTap(Keys.Space))
         {
             if (!InAir)
             {
                 InAir       = true;
                 velocity.Y -= terminalVelocity.Y;
                 animate.Switch(TextureHelper.Sprites.SmileyWalk, SpriteRectangle, 4, 4);
             }
         }
         //if (newState.IsKeyDown(Keys.S)) { }
         if (KeyHelper.CheckTap(Keys.Q))
         {
             ((PlayerManager)Manager).EquippedWeapon?.OnQAbility();
         }
         if (KeyHelper.CheckTap(Keys.E))
         {
             ((PlayerManager)Manager).Class.EAction();
         }
     }
     if ((velocity.X > -1 && velocity.X < 1) && !InAir)
     {
         animate.Switch(PlayerManager.basePlayerSpriteName, SpriteRectangle, 1, 1);
     }
 }