Advertisement
Guest User

ArchonDowntime.cs

a guest
Aug 28th, 2019
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.37 KB | None | 0 0
  1. using System.Globalization;
  2. using Turbo.Plugins.Default;
  3. using System.Linq;
  4. using SharpDX.DirectInput;
  5.  
  6. using System;
  7. using System.Text;
  8. using System.Collections.Generic;
  9.  
  10. namespace Turbo.Plugins.Zy
  11. {
  12.     using System.Text;
  13.  
  14.  
  15.     public class ArchonDowntime : BasePlugin, IInGameTopPainter
  16.     {
  17.         private readonly int[] _skillOrder = { 2, 3, 4, 5, 0, 1 };
  18.         private StringBuilder textBuilder;
  19.         private IFont GreenFont;
  20.         private IFont RedFont;
  21.         private bool ShowMeteorCountDown;
  22.         private int WizardCount = 0;
  23.         public double ArchonTimeLeft;
  24.         public double Cooldown;
  25.         public bool WizIngame;
  26.         public double ArchonLeft;
  27.         public IBrush BackgroundBrush { get; set; }
  28.         public IBrush TimerArchonBrush { get; set; }
  29.         public IBrush TimerArchonWarningBrush { get; set; }
  30.         public IBrush TimerOutsideBrush { get; set; }
  31.         public IBrush BorderBrush { get; set; }
  32.         public const float BorderSize = 1.2f;
  33.         public ArchonDowntime()
  34.         {
  35.             Enabled = true;
  36.         }
  37.  
  38.         public override void Load(IController hud)
  39.         {
  40.             base.Load(hud);
  41.             GreenFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, false);
  42.             RedFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, false);
  43.             textBuilder = new StringBuilder();
  44.             BackgroundBrush = Hud.Render.CreateBrush(240, 0, 0, 0, 0);
  45.             BackgroundBrush.Opacity = 0.25f;
  46.             TimerArchonBrush = Hud.Render.CreateBrush(240, 79, 38, 113, 0);
  47.             TimerArchonWarningBrush = Hud.Render.CreateBrush(240, 200, 0, 0, 0);
  48.             TimerOutsideBrush = Hud.Render.CreateBrush(240, 100, 100, 100, 0);
  49.             BorderBrush = Hud.Render.CreateBrush(240, 244, 169, 80, 0);
  50.         }
  51.        
  52.  
  53.         public void PaintTopInGame(ClipState clipState)
  54.         {
  55.             if (Hud.Render.UiHidden) return;
  56.             float x = Hud.Window.Size.Width * 0.42f;
  57.             float y = Hud.Window.Size.Height * 0.11f;
  58.             float sizex = Hud.Window.Size.Width * 0.16f;
  59.             float sizey = Hud.Window.Size.Height * 0.02f;
  60.             float textx = Hud.Window.Size.Width * 0.498f;
  61.             float texty = Hud.Window.Size.Height * 0.111f;
  62.             float MeteorOcux = Hud.Window.Size.Width * 0.505f;
  63.             float MeteorOcuy = Hud.Window.Size.Height * 0.131f;
  64.             float Meteorx = Hud.Window.Size.Width * 0.421f;
  65.             float Meteory = Hud.Window.Size.Height * 0.131f;
  66.             textBuilder.Clear();
  67.            
  68.             var ATleft = (ArchonLeft - Hud.Game.CurrentGameTick) / 60.0d;
  69.             WizIngame = false;
  70.             foreach (var player in Hud.Game.Players)
  71.             {
  72.                 if (player.HeroClassDefinition.HeroClass == HeroClass.Wizard && player.IsMe)
  73.                 {
  74.                     WizIngame = true;
  75.                     foreach (var i in _skillOrder)
  76.                     {
  77.                         var skill = player.Powers.SkillSlots[i];
  78.                         if (skill == null || skill.SnoPower.Sno != 134872) continue; //Archon
  79.  
  80.                         Cooldown = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
  81.  
  82.                         var buff = player.Powers.GetBuff(Hud.Sno.SnoPowers.Wizard_Archon.Sno);
  83.                         if (buff != null)
  84.                         {
  85.                             ArchonTimeLeft = buff.TimeLeftSeconds[2];
  86.                             if (player.HasValidActor && buff.TimeLeftSeconds[2] > 0.0)
  87.                             {
  88.                                 ArchonLeft = Hud.Game.CurrentGameTick + ArchonTimeLeft * 60.0d;
  89.                             }
  90.                         }
  91.                         ATleft = (ArchonLeft - Hud.Game.CurrentGameTick) / 60.0d;
  92.                         if (ATleft > 0)
  93.                         {
  94.                             textBuilder.AppendFormat("{0:0}", ATleft);
  95.                         }
  96.                         else
  97.                         {
  98.                             textBuilder.AppendFormat("{0:0}", 12.0 + ATleft);
  99.                         }
  100.                         // DEBUG
  101.                         /*
  102.                         textBuilder.AppendLine();
  103.                         textBuilder.AppendFormat("{0:0.00}", ATleft);
  104.                         textBuilder.AppendLine();
  105.                         textBuilder.AppendFormat("{0:0.00}", ArchonLeft);*/
  106.                     }
  107.                 }
  108.  
  109.                 if (player.HeroClassDefinition.HeroClass == HeroClass.Wizard)
  110.                 {
  111.                     WizardCount++;
  112.                 }
  113.                
  114.                 if (player.IsMe && player.HeroClassDefinition.HeroClass != HeroClass.Wizard)
  115.                 {
  116.                     ShowMeteorCountDown = true;
  117.                 }
  118.  
  119.             }
  120.  
  121.             if (WizIngame)
  122.             {
  123.                 if (ATleft <= 0.0)//outside
  124.                 {
  125.                     if (WizardCount == 1 && ShowMeteorCountDown == true)
  126.                     {
  127.                         if (ATleft >= -12.0)//not bugged
  128.                         {
  129.                             BackgroundBrush.DrawRectangle(x, y, sizex, sizey);
  130.                             TimerOutsideBrush.DrawRectangle(x, y, sizex * (float)((12.0 + ATleft) / 12.0), sizey);
  131.                             BorderBrush.DrawLine(x, y, x + sizex, y, 0.6f);
  132.                             BorderBrush.DrawLine(x + sizex, y, x + sizex, y + sizey, BorderSize);
  133.                             BorderBrush.DrawLine(x, y + sizey, x + sizex, y + sizey, BorderSize);
  134.                             BorderBrush.DrawLine(x, y, x, y + sizey, 0.6f);
  135.  
  136.                             Hud.Texture.GetTexture(Hud.Sno.GetSnoPower(69190).NormalIconTextureId).Draw(MeteorOcux, MeteorOcuy, 28.0f, 28.0f);//Wizard_Meteor { get; } // 69190
  137.                             Hud.Texture.GetTexture(Hud.Sno.GetSnoPower(69190).NormalIconTextureId).Draw(Meteorx, Meteory, 28.0f, 28.0f);//Wizard_Meteor { get; } // 69190
  138.                         }
  139.                         var layout = RedFont.GetTextLayout(textBuilder.ToString());
  140.                         RedFont.DrawText(layout, textx, texty);
  141.                     }
  142.                 }
  143.                 else//in archon
  144.                 {
  145.                     if (ATleft <= 20)//not bugged
  146.                     {
  147.                         BackgroundBrush.DrawRectangle(x, y, sizex, sizey);
  148.                         if (ATleft >= 5.0)
  149.                         {
  150.                             TimerArchonBrush.DrawRectangle(x, y, sizex * (float)(ATleft / 20.0), sizey);
  151.                         }
  152.                         else
  153.                         {
  154.                             TimerArchonWarningBrush.DrawRectangle(x, y, sizex * (float)(ATleft / 20.0), sizey);
  155.                         }
  156.                         BorderBrush.DrawLine(x, y, x + sizex, y, 0.6f);
  157.                         BorderBrush.DrawLine(x + sizex, y, x + sizex, y + sizey, BorderSize);
  158.                         BorderBrush.DrawLine(x, y + sizey, x + sizex, y + sizey, BorderSize);
  159.                         BorderBrush.DrawLine(x, y, x, y + sizey, 0.6f);
  160.                     }
  161.                     var layout = GreenFont.GetTextLayout(textBuilder.ToString());
  162.                     GreenFont.DrawText(layout, textx, texty);
  163.                 }
  164.             }
  165.         }
  166.     }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement