context: using EloBuddy; 
   using LeagueSharp.Common; 
   namespace ElTalon
  {
      using System;
      using System.Collections.Generic;
      using System.Drawing;
      using System.Linq;
  
      using LeagueSharp;
      using LeagueSharp.Common;
  
      internal class Talon
      {
          #region Static Fields
  
          public static Menu Menu;
  
          private static SpellSlot ignite;
  
          private static Orbwalking.Orbwalker orbwalker;
  
          private static Spell Q, W, E, R;
  
          private static List<Spell> SpellList;
  
          private static Items.Item Tiamat, Hydra, Youmuu;
  
          #endregion
  
          #region Properties
  
          private static AIHeroClient Player
          {
              get
              {
                  return ObjectManager.Player;
              }
          }
  
          #endregion
  
          #region Public Methods and Operators
  
          public static void Game_OnGameLoad()
          {
              if (ObjectManager.Player.CharData.BaseSkinName != "Talon")
              {
                  return;
              }
  
              #region Spell Data
  
              // set spells
              Q = new Spell(SpellSlot.Q, Orbwalking.GetRealAutoAttackRange(Player) + 100);
              W = new Spell(SpellSlot.W, 650);
              E = new Spell(SpellSlot.E, 700);
              R = new Spell(SpellSlot.R, 650);
  
              W.SetSkillshot(0.25f, 75, 2300, false, SkillshotType.SkillshotLine);
  
              SpellList = new List<Spell> { Q, E, W, R };
  
              ignite = Player.GetSpellSlot("summonerdot");
  
              Tiamat = new Items.Item(3077, 400f);
              Youmuu = new Items.Item(3142, 0f);
              Hydra = new Items.Item(3074, 400f);
  
              InitializeMenu();
  
              #endregion
  
              Game.OnUpdate += OnGameUpdate;
              Drawing.OnDraw += Drawing_OnDraw;
              Orbwalking.AfterAttack += AfterAttack;
              AntiGapcloser.OnEnemyGapcloser += AntiGapcloser_OnEnemyGapcloser;
              new AssassinManager();
          }
  
          #endregion
  
          #region Methods
  
          private static void AfterAttack(AttackableUnit unit, AttackableUnit target)
          {
              switch (orbwalker.ActiveMode)
              {
                  case Orbwalking.OrbwalkingMode.Combo:
                      if (unit.IsMe && Q.IsReady() && target is AIHeroClient)
                      {
                          Q.Cast();
                          Orbwalking.ResetAutoAttackTimer();
                      }
                      break;
              }
          }
  
          private static void AntiGapcloser_OnEnemyGapcloser(ActiveGapcloser gapcloser)
          {
              var antiGapActive = Menu.Item("Antigap").IsActive();
              var target = TargetSelector.GetTarget(W.Range, TargetSelector.DamageType.Physical);
              if (target == null)
              {
                  return;
              }
  
              if (antiGapActive && E.IsReady() && gapcloser.Sender.Distance(Player) < 700)
              {
                  E.Cast(target);
              }
          }
  
          private static void Combo()
          {
              var target = GetEnemy(W.Range, TargetSelector.DamageType.Physical);
              if (target == null || !target.IsValid)
              {
                  return;
              }
  
              var useW = Menu.Item("WCombo").IsActive();
              var useE = Menu.Item("ECombo").IsActive();
              var rCombo = Menu.Item("RCombo").IsActive();
              var onlyKill = Menu.Item("RWhenKill").IsActive();
              var smartUlt = Menu.Item("SmartUlt").IsActive();
              var youmuuitem = Menu.Item("UseYoumuu").IsActive();
              var ultCount = Menu.Item("rcount").GetValue<Slider>().Value;
  
              var comboDamage = GetComboDamage(target);
              var getUltComboDamage = GetUltComboDamage(target);
  
              var ultType = Menu.Item("ElTalon.Combo.Mode").GetValue<StringList>().SelectedIndex;
  
              switch (ultType)
              {
                  case 0:
  
                      if (useE && E.IsReady())
                      {
                          E.Cast(target);
                      }
                      FightItems();
                      if (target.IsValidTarget(Q.Range))
                      {
                          EloBuddy.Player.IssueOrder(GameObjectOrder.AttackUnit, target);
                      }
  
                      if (Q.IsReady() && target.IsValidTarget(Q.Range))
                      {
                          Q.Cast(target);
                      }
  
                      if (useW && W.IsReady())
                      {
                          W.Cast(target);
                      }
  
                      if (onlyKill && E.IsReady() && rCombo && Q.IsReady()
                          && ObjectManager.Get<AIHeroClient>().Count(aiHero => aiHero.IsValidTarget(R.Range)) >= ultCount)
                      {
                          if (comboDamage >= target.Health)
                          {
                              R.Cast();
                          }
                      }
  
                      if (onlyKill && R.IsReady() && smartUlt)
                      {
                          if (getUltComboDamage >= target.Health)
                          {
                              R.Cast();
                          }
                      }
  
                      if (!onlyKill && E.IsReady() && rCombo && Q.IsReady()
                          && ObjectManager.Get<AIHeroClient>().Count(aiHero => aiHero.IsValidTarget(R.Range)) >= ultCount)
                      {
                          R.Cast();
                      }
  
                      break;
  
                  case 1:
  
                      if (R.IsReady() && R.IsInRange(target))
                      {
                          R.Cast();
                      }
  
                      if (useE && E.IsReady())
                      {
                          E.Cast(target);
                      }
  
                      if (useW && W.IsReady())
                      {
                          W.Cast(target);
                      }
  
                      FightItems();
                      break;
  
                  case 2:
  
                      if (useE && E.IsReady())
                      {
                          E.Cast(target);
                      }
  
                      if (R.IsReady() && R.IsInRange(target))
                      {
                          R.Cast();
                      }
  
                      if (useW && W.IsReady())
                      {
                          W.Cast(target);
                      }
  
                      FightItems();
                      break;
              }
  
              if (youmuuitem && Player.Distance(target) <= 400f && Youmuu.IsReady())
              {
                  Youmuu.Cast();
              }
  
              if (target.IsValidTarget(600f) && IgniteDamage(target) >= target.Health && Menu.Item("UseIgnite").IsActive())
              {
                  Player.Spellbook.CastSpell(ignite, target);
              }
          }
  
          private static void Drawing_OnDraw(EventArgs args)
          {
              var drawOff = Menu.Item("ElTalon.Drawingsoff").IsActive();
              var drawE = Menu.Item("ElTalon.DrawE").GetValue<Circle>();
              var drawW = Menu.Item("ElTalon.DrawW").GetValue<Circle>();
              var drawR = Menu.Item("ElTalon.DrawR").GetValue<Circle>();
  
              if (drawOff)
              {
                  return;
              }
  
              if (drawW.Active)
              {
                  if (W.Level > 0)
                  {
                      Render.Circle.DrawCircle(
                          ObjectManager.Player.Position,
                          W.Range,
                          W.IsReady() ? Color.Green : Color.Red);
                  }
              }
  
              if (drawE.Active)
              {
                  if (E.Level > 0)
                  {
                      Render.Circle.DrawCircle(
                          ObjectManager.Player.Position,
                          E.Range,
                          E.IsReady() ? Color.Green : Color.Red);
                  }
              }
  
              if (drawR.Active)
              {
                  if (R.Level > 0)
                  {
                      Render.Circle.DrawCircle(
                          ObjectManager.Player.Position,
                          R.Range,
                          R.IsReady() ? Color.Green : Color.Red);
                  }
              }
          }
  
          private static void FightItems()
          {
              var target = TargetSelector.GetTarget(W.Range, TargetSelector.DamageType.Physical);
  
              var tiamatItem = Menu.Item("UseTiamat").IsActive();
              var hydraItem = Menu.Item("UseHydra").IsActive();
  
              if (Items.CanUseItem(3074) && hydraItem && Player.Distance(target) <= 400f)
              {
                  Items.UseItem(3074);
              }
  
              if (Items.CanUseItem(3077) && tiamatItem && Player.Distance(target) <= 400f)
              {
                  Items.UseItem(3077);
              }
          }
  
          private static float GetComboDamage(Obj_AI_Base enemy)
          {
              var damage = 0d;
  
              if (Q.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.Q);
              }
  
              if (W.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.W);
              }
  
              if (E.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.E);
              }
  
              if (R.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.R);
              }
  
              return (float)damage;
          }
  
          private static AIHeroClient GetEnemy(
              float vDefaultRange = 0,
              TargetSelector.DamageType vDefaultDamageType = TargetSelector.DamageType.Physical)
          {
              if (Math.Abs(vDefaultRange) < 0.00001)
              {
                  vDefaultRange = Q.Range;
              }
  
              if (!Menu.Item("AssassinActive").GetValue<bool>())
              {
                  return TargetSelector.GetTarget(vDefaultRange, vDefaultDamageType);
              }
  
              var assassinRange = Menu.Item("AssassinSearchRange").GetValue<Slider>().Value;
  
              var vEnemy =
                  ObjectManager.Get<AIHeroClient>()
                      .Where(
                          enemy =>
                          enemy.Team != ObjectManager.Player.Team && !enemy.IsDead && enemy.IsVisible
                          && Menu.Item("Assassin" + enemy.ChampionName) != null
                          && Menu.Item("Assassin" + enemy.ChampionName).GetValue<bool>()
                          && ObjectManager.Player.Distance(enemy) < assassinRange);
  
              if (Menu.Item("AssassinSelectOption").GetValue<StringList>().SelectedIndex == 1)
              {
                  vEnemy = (from vEn in vEnemy select vEn).OrderByDescending(vEn => vEn.MaxHealth);
              }
  
              var objAiHeroes = vEnemy as AIHeroClient[] ?? vEnemy.ToArray();
  
              var t = !objAiHeroes.Any() ? TargetSelector.GetTarget(vDefaultRange, vDefaultDamageType) : objAiHeroes[0];
  
              return t;
          }
  
          private static float GetUltComboDamage(Obj_AI_Base enemy)
          {
              var damage = 0d;
  
              if (R.IsReady())
              {
                  damage += Player.GetSpellDamage(enemy, SpellSlot.R);
              }
  
              return (float)damage;
          }
  
          private static void Harass()
          {
              var target = TargetSelector.GetTarget(W.Range, TargetSelector.DamageType.Physical);
              if (target == null || !target.IsValid)
              {
                  return;
              }
  
              var qHarass = Menu.Item("HarassQ").IsActive();
              var wHarass = Menu.Item("HarassW").IsActive();
              var eHarass = Menu.Item("HarassE").IsActive();
  
  
gt:             foreach (var spell in SpellList.Where(y => y.IsReady()))