public override void Update(GameTime gt) { MouseState mouseState = Mouse.GetState(); Pistol pistol = Game1.objectHandler.SearchFirst <Pistol>(); if (pistol != null) { if (pistol.reloadTimer.Triggered) { bounds.Height = 0; } else { bounds.Height = (int)MathHelper.Lerp(50f, 0, pistol.reloadTimer.PercentageDone); yOff = (int)MathHelper.Lerp(50f, 0, pistol.reloadTimer.PercentageDone); } } else { bounds.Height = 0; } bounds.X = mouseState.X + 5; bounds.Y = mouseState.Y - yOff; }
/// <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) { var mouseState = Mouse.GetState(); GraphicsDevice.Clear(new Color(0, 0, 30)); // TODO: Add your drawing code here spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerState.PointClamp, transformMatrix: camera.WorldMatrix); string coinCounterVal = "Coins: " + coinCount.ToString(); string shortInstructions = "WASD or Arrows to move\nHold Click or Space to shoot\nTab to toggle Minimap\nBackspace to Quit"; string instructions = "WASD or Arrows to move\nHold Click or Space to shoot\nR to Reload\nE to purchase item\nTab to toggle Minimap\nBackspace to Quit"; string nodeTrackerVal = RoomShower.playerRoomX.ToString() + ", " + RoomShower.playerRoomY.ToString(); objectHandler.Draw(spriteBatch); heartManager.Draw(spriteBatch); if (showMiniMap) { foreach (MinimapRoom miniroom in minirooms) { miniroom.Draw(spriteBatch); } } if (objectHandler.SearchFirst <Pistol>() != null) { Pistol pistol = objectHandler.SearchFirst <Pistol>(); spriteBatch.DrawString(debugTextFont, pistol.ammo + "/" + pistol.maxAmmo, new Point(0, screenY - 100).ToVector2(), Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); } spriteBatch.DrawString(debugTextFont, coinCounterVal + "\n" + instructions + "\n" + "FPS: " + Math.Round(1f / gameTime.ElapsedGameTime.TotalSeconds), new Vector2(0, 150), Color.White); if (objectHandler.SearchFirst <Weapon>() != null) { weaponrotation = objectHandler.SearchFirst <Weapon>().direction.ToString(); } if (debugStats) { spriteBatch.DrawString(debugTextFont, "x: " + mouseState.X + " y: " + mouseState.Y + "\n x:" + objectHandler.SearchFirst <Character>().bounds.X + "y:" + objectHandler.SearchFirst <Character>().bounds.Y + "\n" + nodeTrackerVal + "\n" + Character.totalXP + "\n" + "X: " + mouseState.X / 64 + "Y: " + mouseState.Y / 64 + "\n" + weaponrotation, new Vector2(mouseState.X + 20, mouseState.Y - 10), color: Color.White); } if (win) { spriteBatch.DrawString(debugTextFont, "You Win!", new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), Color.Magenta, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0f); } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerState.PointClamp); if (gameOver && playPressed) { spriteBatch.Draw(whitePixelTexture, new Rectangle(0, 0, 5000, 5000), Color.Black); spriteBatch.DrawString(debugTextFont, "Game Over", new Vector2(500, 350), Color.Red, 0f, new Vector2(0, 0), 2f, SpriteEffects.None, 0f); } if (!playPressed) { spriteBatch.Draw(mainmenuTexture, new Rectangle(0, 0, screenX, screenY), Color.White); spriteBatch.DrawString(debugTextFont, "Press 1 to choose the Wand\nPress 2 to choose the Pistol\n(recommended)", new Vector2(300, 350), Color.LimeGreen, 0f, new Vector2(0, 0), 2f, SpriteEffects.None, 0f); spriteBatch.DrawString(debugTextFont, shortInstructions, new Vector2(300, 200), Color.Yellow, 0f, new Vector2(0, 0), 2f, SpriteEffects.None, 0f); spriteBatch.Draw(pistolTexture, new Rectangle(700, 395, 26, 17), Color.White); spriteBatch.Draw(wandTexture, new Rectangle(700, 355, 6, 32), Color.White); } spriteBatch.End(); base.Draw(gameTime); }