AndyYin

HeroClassCirclePlugin

Aug 11th, 2019
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.87 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.yin
  7. {
  8.     public class HeroClassCirclePlugin : BasePlugin, IInGameWorldPainter
  9.     {
  10.         public WorldDecoratorCollection MeDecorator { get; set; } // public propertiy to be editable
  11.        
  12.         //                                      sno skill/buff? radius
  13.         public Dictionary<HeroClass, List<Tuple<uint, bool, float>>> HeroClassCircleRadius { get; set; }
  14.  
  15.         public Dictionary<HeroClass, IBrush> HeroClassCircleBrush { get; set; }
  16.  
  17.         public bool ShowInTown { get; set; }
  18.         public bool ShowInNormalRift { get; set; }
  19.  
  20.         private float CircleRadius;
  21.        
  22.         public HeroClassCirclePlugin()
  23.         {
  24.             Enabled = true;
  25.             CircleRadius = 5; // default value
  26.             ShowInTown = true;
  27.             ShowInNormalRift = false;
  28.         }
  29.  
  30.         public override void Load(IController hud)
  31.         {
  32.             base.Load(hud);
  33.  
  34.             MeDecorator = new WorldDecoratorCollection(
  35.                 new GroundCircleDecorator(Hud)
  36.                 {
  37.                     Brush = Hud.Render.CreateBrush(255, 255, 0, 0, 3),
  38.                     Radius = CircleRadius, //default value
  39.                 }
  40.             );
  41.  
  42.             HeroClassCircleBrush = new Dictionary<HeroClass, IBrush>(){
  43.                 {HeroClass.Barbarian, Hud.Render.CreateBrush(200, 250, 10, 10, 3)},
  44.                 {HeroClass.Crusader, Hud.Render.CreateBrush(240, 0, 200, 250, 3)},
  45.                 {HeroClass.DemonHunter, Hud.Render.CreateBrush(255, 0, 0, 200, 3)},
  46.                 {HeroClass.Monk, Hud.Render.CreateBrush(245, 120, 0, 200, 3)},
  47.                 {HeroClass.Necromancer, Hud.Render.CreateBrush(255, 175, 238, 238, 3)},
  48.                 {HeroClass.WitchDoctor, Hud.Render.CreateBrush(155, 0, 155, 125, 3)},
  49.                 {HeroClass.Wizard, Hud.Render.CreateBrush(255, 250, 50, 180, 3)},
  50.             };
  51.            
  52.            
  53.             HeroClassCircleRadius = new Dictionary<HeroClass, List<Tuple<uint, bool, float>>>();
  54.             HeroClassCircleRadius.Add(HeroClass.Barbarian, new List<Tuple<uint, bool, float>>(){
  55.                 Tuple.Create(hud.Sno.SnoPowers.Barbarian_GroundStomp.Sno, true, 24f),//践踏, Barbarian_GroundStomp, 79446
  56.                 //Tuple.Create(hud.Sno.SnoPowers.Barbarian_Leap.Sno, true, 10f),//跳斩, Barbarian_Leap, 93409
  57.             });
  58.             HeroClassCircleRadius.Add(HeroClass.Wizard, new List<Tuple<uint, bool, float>>(){
  59.                 Tuple.Create(hud.Sno.SnoPowers.Wizard_Passive_PowerHungry.Sno, false, 30f),//奥能渴求, Wizard_Passive_PowerHungry, 208478
  60.                 Tuple.Create(hud.Sno.SnoPowers.Wizard_Passive_Audacity.Sno, false, 15f),//无畏无惧, Wizard_Passive_Audacity, 341540
  61.             });
  62.             HeroClassCircleRadius.Add(HeroClass.Monk, new List<Tuple<uint, bool, float>>(){
  63.                 Tuple.Create(hud.Sno.SnoPowers.Monk_InnerSanctuary.Sno, true, 11f),//金轮阵, Monk_InnerSanctuary, 317076
  64.             });
  65.             HeroClassCircleRadius.Add(HeroClass.DemonHunter, new List<Tuple<uint, bool, float>>(){
  66.                 Tuple.Create(hud.Sno.SnoPowers.DemonHunter_Passive_SingleOut.Sno, false, 20f),//逐一击破, DemonHunter_Passive_SingleOut, 338859
  67.                 Tuple.Create(hud.Sno.SnoPowers.DemonHunter_Passive_SteadyAim.Sno, false, 10f),//稳固瞄准, DemonHunter_Passive_SteadyAim, 164363
  68.             });
  69.             HeroClassCircleRadius.Add(HeroClass.WitchDoctor, new List<Tuple<uint, bool, float>>(){
  70.                 Tuple.Create(hud.Sno.SnoPowers.WitchDoctor_Horrify.Sno, true, 18f),//惧灵, WitchDoctor_Horrify, 67668
  71.                 Tuple.Create(hud.Sno.SnoPowers.WitchDoctor_SoulHarvest.Sno, true, 18f),//灵魂收割, WitchDoctor_SoulHarvest, 67616
  72.             });
  73.             HeroClassCircleRadius.Add(HeroClass.Crusader, new List<Tuple<uint, bool, float>>(){
  74.                 Tuple.Create(hud.Sno.SnoPowers.Crusader_Condemn.Sno, true, 15f),//天谴, Crusader_Condemn, 266627
  75.                 Tuple.Create(hud.Sno.SnoPowers.WitchDoctor_SoulHarvest.Sno, true, 18f),//灵魂收割, WitchDoctor_SoulHarvest, 67616
  76.             });
  77.             HeroClassCircleRadius.Add(HeroClass.Necromancer, new List<Tuple<uint, bool, float>>(){
  78.                 Tuple.Create(hud.Sno.SnoPowers.Necromancer_DeathNova.Sno, true, 15f),//死亡新星, Necromancer_DeathNova, 462243
  79.             });
  80.         }
  81.        
  82.         public void PaintWorld(WorldLayer layer)
  83.         {
  84.             if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map)) return;
  85.             if (!Hud.Game.Me.IsInGame) return;
  86.             if (!ShowInTown && Hud.Game.Me.IsInTown) return;
  87.             if (!ShowInNormalRift && (Hud.Game.SpecialArea == SpecialArea.Rift)) return;
  88.  
  89.             var me = Hud.Game.Me;
  90.             var radiusList = HeroClassCircleRadius[me.HeroClassDefinition.HeroClass];
  91.             // find the first matched sno
  92.             var matchedRadius = radiusList.Find(tuple => {
  93.                 // if is skill, not buff or passive
  94.                 if (tuple.Item2)
  95.                 {
  96.                     return me.Powers.UsedSkills.Any(skill => skill.SnoPower.Sno == tuple.Item1);
  97.                 }
  98.                 else {
  99.                     return me.Powers.BuffIsActive(tuple.Item1);
  100.                 }
  101.             });
  102.             if (matchedRadius != null && matchedRadius.Item3 != 0)
  103.             {
  104.                 MeDecorator.GetDecorators<IWorldDecoratorWithRadius>().ForEach(d => d.Radius = matchedRadius.Item3);
  105.                 MeDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d => d.Brush = HeroClassCircleBrush[me.Hero.ClassDefinition.HeroClass]);
  106.                 MeDecorator.Paint(layer, me, me.FloorCoordinate, null);
  107.             }
  108.         }
  109.     }
  110. }
Add Comment
Please, Sign In to add comment