Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using SharpDX;
- namespace Turbo.Plugins.RNN
- {
- public class TrialsOfTempestsIcon : BasePlugin, IInGameTopPainter
- {
- private uint[] Textures { get; set; } = new uint[7] { 3405442230, 2639019912, 4122635698, 1541236666, 3513867492, 928374825, 569405584 }; // 0,1,2-火,3-冰,4-毒,5-物理,6-射线
- private IBrush[] Brushes { get; set; }
- private ITexture TextureBG { get; set; }
- private long[] timers { get; set; } = new long[] { 0, 0, 0, 0 };
- private double[] t { get; set; } = new double[] { 0, 0, 0, 0 };
- private bool[] reset { get; set; } = new bool[] { false, false, false, false };
- private float SizeIconWidth { get; set; }
- private float SizeIconHeight { get; set; }
- private SharpDX.DirectWrite.TextLayout layout { get; set; } = null;
- private IFont FontStacks0 { get; set; }
- private IFont FontStacks1 { get; set; }
- private IFont FontStacksY { get; set; }
- private IFont FontStacksG { get; set; }
- private IFont FontCounter { get; set; }
- private IFont FontTimeLeft { get; set; }
- private IBrush BrushBorder { get; set; }
- public IBrush AlmostGoneBorderBrush { get; set; }
- public IFont AlmostGoneTimeLeftFont { get; set; }
- private RectangleF Buff;
- public float Opacity { get; set; }
- public float SizeMultiplier { get; set; }
- public TrialsOfTempestsIcon()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30001;
- Opacity = 1f;
- SizeMultiplier = 1f;
- TextureBG = Hud.Texture.GetTexture(3144819863);
- var tr = 1.0f;
- BrushBorder = Hud.Render.CreateBrush(255, 255, 255, 255, tr);
- AlmostGoneBorderBrush = Hud.Render.CreateBrush(220, 255, 0, 0, 3);
- Brushes = new IBrush[7] // 0,1,2-火,3-冰,4-毒,5-物理,6-射线
- {
- BrushBorder,
- BrushBorder,
- Hud.Render.CreateBrush( 255, 255, 0, 0, tr),
- BrushBorder,
- Hud.Render.CreateBrush( 255, 0, 255, 0, tr),
- Hud.Render.CreateBrush( 255, 80, 80, 80, tr),
- Hud.Render.CreateBrush( 255, 0, 128, 255, tr),
- };
- FontStacks1 = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 255, 255, 255, false, false, 255, 0, 0, 0, true);
- FontStacksY = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 255, 255, 0, false, false, 255, 0, 0, 0, true);
- FontStacksG = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 195, 195, 195, false, false, 255, 0, 0, 0, true);
- FontCounter = Hud.Render.CreateFont("tahoma", 9f * SizeMultiplier, 255, 255, 255, 255, false, false, 255, 0, 0, 0, true);
- FontTimeLeft = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 0, 255, 0, false, false, 255, 0, 0, 0, true);
- AlmostGoneTimeLeftFont = Hud.Render.CreateFont("tahoma", 9, 255, 255, 0, 0, false, false, 255, 0, 0, 0, true);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- if (!Hud.Game.Me.InGreaterRift) return;
- if (Hud.Game.Me.Powers.BuffIsActive(484426)) //风暴试练
- {
- SizeIconWidth = TextureBG.Width * Hud.Game.Me.PortraitUiElement.Rectangle.Width / 100 * SizeMultiplier;
- SizeIconHeight = TextureBG.Height * Hud.Game.Me.PortraitUiElement.Rectangle.Width / 100 * SizeMultiplier;
- var players = Hud.Game.Players;
- foreach (var player in players)
- {
- var buff = player.Powers.GetBuff(484426);
- if (buff != null)
- {
- var portraitRect = player.PortraitUiElement.Rectangle;
- float x, y;
- x = portraitRect.Right;
- y = portraitRect.Top + portraitRect.Height * 0.3f;
- Buff.Left = x;
- Buff.Top = y;
- Buff.Right = x + SizeIconWidth;
- Buff.Bottom = y + SizeIconHeight;
- TextureBG.Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
- (player.HasValidActor ? Hud.Texture.BuffFrameTexture : Hud.Texture.DebuffFrameTexture).Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
- if (player.HasValidActor) t[player.Index] = buff.TimeLeftSeconds[1]; //赛季BUFF下个爆发的倒计时 layout = FontCounter.GetTextLayout(t.ToString( (t < 1)? "F1" : "F0") );
- if (!player.HasValidActor)//距离过远的玩家获取模拟时间
- {
- if (reset[player.Index] == false)
- {
- t[player.Index] = buff.TimeLeftSeconds[1];
- }
- else
- {
- t[player.Index] = 90;
- }
- if (timers[player.Index] == 0)
- {
- timers[player.Index] = Hud.Game.CurrentRealTimeMilliseconds;//记录最后一个有效BUFF的时间
- }
- else
- {
- t[player.Index] -= (Hud.Game.CurrentRealTimeMilliseconds - timers[player.Index]) / 1000;//根据最后一次有效BUFF时间模拟计算远距离BUFF剩余时间
- }
- if (t[player.Index] < 0)
- {
- //模拟计算BUFF剩余时间小于0时重置为90秒
- t[player.Index] = 90;
- reset[player.Index] = true;
- timers[player.Index] = 0;//重置记录有效距离BUFF时间
- }
- }
- else
- {
- reset[player.Index] = false;
- timers[player.Index] = 0;//重置记录有效距离BUFF时间
- }
- if (t[player.Index] < 1.0f)//倒计时时间格式化
- {
- layout = FontCounter.GetTextLayout(String.Format("{0:N1}", t[player.Index]));
- }
- else
- {
- layout = FontCounter.GetTextLayout((t[player.Index] < 60) ? String.Format("{0:0}", t[player.Index]) : String.Format("{0:0}:{1:00}", (int)(t[player.Index] / 60), t[player.Index] % 60));
- }
- FontCounter.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height)) / 2.0f));
- if (t[player.Index] < 10)//小于10秒时红框红字显示
- {
- AlmostGoneBorderBrush?.DrawRectangle(Buff);
- AlmostGoneTimeLeftFont.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height)) / 2.0f));
- }
- layout = FontStacks1.GetTextLayout(buff.IconCounts[8].ToString());
- FontStacks1.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) / 1.17f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height)) / 1.1f));
- FontStacks0 = FontStacksG;
- for (int i = 2; i < 7; i++)
- {//爆发时的BUFF倒计时
- double t2 = 0;
- t2 = buff.TimeLeftSeconds[i];
- if (t2 > 0)
- {
- layout = FontTimeLeft.GetTextLayout(t2.ToString((t2 < 1) ? "F1" : "F0"));
- FontTimeLeft.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) / 7.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height)) / 1.1f));
- Hud.Texture.GetTexture(Textures[i]).Draw(x + 0.08f * SizeIconWidth, y + 0.08f * SizeIconHeight, SizeIconHeight * 0.28f, SizeIconHeight * 0.28f, 1.0f);
- Brushes[i].DrawRectangle(x + 0.08f * SizeIconWidth, y + 0.08f * SizeIconHeight, SizeIconHeight * 0.28f, SizeIconHeight * 0.28f);
- FontStacks0 = FontStacksY;
- break;
- }
- }
- layout = FontStacks0.GetTextLayout(buff.IconCounts[9].ToString());
- FontStacks0.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) / 1.17f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height)) / 12.0f));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement