Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.RNN
- {
- public class HealthPlayer : BasePlugin, IInGameTopPainter
- {
- public bool ShowMePos { get; set; }
- public IBrush BrushHealthBlue { get; set; }
- public IBrush BrushHealthGreen { get; set; }
- public IBrush BrushBorder { get; set; }
- public IBrush BrushBG { get; set; }
- public IFont TextoFont { get; set; }
- private float WidthHB { get; set; } = 0;
- private float PosYother { get; set; } = 0;
- private float PosYme { get; set; } = 0;
- private bool fixLoad {get; set; } = true;
- public HealthPlayer()
- {
- Enabled = true;
- ShowMePos = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30950;
- BrushHealthBlue = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
- BrushHealthGreen = Hud.Render.CreateBrush(255, 0, 255 , 0, 0);
- BrushBorder = Hud.Render.CreateBrush(255, 0, 0 , 0, -1);
- BrushBG = Hud.Render.CreateBrush(255, 255, 0, 0, 0);
- TextoFont = Hud.Render.CreateFont("tahoma", 7f, 250, 250, 250, 250, true, false, 128, 0, 0, 0, true);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (Hud.Render.UiHidden) return;
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- if (fixLoad)
- {
- WidthHB = (Hud.Window.Size.Width * 0.025f) ;
- PosYother = (Hud.Window.Size.Height * 0.032f) ; // (Hud.Window.Size.Height * 0.032f)
- PosYme = (Hud.Window.Size.Height * 0.015f) ; // (Hud.Window.Size.Height * 0.015f)
- fixLoad = false;
- }
- var players = Hud.Game.Players.Where(player => (ShowMePos || !player.IsMe) && player.HasValidActor && player.IsOnScreen);
- int PosY = 0; int health = 0;
- foreach (var player in players)
- {
- PosY = (int) (player.IsMe? PosYme : PosYother) ;
- health = (int) (WidthHB * player.Defense.HealthCur / player.Defense.HealthMax) ;
- BrushBG.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2 , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, WidthHB , 4);
- if (player.Defense.HealthMax > 2000000)
- {
- BrushHealthBlue.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2, player.FloorCoordinate.ToScreenCoordinate().Y + PosY, health, 4);
- }
- else
- {
- BrushHealthGreen.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2 , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, health, 4);
- }
- BrushBorder.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - (WidthHB / 2) , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, WidthHB + 1 , 5);
- if (Hud.Game.IsInTown)
- {
- var layout = TextoFont.GetTextLayout(ValueToString(player.Defense.HealthMax, ValueFormat.LongNumber));
- TextoFont.DrawText(layout,player.FloorCoordinate.ToScreenCoordinate().X - layout.Metrics.Width / 2.0f, player.FloorCoordinate.ToScreenCoordinate().Y + PosY + 6);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement