Advertisement
RNNCode

HealthPlayer

Nov 21st, 2019 (edited)
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.14 KB | None | 0 0
  1. using System.Linq;
  2. using Turbo.Plugins.Default;
  3.  
  4. namespace Turbo.Plugins.RNN
  5. {
  6.     public class HealthPlayer : BasePlugin, IInGameTopPainter
  7.     {
  8.         public bool ShowMePos { get; set; }
  9.         public IBrush BrushHealthBlue { get; set; }
  10.         public IBrush BrushHealthGreen { get; set; }
  11.         public IBrush BrushBorder { get; set; }
  12.         public IBrush BrushBG { get; set; }
  13.         public IFont TextoFont { get; set; }
  14.         private float WidthHB { get; set; } = 0;
  15.         private float PosYother { get; set; } = 0;
  16.         private float PosYme { get; set; } = 0;
  17.         private bool fixLoad  {get; set; } = true;
  18.  
  19.         public HealthPlayer()
  20.         {
  21.             Enabled = true;
  22.             ShowMePos = true;
  23.         }
  24.  
  25.         public override void Load(IController hud)
  26.         {
  27.             base.Load(hud);
  28.             Order = 30950;
  29.             BrushHealthBlue = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
  30.             BrushHealthGreen = Hud.Render.CreateBrush(255, 0, 255 , 0, 0);
  31.             BrushBorder = Hud.Render.CreateBrush(255, 0, 0 , 0, -1);
  32.             BrushBG = Hud.Render.CreateBrush(255, 255, 0, 0, 0);
  33.             TextoFont = Hud.Render.CreateFont("tahoma", 7f, 250, 250, 250, 250, true, false, 128, 0, 0, 0, true);
  34.  
  35.         }
  36.  
  37.         public void PaintTopInGame(ClipState clipState)
  38.         {
  39.             if (Hud.Render.UiHidden) return;
  40.             if (clipState != ClipState.BeforeClip) return;
  41.             if (!Hud.Game.IsInGame) return;
  42.             if (fixLoad)
  43.             {
  44.                 WidthHB =  (Hud.Window.Size.Width * 0.025f) ;
  45.                 PosYother =   (Hud.Window.Size.Height * 0.032f) ; // (Hud.Window.Size.Height * 0.032f)
  46.                 PosYme =   (Hud.Window.Size.Height * 0.015f) ;  // (Hud.Window.Size.Height * 0.015f)
  47.                 fixLoad = false;
  48.             }
  49.  
  50.             var players = Hud.Game.Players.Where(player => (ShowMePos || !player.IsMe) && player.HasValidActor && player.IsOnScreen);
  51.             int PosY = 0; int health = 0;
  52.             foreach (var player in players)
  53.             {
  54.  
  55.                 PosY = (int) (player.IsMe? PosYme : PosYother) ;
  56.                 health = (int) (WidthHB * player.Defense.HealthCur / player.Defense.HealthMax) ;
  57.                 BrushBG.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2 , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, WidthHB , 4);
  58.                 if (player.Defense.HealthMax > 2000000)
  59.                 {
  60.                     BrushHealthBlue.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2, player.FloorCoordinate.ToScreenCoordinate().Y + PosY, health, 4);
  61.                 }
  62.                 else
  63.                 {
  64.                     BrushHealthGreen.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - WidthHB / 2 , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, health, 4);
  65.                 }
  66.                 BrushBorder.DrawRectangle(player.FloorCoordinate.ToScreenCoordinate().X - (WidthHB / 2) , player.FloorCoordinate.ToScreenCoordinate().Y + PosY, WidthHB + 1 , 5);
  67.  
  68.                 if (Hud.Game.IsInTown)
  69.                 {
  70.                     var layout = TextoFont.GetTextLayout(ValueToString(player.Defense.HealthMax, ValueFormat.LongNumber));
  71.                     TextoFont.DrawText(layout,player.FloorCoordinate.ToScreenCoordinate().X - layout.Metrics.Width / 2.0f, player.FloorCoordinate.ToScreenCoordinate().Y  + PosY + 6);
  72.                 }
  73.             }
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement