public override void draw(SpriteBatch spriteBatch, Point offset, TimeSpan elapsed) { if (SlatedToRemove) { return; } Rectangle pRect = EBounds.Rect; pRect.Offset(offset); Texture2D sprite = getSprite(elapsed.Milliseconds); if (isFacingForward()) { spriteBatch.Draw(sprite, pRect, Color.White); } else { spriteBatch.Draw(sprite, pRect, sprite.Bounds, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0); } // Was hit resently, show hp bar if (Alive && showHpTicks != 0) { Rectangle hpRect = EBounds.Rect; hpRect.Offset(offset); hpRect.X += (int)(hpRect.Width * 0.125); // Offset and a bit over from the absolute left side hpRect.Y -= 7; hpRect.Height = 3; hpRect.Width = (int)Math.Round(hpRect.Width * 0.75 * Stats.HpPercent) + 1; spriteBatch.Draw(ScreenManager.WhiteRect, hpRect, Color.Red); Vector2 vect = ScreenManager.Small_Font.MeasureString(Name); spriteBatch.DrawString(ScreenManager.Small_Font, Name, new Vector2(pRect.Center.X - vect.X / 2, hpRect.Y - 19), Color.White); Rectangle lastRect = EBounds.getRectFromPart(lastHitPart); if (showHpTicks > HP_BAR_SHOW_MS / 2 && lastRect.Width != 0) { lastRect.Offset(offset); lastRect.X += (int)(lastRect.Height * 0.1); lastRect.Width = (int)(pRect.Width * 0.8); spriteBatch.Draw(ScreenManager.WhiteRect, lastRect, HIT_BOX_COLOR); } } }
public override void draw(SpriteBatch spriteBatch, Point offset, TimeSpan elapsed) { // Draw hp bar if (Stats.Hp > 0) { Rectangle hpRect = new Rectangle(2, 2, 100, 16); hpRect.Width = (int)Math.Round(hpRect.Width * Stats.HpPercent) + 1; spriteBatch.Draw(ScreenManager.WhiteRect, hpRect, Color.Green); } else { spriteBatch.DrawString(ScreenManager.Small_Font, "Dead", new Vector2(12, 0), Color.White); } // Draw level spriteBatch.DrawString(ScreenManager.Small_Font, "Lvl " + Stats.Level + " " + Name, new Vector2(105, 0), Color.White); // Draw entity Rectangle pRect = EBounds.Rect; pRect.Offset(offset); Texture2D sprite = getSprite(elapsed.Milliseconds); if (isFacingForward()) { spriteBatch.Draw(sprite, pRect, Color.White); } else { spriteBatch.Draw(sprite, pRect, sprite.Bounds, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0); } // Draw armour stats if (Alive) { // Draw armour Equipment.draw(spriteBatch, offset); // Draw xp bar Rectangle xpBar = new Rectangle(0, spriteBatch.GraphicsDevice.Viewport.Height - 3, (int)(xp / (float)nextLevelXP * spriteBatch.GraphicsDevice.Viewport.Width), 2); spriteBatch.Draw(ScreenManager.WhiteRect, xpBar, Color.LightBlue); Viewport vp = spriteBatch.GraphicsDevice.Viewport; Rectangle armourImg = new Rectangle(vp.Width - 45, 2, 32, 32); Texture2D img; switch (State) { case EntityState.Blocking: img = GameScreen.sprGUI[GUISpriteId.Blocking]; break; case EntityState.Crouching: img = GameScreen.sprGUI[GUISpriteId.Ducking]; break; default: img = GameScreen.sprGUI[GUISpriteId.Standing]; break; } if (isFacingForward()) { spriteBatch.Draw(img, armourImg, Color.Black); } else { spriteBatch.Draw(img, armourImg, img.Bounds, Color.Black, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0); } spriteBatch.DrawString(ScreenManager.Small_Font, Stats.THeadMultiplier.ToString("0.0"), new Vector2(vp.Width - 38, 0), Color.White); spriteBatch.DrawString(ScreenManager.Small_Font, Stats.TBodyMultiplier.ToString("0.0"), new Vector2(vp.Width - 38, 11), Color.White); spriteBatch.DrawString(ScreenManager.Small_Font, Stats.TLegsMultiplier.ToString("0.0"), new Vector2(vp.Width - 38, 22), Color.White); // Draw hit box if (showHpTicks > HP_BAR_SHOW_MS / 2) { Rectangle lastRect = EBounds.getRectFromPart(lastHitPart); if (lastRect.Width != 0) { lastRect.Offset(offset); lastRect.X += (int)(lastRect.Height * 0.1); lastRect.Width = (int)(lastRect.Width * 0.8); spriteBatch.Draw(ScreenManager.WhiteRect, lastRect, HIT_BOX_COLOR); } } } }