Ejemplo n.º 1
0
        private static void DrawButton(Vector2 a, Vector2 b, ref RangeObj rangeObj, Color @on, Color off)
        {
            var isIn = Utils.IsUnderRectangle(Game.MouseScreenPosition, a.X, a.Y, b.X, b.Y);

            if (rangeObj.IsDisplayable)
            {
                if (_leftMouseIsPress && Utils.SleepCheck("DSR_ClickButtonCd") && isIn)
                {
                    rangeObj.IsDisplayed = !rangeObj.IsDisplayed;
                    Utils.Sleep(250, "DSR_ClickButtonCd");
                }
                var newColor = isIn
                    ? new Color((int)(rangeObj.IsDisplayed ? @on.R : off.R), rangeObj.IsDisplayed ? @on.G : off.G, rangeObj.IsDisplayed ? @on.B : off.B, 150)
                    : rangeObj.IsDisplayed ? @on : off;
                Drawing.DrawRect(a, b, newColor);
            }
            else
            {
                Drawing.DrawRect(a, b, new Color(172, 172, 172, 125));
            }
            Drawing.DrawRect(a, b, Color.Black, true);
        }
Ejemplo n.º 2
0
        public static void Game_OnUpdate(EventArgs args)
        {
            Me = ObjectManager.LocalHero;

            if (!Game.IsInGame && _initialized)
            {
                _spellList     = new List <RangeObj>();
                _itemList      = new List <RangeObj>();
                _customList    = new List <RangeObj>();
                CacheSpellList = new Dictionary <string, RangeObj>();
                _initialized   = false;
            }

            if (!Game.IsInGame)
            {
                return;
            }

            if (_leftMouseIsPress && Game.IsInGame)
            {
                var selectedUnitTemp = ObjectManager.GetEntities <Unit>().Where(x => Vector3.Distance(x.Position, Game.MousePosition) < 300).OrderByDescending(x => - Vector3.Distance(x.Position, Game.MousePosition)).FirstOrDefault();
                if (selectedUnitTemp != null)
                {
                    SelectedUnit = selectedUnitTemp;
                }
            }

            if (!Utils.SleepCheck("DSR_GameUpdateSleeper"))
            {
                return;
            }

            if (!_initialized)
            {
                _initialized = true;
            }

            List <float> deleteSetList  = (from item in _customRange where !RangeMenu.Item("range" + (int)item).GetValue <bool>() select item).ToList();
            bool         changedSetList = false;

            foreach (var key in deleteSetList)
            {
                _customRange.Remove(key);
                for (int i = 0; i < RangeMenu.Items.Count; ++i)
                {
                    var menu = RangeMenu.Items[i];
                    if (menu.Name == ("range" + (int)key))
                    {
                        menu.Parent = null;
                        RangeMenu.Items.RemoveAt(i);
                        changedSetList = true;
                        break;
                    }
                }
            }
            if (RangeMenu.Item("addRangeToggler").GetValue <bool>() != _customRangeToggler)
            {
                _customRangeToggler = !_customRangeToggler;
                var num = RangeMenu.Item("rangeAddNum").GetValue <Slider>().Value * 10;
                RangeMenu.AddItem(new MenuItem("range" + num, "Range " + num).SetValue(true).SetTooltip("Toggle to delete").DontSave());
                _customRange.Add(num);
                changedSetList = true;
            }
            if (changedSetList)
            {
                SaveData();
            }

            RangeObj.UseOldStyle   = Menu.Item("useOldStyle").GetValue <bool>();
            RangeObj.UseColorStyle = Menu.Item("useColorStyle").GetValue <bool>();
            _showCachedRange       = Menu.Item("showCachedRange").GetValue <bool>();
            _showRangeSelector     = Menu.Item("showRangeSelector").GetValue <bool>();

            _customList = new List <RangeObj>();
            _spellList  = new List <RangeObj>();
            _itemList   = new List <RangeObj>();
            if (Menu.Item("lockMeOnly").GetValue <bool>())
            {
                SelectedUnit = (Unit)ObjectManager.LocalPlayer.Selection.FirstOrDefault();
            }
            if (SelectedUnit != null && !SelectedUnit.IsValid)
            {
                SelectedUnit = null;
            }
            if (SelectedUnit == null)
            {
                SelectedUnit = Me;
            }
            if (SelectedUnit != null)
            {
                RangeObj rangeObj = null;
                if (SelectedUnit.AttackCapability != AttackCapability.None)
                {
                    if (Menu.Item("useAttackRange").GetValue <bool>())
                    {
                        try
                        {
                            rangeObj = CacheSpellList[RangeObj.GetCacheKeyName(SelectedUnit, null, 0f, true)];
                        }
                        catch (KeyNotFoundException)
                        {
                            rangeObj = new RangeObj(true, SelectedUnit);
                        }
                        _customList.Add(rangeObj);
                    }
                }
                foreach (var rangeNum in _customRange)
                {
                    try
                    {
                        rangeObj = CacheSpellList[RangeObj.GetCacheKeyName(SelectedUnit, null, rangeNum)];
                    }
                    catch (KeyNotFoundException)
                    {
                        rangeObj = new RangeObj(rangeNum, SelectedUnit);
                    }
                    _customList.Add(rangeObj);
                }
                foreach (var spell in SelectedUnit.Spellbook.Spells)
                {
                    if (spell.Name == "attribute_bonus")
                    {
                        continue;
                    }
                    try
                    {
                        rangeObj = CacheSpellList[RangeObj.GetCacheKeyName(SelectedUnit, spell)];
                    }
                    catch (KeyNotFoundException)
                    {
                        rangeObj = new RangeObj(spell, SelectedUnit);
                    }
                    _spellList.Add(rangeObj);
                }
                if (SelectedUnit.HasInventory)
                {
                    foreach (var item in SelectedUnit.Inventory.Items)
                    {
                        try
                        {
                            rangeObj = CacheSpellList[RangeObj.GetCacheKeyName(SelectedUnit, item)];
                        }
                        catch (KeyNotFoundException)
                        {
                            rangeObj = new RangeObj(item, SelectedUnit);
                        }
                        _itemList.Add(rangeObj);
                    }
                }
            }

            //loop through the spellList and display them
            bool retry = true;

            while (retry)
            {
                try
                {
                    List <string> deleteList = new List <string>();
                    foreach (var item in CacheSpellList)
                    {
                        try
                        {
                            if (!item.Value.Refresh())
                            {
                                deleteList.Add(item.Key);
                            }
                        }
                        catch (EntityNotFoundException)
                        {
                        }
                    }
                    foreach (var key in deleteList)
                    {
                        CacheSpellList.Remove(key);
                    }
                    retry = false;
                }
                catch (InvalidOperationException)
                {
                }
            }

            Utils.Sleep(Menu.Item("refreshRate").GetValue <Slider>().Value, "DSR_GameUpdateSleeper");
        }