context: #region
  
  using System;
  using System.Collections.Generic;
  using System.Drawing;
  using System.Linq;
  using LeagueSharp;
  using LeagueSharp.Common;
  using SharpDX;
  using SharpDX.Direct3D9;
  using Collision = LeagueSharp.Common.Collision;
  using Color = System.Drawing.Color;
  using Font = SharpDX.Direct3D9.Font;
  using Marksman.Common;
  
  #endregion
  
   namespace Marksman.Champions
  {
      using EloBuddy;
      using EloBuddy.SDK;
      using EloBuddy.SDK.Menu;
      using EloBuddy.SDK.Menu.Values;
      using Marksman.Utils;
  
      internal class Ezreal : Champion
      {
          public static LeagueSharp.Common.Spell Q;
  
          public static LeagueSharp.Common.Spell E;
  
          public static LeagueSharp.Common.Spell W;
  
          public static LeagueSharp.Common.Spell R;
  
          private static bool haveIceBorn = false;
  
          public Ezreal()
          {
              Q = new LeagueSharp.Common.Spell(SpellSlot.Q, 1190);
              Q.SetSkillshot(0.25f, 60f, 2000f, true, SkillshotType.SkillshotLine);
  
              W = new LeagueSharp.Common.Spell(SpellSlot.W, 950);
              W.SetSkillshot(0.25f, 80f, 1600f, false, SkillshotType.SkillshotLine);
  
              E = new LeagueSharp.Common.Spell(SpellSlot.E, 475);
  
              R = new LeagueSharp.Common.Spell(SpellSlot.R, 2500);
              R.SetSkillshot(1f, 160f, 2000f, false, SkillshotType.SkillshotLine);
  
              Obj_AI_Base.OnBuffGain += (sender, args) =>
              {
                  //if (sender.IsMe)
                  //Game.PrintChat(args.Buff.Name);
              };
  
              Utils.PrintMessage("Ezreal loaded");
          }
  
          public override void Orbwalking_AfterAttack(AttackableUnit target, EventArgs args)
          {
              var t = target as AIHeroClient;
              if (t != null && (ComboActive || HarassActive) && !t.HasKindredUltiBuff())
              {
                  var useQ = ComboActive ? Program.combo["UseQC"].Cast<CheckBox>().CurrentValue : Program.harass["UseQH"].Cast<CheckBox>().CurrentValue;
                  var useW = ComboActive ? Program.combo["UseWC"].Cast<CheckBox>().CurrentValue : Program.harass["UseWH"].Cast<CheckBox>().CurrentValue;
  
                  if (Q.IsReady() && useQ)
                  {
                      Q.CastIfHitchanceGreaterOrEqual(t);
                  }
                  else if (W.IsReady() && useW)
                  {
                      W.CastIfHitchanceGreaterOrEqual(t);
                  }
              }
          }
  
          public override void Drawing_OnDraw(EventArgs args)
          {
              if (ComboActive && Program.combo["UseEC"].Cast<CheckBox>().CurrentValue && E.IsReady())
              {
                  var nRange = ObjectManager.Player.HealthPercent < 25 ? 550 : 450;
                  var nSum = HeroManager.Enemies.Where(e => e.LSIsValidTarget(nRange) && e.LSIsFacing(ObjectManager.Player)).Sum(e => e.HealthPercent);
                  if (nSum > ObjectManager.Player.HealthPercent)
                  {
                      var nResult = HeroManager.Enemies.FirstOrDefault(e => e.LSIsValidTarget(nRange));
                      if (nResult != null)
                      {
                          var nPosition = ObjectManager.Player.Position.LSExtend(nResult.Position, -E.Range);
                          E.Cast(nPosition);
                      }
                  }
                  Render.Circle.DrawCircle(ObjectManager.Player.Position, nRange, Color.DarkSalmon);
              }
  
              var t = TargetSelector.GetTarget(1500, DamageType.Magical);
              if (t != null)
              {
                  var x = ObjectManager.Player.Position.LSExtend(t.Position, -E.Range);
                  //var x = t.Position.Extend(ObjectManager.Player.Position, -E.Range);
                  Render.Circle.DrawCircle(x, 105f, Color.DarkSalmon);
  
              }
              foreach (var enemy in HeroManager.Enemies.Where(enemy => R.IsReady() && enemy.LSIsValidTarget() && R.GetDamage(enemy) > enemy.Health))
              {
                  Marksman.Common.CommonGeometry.DrawBox(new Vector2(Drawing.Width * 0.43f, Drawing.Height * 0.80f), 185, 18, Color.FromArgb(242, 255, 236, 6), 1, System.Drawing.Color.Black);
                  Marksman.Common.CommonGeometry.DrawText(Marksman.Common.CommonGeometry.Text, "Killable enemy with ultimate: " + enemy.ChampionName, Drawing.Width * 0.435f, Drawing.Height * 0.803f, SharpDX.Color.Black);
              }
  
              LeagueSharp.Common.Spell[] spellList = { Q, W };
              foreach (var spell in spellList)
              {
                  var menuItem = Program.marksmanDrawings["Draw" + spell.Slot].Cast<CheckBox>().CurrentValue;
                  if (menuItem)
                      Render.Circle.DrawCircle(ObjectManager.Player.Position, spell.Range, Color.FromArgb(100, 255, 0, 255));
              }
  
              var drawRMin = Program.combo["DrawRMin"].Cast<CheckBox>().CurrentValue;
              if (drawRMin)
              {
                  var minRRange = Program.combo["UseRCMinRange"].Cast<Slider>().CurrentValue;
                  Render.Circle.DrawCircle(ObjectManager.Player.Position, minRRange, Color.DarkRed, 2);
              }
  
              var drawRMax = Program.combo["DrawRMax"].Cast<CheckBox>().CurrentValue;
              if (drawRMax)
              {
                  var maxRRange = Program.combo["UseRCMaxRange"].Cast<Slider>().CurrentValue;
                  Render.Circle.DrawCircle(ObjectManager.Player.Position, maxRRange, Color.DarkMagenta, 2);
              }
          }
  
          public override void DrawingOnEndScene(EventArgs args)
          {
              if (Program.misc["PingDH"].Cast<CheckBox>().CurrentValue)
              {
                  var i = 0;
                  foreach (var enemy in HeroManager.Enemies.Where(enemy => R.IsReady() && enemy.IsValidTarget() && R.GetDamage(enemy) > enemy.Health))
                  {
                      //Game.PrintChat(HeroManager.Enemies[i].ChampionName);
                      float a1 = (i + 1) * 0.025f;
  
                      Common.CommonGeometry.DrawBox(
                          new Vector2(Drawing.Width * 0.43f, Drawing.Height * (0.700f + (float)a1)), 150, 18,
                          Color.FromArgb(170, 255, 0, 0), 1, System.Drawing.Color.Black);
  
                      CommonGeometry.Text.DrawTextCentered(HeroManager.Enemies[i].ChampionName + " Killable with R",
                          (int)(Drawing.Width * 0.475f), (int)(Drawing.Height * (0.803f + a1 - 0.093f)), SharpDX.Color.Wheat);
  
                      i += 1;
                  }
              }
          }
          
  
          public override void Game_OnGameUpdate(EventArgs args)
          {
              Console.WriteLine(Q.GetHitchance().ToString());
              haveIceBorn = ObjectManager.Player.InventoryItems.Any(i => i.Id == ItemId.Iceborn_Gauntlet);
  
              if (Program.misc["ChargeR.Enable"].Cast<CheckBox>().CurrentValue && !Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Combo))
              {
                  var rCooldown = Program.misc["ChargeR.Cooldown"].Cast<Slider>().CurrentValue;
                  var rMinMana = Program.misc["ChargeR.MinMana"].Cast<Slider>().CurrentValue;
  
                  if (ObjectManager.Player.ManaPercent >= rMinMana && R.Cooldown >= rCooldown)
                  {
                      var vMinions = MinionManager.GetMinions(ObjectManager.Player.Position, Q.Range);
                      foreach (var hit in from minions in vMinions
                                          select Q.GetPrediction(minions)
                          into qP
                                          let hit = qP.CastPosition.LSExtend(ObjectManager.Player.Position, -140)
                                          where qP.HitChance >= Q.GetHitchance()
                                          select hit)
                      {
                          Q.Cast(hit);
                      }
                  }
              }
  
  
  
              // 3070 tear of the goddess
              //  foreach (var i in ObjectManager.Player.InventoryItems)
              //  {
              //Game.PrintChat(i.IData.Id.ToString());
              //    }
  
              if (Program.misc["PingCH"].Cast<CheckBox>().CurrentValue)
              {
                  foreach (var enemy in
                      HeroManager.Enemies.Where(
                          enemy =>
                              R.IsReady() && enemy.LSIsValidTarget() && R.GetDamage(enemy) > enemy.Health
                              && enemy.LSDistance(ObjectManager.Player) > Q.Range))
                  {
                      Utils.MPing.Ping(enemy.Position.LSTo2D());
                  }
              }
  
              AIHeroClient t = TargetSelector.GetTarget(Q.Range, DamageType.Physical);
              var toggleQ = Program.harass["UseQTH"].Cast<KeyBind>().CurrentValue;
              var toggleW = Program.harass["UseWTH"].Cast<KeyBind>().CurrentValue;
              if ((toggleQ || toggleW) && t.LSIsValidTarget(Q.Range) && ToggleActive)
              {
                  if (Q.IsReady() && toggleQ)
                  {
                      if (ObjectManager.Player.HasBuff("Recall")) return;
  
                      var useQt = (Program.harass["DontQToggleHarass" + t.ChampionName] != null
                                   && Program.harass["DontQToggleHarass" + t.ChampionName].Cast<CheckBox>().CurrentValue == false);
                      if (useQt)
                      {
                          Q.CastIfHitchanceGreaterOrEqual(t);
                      }
                  }
  
                  if (W.IsReady() && t.LSIsValidTarget(W.Range) && toggleW)
                  {
                      if (ObjectManager.Player.HasBuff("Recall")) return;
                      var useWt = (Program.harass["DontWToggleHarass" + t.ChampionName] != null
                                   && Program.harass["DontWToggleHarass" + t.ChampionName].Cast<CheckBox>().CurrentValue == false);
                      if (useWt)
                      {
                          W.Cast(t);
                      }
                  }
              }
  
  
gt:             if (ComboActive || HarassActive)