Advertisement
Guest User

HealthBarOnElitePlugin

a guest
Mar 26th, 2017
6,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.34 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System;
  4. using Turbo.Plugins.Default;
  5. namespace Turbo.Plugins.BM
  6. {
  7.     public class HealthBarOnElitePlugin : BasePlugin, IInGameWorldPainter
  8.     {
  9.         public IFont TextFont { get; set; }
  10.         public IBrush BorderBrush { get; set; }
  11.         public IBrush BackgroundBrush { get; set; }
  12.         public IBrush RareBrush { get; set; }
  13.         public IBrush RareJBrush { get; set; }
  14.         public IBrush ChampionBrush { get; set; }
  15.         public IFont TextFontHaunt { get; set; }
  16.         public IFont TextFontLocust { get; set; }
  17.  
  18.         public HealthBarOnElitePlugin()
  19.         {
  20.             Enabled = true;
  21.         }
  22.  
  23.         public override void Load(IController hud)
  24.         {
  25.             base.Load(hud);
  26.             TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true);
  27.             BorderBrush = Hud.Render.CreateBrush(255, 0, 100, 0, -1);
  28.             BackgroundBrush = Hud.Render.CreateBrush(255, 128, 128, 128, 0);
  29.             RareBrush = Hud.Render.CreateBrush(255, 255, 148, 20, 0);
  30.             RareJBrush = Hud.Render.CreateBrush(255, 255, 50, 0, 0);
  31.             ChampionBrush = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
  32.  
  33.             TextFontLocust = Hud.Render.CreateFont("tahoma", 9, 255, 0, 200, 0, false, false, true);
  34.             TextFontHaunt = Hud.Render.CreateFont("tahoma", 9, 255, 255, 0, 0, false, false, true);
  35.             TextFontLocust.SetShadowBrush(255, 0, 200, 0, true);
  36.             TextFontHaunt.SetShadowBrush(255, 255, 0, 0, true);
  37.         }
  38.  
  39.         public void PaintWorld(WorldLayer layer)
  40.         {
  41.             var h = 17;
  42.             var w1 = 30;
  43.             var textLocust = "L";
  44.             var layoutLocust = TextFontLocust.GetTextLayout(textLocust);
  45.             var textHaunt = "H";
  46.             var layoutHaunt = TextFontHaunt.GetTextLayout(textHaunt);
  47.             var py = Hud.Window.Size.Height / 600;
  48.             var monsters = Hud.Game.AliveMonsters.Where(x => x.IsAlive);
  49.             List<IMonster> monstersElite = new List<IMonster>();
  50.             foreach (var monster in monsters)
  51.             {
  52.             if (monster.SummonerAcdDynamicId == 0)
  53.             {
  54.                 if (monster.Rarity == ActorRarity.Champion || monster.Rarity == ActorRarity.Rare)
  55.                 {
  56.                     monstersElite.Add(monster);
  57.                 }
  58.             }
  59.             }
  60.             foreach (var monster in monstersElite)
  61.             {
  62.                     var hptext = ValueToString(monster.CurHealth * 100 / monster.MaxHealth, ValueFormat.NormalNumberNoDecimal);
  63.                     var layout = TextFont.GetTextLayout(hptext);
  64.                     var w = monster.CurHealth * w1 / monster.MaxHealth;
  65.                     var monsterX = monster.FloorCoordinate.ToScreenCoordinate().X - w1 / 2;
  66.                     var monsterY = monster.FloorCoordinate.ToScreenCoordinate().Y + py * 12;
  67.                     var locustX = monsterX - w1 / 2;
  68.                     var hauntX = monsterX + w1 + 5;
  69.                     var buffY = monsterY - 1;
  70.                     var hpX = monsterX + 7;
  71.  
  72.                     BorderBrush.DrawRectangle(monsterX, monsterY, w1, h);
  73.                     BackgroundBrush.DrawRectangle(monsterX, monsterY, w1, h);
  74.                     if (monster.Rarity == ActorRarity.Champion) ChampionBrush.DrawRectangle(monsterX, monsterY, (float)w, h);
  75.                     if (monster.Rarity == ActorRarity.Rare)
  76.                     {
  77.                         bool flagJ = false;
  78.                         foreach (var snoMonsterAffix in monster.AffixSnoList)
  79.                         {
  80.                             if (snoMonsterAffix.Affix == MonsterAffix.Juggernaut)
  81.                             {
  82.                                 flagJ = true;
  83.                                 break;
  84.                             }
  85.                         }
  86.                         if (flagJ) RareJBrush.DrawRectangle(monsterX, monsterY, (float)w, h);
  87.                         else RareBrush.DrawRectangle(monsterX, monsterY, (float)w, h);
  88.                     }
  89.                     if (monster.Locust) TextFontLocust.DrawText(layoutLocust, locustX, buffY);
  90.                     if (monster.Haunted) TextFontHaunt.DrawText(layoutHaunt, hauntX, buffY);
  91.                     TextFont.DrawText(layout, hpX, buffY);
  92.                
  93.             }
  94.             monstersElite.Clear();
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement