Exemple #1
0
        /// <summary>
        /// Initializes the sprites.
        /// </summary>
        /// <param name="bypass">if set to <c>true</c> it will bypass the Menu enabled check.</param>
        public static void InitSprites(bool bypass = false)
        {
            try
            {
                if (!MenuExtensions.GetItemValue <bool>("dz191.dza.hud.show") && !bypass)
                {
                    return;
                }

                HudSprite = new Render.Sprite(Resources.TFHelperBG, CurrentPosition)
                {
                    PositionUpdate   = () => CurrentPosition,
                    VisibleCondition = delegate { return(ShouldBeVisible); },
                };
                HudSprite.Crop(0, 0, (int)SpriteWidth, CroppedHeight);

                ExpandShrinkButton = new Render.Sprite(Resources.Expand, CurrentPosition)
                {
                    PositionUpdate   = () => new Vector2(CurrentPosition.X + SpriteWidth - 20, CurrentPosition.Y + CroppedHeight - 20),
                    Scale            = new Vector2(0.7f, 0.7f),
                    VisibleCondition = delegate { return(ShouldBeVisible); }
                };

                ExpandShrinkButton.Add(1);
                HudSprite.Add(0);
            }
            catch (Exception ex)
            {
                LogHelper.AddToLog(new LogItem("Hud_Init", ex, LogSeverity.Error));
            }
        }
Exemple #2
0
 private void Game_OnGameUpdate(EventArgs args)
 {
     if (_active && _duration > 0)
     {
         float percentage = (Game.ClockTime - _begin) / (_duration / 1000f);
         int   width      = (int)(_sprite.Width - (percentage * _sprite.Width));
         _countdownText.X    = (int)(_sprite.X + (width * _sprite.Scale.X) + GapTextBar);
         _countdownText.text =
             Math.Round(
                 (Decimal)((_duration / 1000f) - (Game.ClockTime - _begin)), 1, MidpointRounding.AwayFromZero) +
             "s";
         Rectangle rect = TextFont.MeasureText(null, _countdownText.text, FontDrawFlags.Center);
         _countdownText.Y = (int)(_sprite.Y - rect.Height / 2 + (_sprite.Height * Program.Instance().BarScale) / 2);
         _sprite.Crop(0, 0, width, _sprite.Height);
     }
     else
     {
         _sprite.Crop(0, 0, _sprite.Width, _sprite.Height);
     }
 }
Exemple #3
0
        private void Game_OnGameUpdate(EventArgs args)
        {
            float colorPercentage = (_hero.HealthPercent / 100);

            _healthText.Color = new ColorBGRA(1 - colorPercentage, colorPercentage, 0, 1);

            if (_active && _duration > 0)
            {
                float percentage = (Game.Time - _begin) / (_duration / 1000f);
                int   width      = (int)(_sprite.Width - (percentage * _sprite.Width));
                _countdownText.X    = (int)(_sprite.X + (width * _sprite.Scale.X) + GapTextBar);
                _countdownText.text = Math.Round((Decimal)((_duration / 1000f) - (Game.Time - _begin)), 1, MidpointRounding.AwayFromZero) + "s";
                Rectangle rect = TextFont.MeasureText(_countdownText.text);
                _countdownText.Y = (int)(_sprite.Y - rect.Height / 2 + (_sprite.Height * Program.Instance().BarScale) / 2);
                _sprite.Crop(0, 0, width, _sprite.Height);
            }
            else
            {
                _sprite.Crop(0, 0, _sprite.Width, _sprite.Height);
            }
        }
Exemple #4
0
        public static void Game_OnGameLoad(EventArgs args)
        {
            GameObject.OnCreate += GameObject_OnCreate;
            //Properties.Resources.RecallBar.Save("test123.png");
            float x = (Drawing.Direct3DDevice.Viewport.Width - Properties.Resources.RecallBar.Width) / 2f;
            float y = Drawing.Direct3DDevice.Viewport.Height * 3f / 4f;

            _sprite = new Render.Sprite(Properties.Resources.RecallBar, new Vector2(x, y));
            _sprite.Crop(0, 0, 20, Properties.Resources.RecallBar.Height);
            _sprite.Add(0);
            Game.OnGameProcessPacket += Game_OnGameProcessPacket;
            Game.PrintChat("Test 2");
        }
Exemple #5
0
 private void Game_OnGameUpdate(EventArgs args)
 {
     if (_active && _duration > 0)
     {
         float percentage = (Game.ClockTime - _begin) / (_duration / 1000f);
         int   width      =
             (int)(Properties.Resources.RecallBar.Width - (percentage * Properties.Resources.RecallBar.Width));
         _sprite.Crop(0, 0, width, Properties.Resources.RecallBar.Height);
         _countdownText.X    = _sprite.X + width + GapTextBar;
         _countdownText.text =
             Math.Round((Decimal)((_duration / 1000f) - (Game.ClockTime - _begin)), 1,
                        MidpointRounding.AwayFromZero) + "s";
         Rectangle rect = TextFont.MeasureText(null, _countdownText.text, FontDrawFlags.Center);
         _countdownText.Y = _sprite.Y - (rect.Height / 2);
     }
 }
Exemple #6
0
        private static void UpdateDrawings()
        {
            _greenBar.Reset();

            _goldAdvantage = (float)Math.Round(_myTeamGold / (_myTeamGold + _enemyTeamGold) * 100, 1);

            var width = (_goldAdvantage / 100) * ImgWidth;

            _greenBar.Crop(new Rectangle(_greenBar.X, _greenBar.Y, (int)width, _greenBar.Height), true);

            _leftText.text = _myTeamGold.ToString(CultureInfo.InvariantCulture) + "g";
            _leftText.X    = _redBar.X - Drawing.GetTextExtent(_leftText.text).Width;

            _middleText.text = _goldAdvantage + "%";
            _middleText.X    = Drawing.Width / 2 -
                               Drawing.GetTextExtent(_goldAdvantage.ToString(CultureInfo.InvariantCulture)).Width / 2;

            _rightText.text = _enemyTeamGold.ToString(CultureInfo.InvariantCulture) + "g";
            _rightText.X    = _redBar.Width + Drawing.GetTextExtent(_rightText.text).Width;

            Utility.DelayAction.Add(1000, UpdateDrawings);
        }
Exemple #7
0
            public Cooldown(Obj_AI_Hero hero)
            {
                Hero       = hero;
                _hudSprite =
                    new Render.Sprite(Resources.CD_Hud, default(Vector2))
                {
                    VisibleCondition = delegate
                    {
                        try
                        {
                            return(Visible);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(false);
                        }
                    },
                    PositionUpdate = delegate
                    {
                        try
                        {
                            return(HpBarPostion);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(default(Vector2));
                        }
                    }
                };

                //  Game.PrintChat(_summonerSpellSlots.Length.ToString());
                for (int i = 0; i < _summonerSpellSlots.Length; i++)
                {
                    // foreach (var sSlot in _summonerSpellSlots) {
                    //for (int i = 0; i < _summonerSpellSlots.Length; i++)
                    var index = i;
                    var spell = Hero.Spellbook.GetSpell(_summonerSpellSlots[index]);
                    // Game.PrintChat(spell.Name);
                    var summoner = Resources.ResourceManager.GetObject(string.Format("CD_{0}", spell.Name.ToLower())) ??
                                   Resources.CD_summonerbarrier;
                    var sprite = new Render.Sprite((Bitmap)summoner, default(Vector2))
                    {
                        VisibleCondition = delegate
                        {
                            try
                            {
                                return(Visible);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                                return(false);
                            }
                        }
                    };
                    sprite.PositionUpdate = delegate
                    {
                        try
                        {
                            sprite.Crop(new Rectangle(0,
                                                      12 *
                                                      ((spell.CooldownExpires - Game.Time > 0)
                                    ? (int)
                                                       (19 *
                                                        (1f -
                                                         ((Math.Abs(spell.Cooldown) > float.Epsilon)
                                              ? (spell.CooldownExpires - Game.Time) / spell.Cooldown
                                              : 1f)))
                                    : 19), 12, 12));
                            return(new Vector2(HpBarPostion.X + 3, HpBarPostion.Y + 1 + index * 13));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(default(Vector2));
                        }
                    };
                    var text = new Render.Text(default(Vector2), string.Empty, index * 13, Color.White)
                    {
                        VisibleCondition = delegate
                        {
                            try
                            {
                                return(Visible);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                                return(false);
                            }
                        }
                    };
                    text.PositionUpdate =
                        delegate
                    {
                        try
                        {
                            return(new Vector2(HpBarPostion.X - 5 - text.text.Length * 5,
                                               HpBarPostion.Y + 1 + 13 * index));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(default(Vector2));
                        }
                    };
                    text.TextUpdate = delegate
                    {
                        try
                        {
                            return(spell.CooldownExpires - Game.Time > 0f
                                ? string.Format(spell.CooldownExpires - Game.Time < 1f ? "{0:0.0}" : "{0:0}",
                                                spell.CooldownExpires - Game.Time)
                                : string.Empty);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(string.Empty);
                        }
                    };
                    _summonerSprites.Add(sprite);
                    _summonerSpellTexts.Add(text);
                }

                for (int i = 0; i < _spellSlots.Length; i++)
                {
                    var index = i;
                    var spell = Hero.Spellbook.GetSpell(_spellSlots[index]);
                    var line  = new Render.Line(default(Vector2), default(Vector2), 4, Color.Green)
                    {
                        VisibleCondition = delegate
                        {
                            try
                            {
                                return(Visible &&
                                       Hero.Spellbook.CanUseSpell(_spellSlots[index]) != SpellState.NotLearned);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                                return(false);
                            }
                        },
                        StartPositionUpdate = delegate
                        {
                            try
                            {
                                return(new Vector2(HpBarPostion.X + 18f + index * 27f, HpBarPostion.Y + 20f));
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                                return(default(Vector2));
                            }
                        }
                    };
                    line.EndPositionUpdate =
                        delegate
                    {
                        try
                        {
                            line.Color = spell.CooldownExpires - Game.Time <= 0f ? Color.Green : Color.DeepSkyBlue;
                            return
                                (new Vector2(
                                     line.Start.X +
                                     ((spell.CooldownExpires - Game.Time > 0f &&
                                       Math.Abs(spell.Cooldown) > float.Epsilon)
                                            ? 1f - ((spell.CooldownExpires - Game.Time) / spell.Cooldown)
                                            : 1f) * 23f, line.Start.Y));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(default(Vector2));
                        }
                    };
                    var text = new Render.Text(default(Vector2), string.Empty, 13, Color.White)
                    {
                        VisibleCondition = delegate
                        {
                            try
                            {
                                return(Visible);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                                return(false);
                            }
                        }
                    };
                    text.PositionUpdate =
                        delegate
                    {
                        try
                        {
                            return(new Vector2(line.Start.X + (23f - text.text.Length * 4) / 2, line.Start.Y + 7f));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(default(Vector2));
                        }
                    };
                    text.TextUpdate = delegate
                    {
                        try
                        {
                            return(spell.CooldownExpires - Game.Time > 0f
                                ? string.Format(spell.CooldownExpires - Game.Time < 1f ? "{0:0.0}" : "{0:0}",
                                                spell.CooldownExpires - Game.Time)
                                : string.Empty);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                            return(string.Empty);
                        }
                    };
                    _spellLines.Add(line);
                    _spellTexts.Add(text);
                }
            }
Exemple #8
0
 private static void Crop(Render.Sprite sprite, bool isMajor = false)
 {
     int[] dimensions = isMajor ? MajorCampSpriteDimensions : MinorCampSpriteDimensions;
     sprite.Crop(0, 0, dimensions[0], dimensions[1], true);
 }