public static void Draw(SpriteBatch sp) { //Health Bar sp.Draw(BarBackTexture, new Rectangle((int)Location.X, (int)Location.Y, BarLength, 25), Color.White); sp.Draw(TextureHelper.Blank(Color.Red), new Rectangle((int)Location.X, (int)Location.Y, (int)HLength, 25), Color.White); sp.DrawString(font, Game.PlayerManager.Health + "/" + Game.PlayerManager.MaxHealth, Location, Color.White, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); //Mana Bar sp.Draw(BarBackTexture, new Rectangle((int)Location.X, (int)Location.Y + 50, BarLength, 25), Color.White); sp.Draw(TextureHelper.Blank(Color.Blue), new Rectangle((int)Location.X, (int)Location.Y + 50, (int)MLength, 25), Color.White); sp.DrawString(font, Game.PlayerManager.Mana + "/" + Game.PlayerManager.MaxMana, new Vector2(Location.X, Location.Y + 50), Color.White, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); Rectangle BuffPosition = new Rectangle((int)Location.X, (int)Location.Y + 100, 30, 30); //Buffs foreach (Buff b in Game.PlayerCharacter.Buffs.CurrentBuffs) { if (b.Texture != null) { sp.Draw(b.Texture, BuffPosition, Color.White); sp.DrawString(font, GameMathHelper.FramesToStringTime(b.Duration), new Point(BuffPosition.X, BuffPosition.Bottom).ToVector2(), Color.White, 0f, new Vector2(), 0.5f, SpriteEffects.None, 1); if (MouseHandler.mousePosRect.Intersects(BuffPosition)) { string displayString = b.Name + "\n" + b.Description; Vector2 size = font.MeasureString(displayString) * 0.5f; sp.Draw(TextureHelper.Blank(Color.Black), new Rectangle(MouseHandler.mousePos.ToPoint(), size.ToPoint()), Color.White * 0.5f); sp.DrawString(font, displayString, MouseHandler.mousePos, Color.White, 0f, new Vector2(), 0.5f, SpriteEffects.None, 1); } BuffPosition.X += 10 + BuffPosition.Width; } } //Ability Bar sp.Draw(TextureHelper.Blank(Color.DarkOliveGreen), AbilityBarLocation, Color.White); sp.Draw(TextureHelper.Blank(Color.Turquoise), new Rectangle(AbilityBarLocation.Left, AbilityBarLocation.Y, AbilityBarLocation.Width / 4, AbilityBarLocation.Height), Color.White); // Q Ability sp.Draw(TextureHelper.Blank(Color.Pink), new Rectangle(AbilityBarLocation.Right - (AbilityBarLocation.Width / 4), AbilityBarLocation.Y, AbilityBarLocation.Width / 4, AbilityBarLocation.Height), Color.White); // E Ability if (Manager.Class.CooldownPercentage() < 1.0) { sp.Draw(TextureHelper.Blank(Color.Black), new Rectangle( AbilityBarLocation.Right - (AbilityBarLocation.Width / 4), // X AbilityBarLocation.Bottom - (int)(AbilityBarLocation.Height * Manager.Class.CooldownPercentage()), // Y AbilityBarLocation.Width / 4, // Width (int)(AbilityBarLocation.Height * Manager.Class.CooldownPercentage())), // Height Color.White * 0.5f); // E Ability Cover } }
public void DrawItemInfo(SpriteBatch sp) { if (HoverItem != null) { if (HoverItem is ItemStack) { List <Item> stack = ((ItemStack)HoverItem).items; ItemInformation = new string[] { HoverItem.ID + " - " + HoverItem.Name + " (x" + stack.Count + ")", stack[0] is Weapon ? "Damage: " + ((Weapon)stack[0]).Damage.ToString() : "", stack[0] is Potion ? "Effect: " + ((Potion)stack[0]).EffectDescription : "", stack[0] is Potion ? "Duration: " + GameMathHelper.FramesToStringTime(((Potion)stack[0]).Duration) : "", "Description: " + HoverItem.Description }; } else { ItemInformation = new string[] { HoverItem.ID + " - " + HoverItem.Name, HoverItem is Weapon ? "Damage: " + ((Weapon)HoverItem).Damage.ToString() : "", HoverItem is Potion ? "Effect: " + ((Potion)HoverItem).EffectDescription : "", HoverItem is Potion ? "Duration: " + GameMathHelper.FramesToStringTime(((Potion)HoverItem).Duration) : "", "Description: " + HoverItem.Description }; } Point position = MouseHandler.mousePos.ToPoint(); SpriteFont font = Game.GameContent.Load <SpriteFont>(TextureHelper.Fonts.Default); float width = 0; foreach (string str in ItemInformation) { width = width < font.MeasureString(str).X ? (int)font.MeasureString(str).X : width; } width *= 0.7f; float yPos = position.Y + font.MeasureString(ItemInformation[0]).Y; for (int i = 0; i < ItemInformation.Length; i++) { if (ItemInformation[i].Length == 0) { continue; } sp.Draw(TextureHelper.Blank(Color.Black), new Vector2(position.X, yPos), new Rectangle(position.X, (int)yPos, (int)width, (int)font.MeasureString(ItemInformation[i]).Y), Color.White * TransparencyLevel); sp.DrawString(font, ItemInformation[i], new Vector2(position.X, yPos), Color.LightGray, 0f, new Vector2(), 0.7f, SpriteEffects.None, 1f); yPos += font.MeasureString(ItemInformation[i]).Y; } } }