Ejemplo n.º 1
0
        private static void OnEndScene(EventArgs args)
        {
            if (HealthbarEnabled || PercentEnabled)
            {
                foreach (var unit in EntityManager.Heroes.Enemies.Where(u => u.IsValidTarget() && u.IsHPBarRendered))
                {
                    var damage = DamageToUnit(unit);

                    if (damage <= 0)
                    {
                        continue;
                    }

                    if (HealthbarEnabled)
                    {
                        var damagePercentage = (unit.TotalShieldHealth() - damage > 0 ? unit.TotalShieldHealth() - damage : 0) /
                                               (unit.MaxHealth + unit.AllShield + unit.AttackShield + unit.MagicShield);
                        var currentHealthPercentage = unit.TotalShieldHealth() / (unit.MaxHealth + unit.AllShield + unit.AttackShield + unit.MagicShield);

                        var startPoint = new Vector2(unit.HPBarPosition.X + BarOffset.X + damagePercentage * BarWidth, unit.HPBarPosition.Y + BarOffset.Y - 5);
                        var endPoint   = new Vector2(unit.HPBarPosition.X + BarOffset.X + currentHealthPercentage * BarWidth + 1, unit.HPBarPosition.Y + BarOffset.Y - 5);

                        OverlayLine.Draw(DrawingColor, startPoint, endPoint);
                        Drawing.DrawLine(startPoint, endPoint, LineThickness, DrawingColor);
                    }

                    if (PercentEnabled)
                    {
                        Drawing.DrawText(unit.HPBarPosition + PercentOffset, DrawingColor, string.Concat(Math.Ceiling(damage / unit.TotalShieldHealth() * 100), "%"), 10);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void AddOverlay(OverlayLine line)
        {
            this.ThrowIfDisposed();

            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }

            line.ThrowIfDisposed();

            NativeMethods.image_window_add_overlay4(this.NativePtr, line.NativePtr);
        }
Ejemplo n.º 3
0
        private static void OnEndScene(EventArgs args)
        {
            if (HealthbarEnabled || PercentEnabled)
            {
                foreach (var unit in EntityManager.Heroes.Enemies.Where(u => u.IsValidTarget() && u.IsHPBarRendered))
                {
                    // Get damage to unit
                    var damage = DamageToUnit(unit);

                    // Continue on 0 damage
                    if (damage <= 0)
                    {
                        continue;
                    }

                    if (HealthbarEnabled)
                    {
                        // Get remaining HP after damage applied in percent and the current percent of health
                        var damagePercentage = (unit.TotalShieldHealth() - damage > 0
                            ? unit.TotalShieldHealth() - damage
                            : 0) /
                                               (unit.MaxHealth + unit.AllShield + unit.AttackShield + unit.MagicShield);
                        var currentHealthPercentage = unit.TotalShieldHealth() /
                                                      (unit.MaxHealth + unit.AllShield + unit.AttackShield +
                                                       unit.MagicShield);

                        // Calculate start and end point of the bar indicator
                        var startPoint = new Vector2(unit.HPBarPosition.X + _barOffset.X + damagePercentage * BarWidth,
                                                     unit.HPBarPosition.Y + _barOffset.Y - 5);
                        var endPoint =
                            new Vector2(unit.HPBarPosition.X + _barOffset.X + currentHealthPercentage * BarWidth + 1,
                                        unit.HPBarPosition.Y + _barOffset.Y - 5);

                        // Draw the line
                        OverlayLine.Draw(DrawingColor, startPoint, endPoint);
                        Drawing.DrawLine(startPoint, endPoint, LineThickness, DrawingColor);

                        if (PercentEnabled)
                        {
                            // Get damage in percent and draw next to the health bar
                            Drawing.DrawText(unit.HPBarPosition + _percentOffset, DrawingColor,
                                             string.Concat(Math.Ceiling(damage / unit.TotalShieldHealth() * 100), "%"), 10);
                        }
                    }
                }
            }
        }