Пример #1
0
        public static void AddMenu(Menu menu)
        {
            Core.DelayAction(() =>
            {
                bool exist = false;
                foreach (var spell in Database.GapCloserSpells)
                {
                    foreach (var enemy in ObjectManager.Heroes.Enemies)
                    {
                        if (spell.ChampionName == enemy.ChampionName)
                        {
                            if (!SpellData.ContainsKey(spell.SpellName))
                            {
                                SpellData[spell.SpellName] = true;
                                menu.Boolean(spell.SpellName, spell.ChampionName + " " + spell.Slot.ToString(), true);
                                exist = true;
                                break;
                            }
                        }
                    }
                }
                if (!exist)
                {
                    menu.AddSeparator("- No Spell Avaliable -");
                }
            }, 10);

            if (!load)
            {
                load = true;

                Obj_AI_Base.OnProcessSpellCast += (unit, spell) =>
                {
                    if (unit.IsEnemy && SpellData.ContainsKey(spell.SData.Name.ToLower()))
                    {
                        AntiSpellObject.GapcloseSpells.AddLast(new AntiSpellObject((AIHeroClient)unit, spell));
                    }
                };

                Game.OnTick += () =>
                {
                    if (AntiSpellObject.GapcloseSpells.Count == 0)
                    {
                        return;
                    }
                    var node = AntiSpellObject.GapcloseSpells.First;
                    for (int i = 1; i <= AntiSpellObject.GapcloseSpells.Count; ++i)
                    {
                        if (Game.Time > node.Value.end)
                        {
                            AntiSpellObject.GapcloseSpells.Remove(node);
                            break;
                        }
                        OnSpellActive(node.Value.unit, node.Value.spell);
                        if (i < AntiSpellObject.GapcloseSpells.Count)
                        {
                            node = node.Next;
                        }
                    }
                };
            }
        }