Guest User

GLQ_EliteHealthListPlugin.cs

a guest
May 6th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.glq
  7. {
  8. public class GLQ_EliteHealthListPlugin : BasePlugin, IInGameWorldPainter
  9. {
  10. //作者:我想静静 修改:小米
  11. public IFont TextFont { get; set; }
  12. public IBrush BorderBrush { get; set; }
  13. public IBrush BackgroundBrush { get; set; }
  14. public IBrush RareBrush { get; set; }
  15. public IBrush ChampionBrush { get; set; }
  16.  
  17. public GLQ_EliteHealthListPlugin()
  18. {
  19. Enabled = true;
  20. }
  21.  
  22. public override void Load(IController hud)
  23. {
  24. base.Load(hud);
  25. TextFont = Hud.Render.CreateFont("tahoma", 6, 180, 255, 255, 255, false, false, true);
  26. BorderBrush = Hud.Render.CreateBrush(255, 150, 180, 150, 2);
  27. BackgroundBrush = Hud.Render.CreateBrush(120, 0, 0, 0, 0);
  28. RareBrush = Hud.Render.CreateBrush(120, 255, 128, 0, 0);
  29. ChampionBrush = Hud.Render.CreateBrush(120, 0, 128, 255, 0);
  30. }
  31.  
  32. public void PaintWorld(WorldLayer layer)
  33. {
  34. var monsters = Hud.Game.AliveMonsters;
  35. Dictionary<IMonster, string> eliteGroup = new Dictionary<IMonster, string>();
  36.  
  37. foreach (var monster in monsters)
  38. {
  39. if (monster.Rarity == ActorRarity.Champion || monster.Rarity == ActorRarity.Rare)
  40. {
  41. eliteGroup.Add(monster, String.Join(", ", monster.AffixSnoList));
  42. }
  43. }
  44. Dictionary<IMonster, string> eliteGroup1 = eliteGroup.OrderBy(p => p.Value).ToDictionary(p => p.Key, o => o.Value);
  45.  
  46. var px = Hud.Window.Size.Width * 0.00125f;
  47. var py = Hud.Window.Size.Height * 0.001667f;
  48. var h = py * 5;
  49. var w2 = py * 50;
  50. var count = 0;
  51. string preStr = null;
  52. //remove clone
  53. foreach (var elite in eliteGroup1)
  54. {
  55. bool illusionist = false;
  56. if(elite.Key.SummonerAcdDynamicId == 0)
  57. {
  58. illusionist = false;
  59. }
  60. else
  61. {
  62. illusionist = true;
  63. }
  64. if (elite.Key.Rarity == ActorRarity.Champion)
  65. {
  66. if (illusionist == false)
  67. {
  68. var x = Hud.Window.Size.Width * 0.125f;
  69. var w = elite.Key.CurHealth * w2 / elite.Key.MaxHealth;
  70. var affixlist = "";
  71. foreach (var Affix in elite.Key.AffixSnoList)
  72. {
  73. affixlist = affixlist + " " + Affix.NameLocalized;
  74. }
  75. var text = (elite.Key.CurHealth * 100 / elite.Key.MaxHealth).ToString("f1")+ "%" + affixlist;
  76. var layout = TextFont.GetTextLayout(text);
  77. if (preStr != elite.Value || preStr == null) count++;
  78. var y = py * 8 * count;
  79. if(elite.Key.Invulnerable)BorderBrush.DrawRectangle(x, y, w2, h);
  80. BackgroundBrush.DrawRectangle(x, y, w2, h);
  81. TextFont.DrawText(layout, x + px + w2, y - py);
  82. ChampionBrush.DrawRectangle(x, y, (float)w, h);
  83. preStr = elite.Value;
  84. count++;
  85. }
  86. }
  87. if (elite.Key.Rarity == ActorRarity.Rare)
  88. {
  89. if (illusionist == false)
  90. {
  91. var x = Hud.Window.Size.Width * 0.125f;
  92. var w = elite.Key.CurHealth * w2 / elite.Key.MaxHealth;
  93. var affixlist="";
  94. foreach (var Affix in elite.Key.AffixSnoList)
  95. {
  96. affixlist = affixlist + " " + Affix.NameLocalized;
  97. }
  98. var text = (elite.Key.CurHealth * 100 / elite.Key.MaxHealth).ToString("f1")+ "%" + affixlist;
  99. var layout = TextFont.GetTextLayout(text);
  100. if (preStr != elite.Value || preStr == null) count++;
  101. var y = py * 8 * count;
  102. if(elite.Key.Invulnerable)BorderBrush.DrawRectangle(x, y, w2, h);
  103. BackgroundBrush.DrawRectangle(x, y, w2, h);
  104. TextFont.DrawText(layout, x + px + w2, y - py);
  105. RareBrush.DrawRectangle(x, y, (float)w, h);
  106. preStr = elite.Value;
  107. count++;
  108. }
  109. }
  110. }
  111. eliteGroup.Clear();
  112. }
  113. }
  114. }
Add Comment
Please, Sign In to add comment