示例#1
0
        public static void AddItem(Hero hero, Item item)
        {
            Menu rangeMenu;

            HeroMenu.TryGetValue(hero, out rangeMenu);

            if (rangeMenu == null)
            {
                return;
            }

            var castRange = item.GetCastRange();

            if (castRange >= 5000)
            {
                castRange = item.GetRadius();
            }

            var itemName = item.StoredName().GetDefaultName();
            var key      = hero.StoredName() + itemName;

            if (castRange > 0 && castRange <= 5000)
            {
                var addItem = new Menu(string.Empty, key, false, itemName);

                addItem.AddItem(new MenuItem(key + "enabled", "Enabled"))
                .SetValue(false)
                .ValueChanged += (sender, arg) => { Drawings.DrawRange(hero, itemName, arg.GetNewValue <bool>()); };

                addItem.AddItem(
                    new MenuItem(key + "bonus", "Bonus range").SetValue(new Slider(0, -300, 300)))
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeRange(key, hero, arg.GetNewValue <Slider>().Value); };

                addItem.AddItem(new MenuItem(key + "red", "Red").SetValue(new Slider(255, 0, 255)))
                .SetFontStyle(fontColor: Color.IndianRed)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Red); };

                addItem.AddItem(new MenuItem(key + "green", "Green").SetValue(new Slider(0, 0, 255)))
                .SetFontStyle(fontColor: Color.LightGreen)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Green); };

                addItem.AddItem(new MenuItem(key + "blue", "Blue").SetValue(new Slider(0, 0, 255)))
                .SetFontStyle(fontColor: Color.LightBlue)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Blue); };

                rangeMenu.AddSubMenu(addItem);

                Main.ItemsDictionary.Add(key, item.Level);
            }

            Main.ItemsSet.Add(key);
        }
示例#2
0
        public static void AddSpells(Hero hero)
        {
            var heroName = hero.StoredName();

            var heroMenu = new Menu(string.Empty, heroName, false, heroName);

            HeroMenu.Add(hero, heroMenu);

            foreach (
                var spell in
                hero.Spellbook.Spells.Where(x => x.ClassID != ClassID.CDOTA_Ability_AttributeBonus))
            {
                var spellName = spell.StoredName();
                var key       = heroName + spellName;

                var spellMenu = new Menu(string.Empty, key, false, spellName);

                spellMenu.AddItem(new MenuItem(key + "enabled", "Enabled")).SetValue(false)
                .ValueChanged += (sender, arg) => { Drawings.DrawRange(hero, spellName, arg.GetNewValue <bool>()); };

                spellMenu.AddItem(new MenuItem(key + "bonus", "Bonus range").SetValue(new Slider(0, -300, 300)))
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeRange(key, hero, arg.GetNewValue <Slider>().Value); };

                spellMenu.AddItem(new MenuItem(key + "red", "Red").SetValue(new Slider(255, 0, 255)))
                .SetFontStyle(fontColor: Color.IndianRed)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Red); };

                spellMenu.AddItem(new MenuItem(key + "green", "Green").SetValue(new Slider(0, 0, 255)))
                .SetFontStyle(fontColor: Color.LightGreen)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Green); };

                spellMenu.AddItem(new MenuItem(key + "blue", "Blue").SetValue(new Slider(0, 0, 255)))
                .SetFontStyle(fontColor: Color.LightBlue)
                .ValueChanged +=
                    (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Blue); };

                heroMenu.AddSubMenu(spellMenu);

                Main.AbilitiesDictionary.Add(key, Math.Max(spell.Level, 1));
            }

            Menu.AddSubMenu(heroMenu);
        }
示例#3
0
        public static void AddCustomItem(Hero hero, string texture, float range, string tooltip = null)
        {
            Menu rangeMenu;

            HeroMenu.TryGetValue(hero, out rangeMenu);

            if (rangeMenu == null)
            {
                return;
            }

            var key = hero.StoredName() + texture;

            var addItem = new Menu(string.Empty, key, false, texture);

            addItem.AddItem(new MenuItem(key + "enabled", "Enabled"))
            .SetValue(false)
            .SetTooltip(tooltip)
            .ValueChanged +=
                (sender, arg) => { Drawings.DrawRange(hero, texture, arg.GetNewValue <bool>(), customRange: true); };

            addItem.AddItem(
                new MenuItem(key + "bonus", "Bonus range").SetValue(new Slider(0, -300, 300)))
            .ValueChanged +=
                (sender, arg) => { Drawings.ChangeRange(key, hero, arg.GetNewValue <Slider>().Value, true); };

            addItem.AddItem(new MenuItem(key + "red", "Red").SetValue(new Slider(255, 0, 255)))
            .SetFontStyle(fontColor: Color.IndianRed)
            .ValueChanged +=
                (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Red); };

            addItem.AddItem(new MenuItem(key + "green", "Green").SetValue(new Slider(0, 0, 255)))
            .SetFontStyle(fontColor: Color.LightGreen)
            .ValueChanged +=
                (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Green); };

            addItem.AddItem(new MenuItem(key + "blue", "Blue").SetValue(new Slider(0, 0, 255)))
            .SetFontStyle(fontColor: Color.LightBlue)
            .ValueChanged +=
                (sender, arg) => { Drawings.ChangeColor(key, arg.GetNewValue <Slider>().Value, Color.Blue); };

            rangeMenu.AddSubMenu(addItem);

            Main.CustomRangesDictionary.Add(key, range);
        }
示例#4
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if (!Utils.SleepCheck("advancedRangeDisplay"))
            {
                return;
            }

            if (!inGame)
            {
                Hero = ObjectMgr.LocalHero;

                if (!Game.IsInGame || Hero == null)
                {
                    Utils.Sleep(1000, "advancedRangeDisplay");
                    return;
                }

                AbilitiesDictionary.Clear();
                ItemsDictionary.Clear();
                CustomRangesDictionary.Clear();
                HeroesLens.Clear();
                ItemsSet.Clear();

                MainMenu.Init();
                Drawings.Init();

                inGame = true;
            }

            if (!Game.IsInGame)
            {
                inGame = false;
                return;
            }

            if (Game.IsPaused)
            {
                return;
            }

            var allHeroes = ObjectMgr.GetEntities <Hero>().Where(x => !x.IsIllusion).ToList();

            foreach (var hero in allHeroes)
            {
                var heroName = hero.Name;

                if (!MainMenu.RangesMenu.ContainsKey(hero))
                {
                    MainMenu.AddSpells(hero);
                    MainMenu.AddCustomItem(hero, "attribute_bonus", 1300, "Experience range");
                }

                foreach (var spell in
                         hero.Spellbook.Spells.Where(x => Drawings.ParticleDictionary.ContainsKey(heroName + x.Name)))
                {
                    var  key = heroName + spell.Name;
                    uint savedLevel;
                    AbilitiesDictionary.TryGetValue(key, out savedLevel);
                    var spellLevel = spell.Level;
                    if (savedLevel == spellLevel)
                    {
                        continue;
                    }
                    AbilitiesDictionary[key] = spellLevel;
                    Drawings.ChangeRange(key, hero);
                }

                if (hero.FindItem("item_aether_lens") != null)
                {
                    if (!HeroesLens.Contains(hero))
                    {
                        Drawings.UpdateAbilityRanges(hero);
                        HeroesLens.Add(hero);
                    }
                }
                else
                {
                    if (HeroesLens.Contains(hero))
                    {
                        Drawings.UpdateAbilityRanges(hero);
                        HeroesLens.Remove(hero);
                    }
                }

                foreach (var item in hero.Inventory.Items)
                {
                    var key = heroName + item.Name.GetDefaultName();

                    if (!ItemsSet.Contains(key))
                    {
                        MainMenu.AddItem(hero, item);
                    }
                    else if (Drawings.ParticleDictionary.ContainsKey(key))
                    {
                        uint savedLevel;
                        ItemsDictionary.TryGetValue(key, out savedLevel);
                        var spellLevel = item.Level;
                        if (savedLevel == spellLevel)
                        {
                            continue;
                        }
                        ItemsDictionary[key] = spellLevel;
                        Drawings.ChangeRange(key, hero);
                    }
                }

                foreach (var key in AbilitiesDictionary.Keys.Where(x => x.StartsWith(heroName))
                         .Concat(ItemsDictionary.Keys.Where(x => x.StartsWith(heroName))))
                {
                    var ability = hero.FindAbility(key.Substring(heroName.Length));

                    if (ability == null)
                    {
                        if (Drawings.ParticleDictionary.ContainsKey(key))
                        {
                            Drawings.DisposeRange(key);
                        }
                    }
                    else
                    {
                        if (MainMenu.Menu.Item(key + "enabled").GetValue <bool>() &&
                            !Drawings.ParticleDictionary.ContainsKey(key) && ability.Level > 0)
                        {
                            Drawings.DrawRange(hero, ability is Item ? ability.Name.GetDefaultName() : ability.Name,
                                               true);
                        }
                    }
                }

                if (Game.GameTime % 480 > 240)
                {
                    if (!nightChanged)
                    {
                        nightChanged = true;
                        Drawings.ChangeTowerRanges(865);
                    }
                }
                else
                {
                    if (nightChanged)
                    {
                        nightChanged = false;
                        Drawings.ChangeTowerRanges(950);
                    }
                }

                //    if (RemoveFromMenu.Any()) {
                //        foreach (var key in RemoveFromMenu) {
                //            if (ItemsSet.Contains(key))
                //                ItemsSet.Remove(key);
                //            if (ItemsDictionary.ContainsKey(key))
                //                ItemsDictionary.Remove(key);
                //            if (AbilitiesDictionary.ContainsKey(key))
                //                AbilitiesDictionary.Remove(key);

                //            Menu rangeMenu;
                //            MainMenu.RangesMenu.TryGetValue(hero, out rangeMenu);
                //            if (rangeMenu == null) continue;

                //            rangeMenu.RemoveSubMenu(key);
                //        }
                //        RemoveFromMenu.Clear();
                //}

                foreach (var key in CustomRangesDictionary.Keys.Where(x =>
                                                                      !Drawings.ParticleDictionary.ContainsKey(x) &&
                                                                      x.StartsWith(heroName) &&
                                                                      MainMenu.Menu.Item(x + "enabled").GetValue <bool>()))
                {
                    Drawings.DrawRange(hero, key.Substring(hero.Name.Length), true, customRange: true);
                }
            }

            Utils.Sleep(1000, "advancedRangeDisplay");
        }