Advertisement
zjqyf

AncientParthanCount.cs

May 6th, 2017
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4. using System.Drawing;
  5. namespace Turbo.Plugins.glq
  6. {
  7. public class AncientParthanCount : BasePlugin, IInGameTopPainter
  8. {
  9. public IFont TextFont { get; set; }
  10. public float XWidth { get; set; }
  11. public float YHeight { get; set; }
  12. public int percent { get; set; }
  13. public TopLabelDecorator AncientParthanDecorator { get; set; }
  14. private IBrush StackBrush;
  15.  
  16. public AncientParthanCount()
  17. {
  18. Enabled = true;
  19. }
  20.  
  21. public override void Load(IController hud)
  22. {
  23. base.Load(hud);
  24. TextFont = Hud.Render.CreateFont("tahoma", 9, 255, 170, 90, 90, false, false, true);
  25. XWidth = 0.3f;
  26. YHeight = 0.3f;
  27. percent = 0;
  28. AncientParthanDecorator = new TopLabelDecorator(Hud)
  29. {
  30. TextFont = Hud.Render.CreateFont("tahoma", 5, 255, 255, 255, 255, false, false, 250, 0, 0, 0, true),
  31. };
  32. StackBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0);
  33. }
  34.  
  35. public void PaintTopInGame(ClipState clipState)
  36. {
  37. if (clipState != ClipState.BeforeClip) return;
  38. if (!Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.AncientParthanDefenders.Sno))
  39. {
  40. percent = 0;
  41. return;
  42. }
  43. var count = Hud.Game.AliveMonsters.Count(m => (m.Stunned || m.Frozen) && m.NormalizedXyDistanceToMe <= 25);
  44. if (count == 0) return;
  45. SetDamageReductionpercent();
  46. var dr = 100 * (1 - Math.Pow(1 - percent * 0.01d, count));
  47. var ui = Hud.Render.GetUiElement("Root.NormalLayer.minimap_dialog_backgroundScreen.minimap_dialog_pve.minimap_pve_main");
  48. var XPos = ui.Rectangle.Left - ui.Rectangle.Width * XWidth;
  49. var YPos = ui.Rectangle.Bottom + ui.Rectangle.Width * YHeight;
  50. var w = ui.Rectangle.Height * 0.1f;
  51. var h = ui.Rectangle.Height * 0.2f;
  52. var tex = Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.Unique_Bracer_102_x1);
  53. var bgTex = Hud.Texture.GetTexture(3166997520);
  54. var rect = new RectangleF(XPos, YPos, w, h);
  55. if (Hud.Window.CursorInsideRect(rect.X, rect.Y, rect.Width, rect.Height))
  56. {
  57. Hud.Render.SetHint("Legend effect\r\nAPCount\r\nAPDR");
  58. }
  59. StackBrush.DrawRectangle(rect);
  60.  
  61. bgTex.Draw(rect.Left, rect.Top, rect.Width, rect.Height);
  62. tex.Draw(rect.Left, rect.Top, rect.Width, rect.Height);
  63. AncientParthanDecorator.TextFunc = () => " " + percent.ToString()+"%" + "\r\n" + "\r\n" + "\r\n" + " " + count.ToString() + "\r\n" + dr.ToString("f2")+"%";
  64. //AncientParthanDecorator.HintFunc = () => "古帕特效\r\n古帕触发数\r\n古帕总减伤";
  65. AncientParthanDecorator.Paint(XPos, YPos, w, h, HorizontalAlign.Center);
  66.  
  67. }
  68. private void SetDamageReductionpercent()
  69. {
  70. if (Hud.Game.Me.CubeSnoItem2 != null && Hud.Game.Me.CubeSnoItem2.LegendaryPower.Sno == Hud.Sno.SnoPowers.AncientParthanDefenders.Sno)
  71. {
  72. percent = 12;
  73. }
  74. else
  75. {
  76. var parthans = Hud.Game.Items.First(item => item.Location == ItemLocation.Bracers).Perfections.FirstOrDefault(p => p.Attribute.Code == "Item_Power_Passive");
  77. percent = parthans == null ? 10 : (int)Math.Round(parthans.Cur * 100);
  78. }
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement