Beispiel #1
0
 public ScaleColor(ChampionSprite sprite, Color start, Color end)
 {
     this.Sprite     = sprite;
     this.StartColor = start;
     this.EndColor   = end;
     this.A          = end.A - start.A;
     this.R          = end.R - start.R;
     this.G          = end.G - start.G;
     this.B          = end.B - start.B;
 }
Beispiel #2
0
        private static void Draw(ChampionSprite sprite, int Yoffset, int x, int y)
        {
            try
            {
                if (!DownloadTexture.Finished || sprite == null)
                {
                    return;
                }

                sprite.Offset = 0;

                var vector2 = new Vector2(x, y + Yoffset);
                var iconPos = vector2;
                sprite.CurrentIcon.Sprite.Draw(vector2);

                var heroIconHeight = 0;
                if (sprite.Icon.Sprite.Rectangle.HasValue)
                {
                    heroIconHeight = sprite.Icon.Sprite.Rectangle.Value.Height;
                }

                var heroIconWidth = 0;
                if (sprite.Icon.Sprite.Rectangle.HasValue)
                {
                    heroIconWidth = sprite.Icon.Sprite.Rectangle.Value.Width;
                }

                var spellIconHeight = 0;
                var rndspell        = sprite.SpellSprites.FirstOrDefault();
                if (rndspell?.Icon.Sprite.Rectangle != null)
                {
                    spellIconHeight = rndspell.Icon.Sprite.Rectangle.Value.Height;
                }

                var barIconHeight = 0;
                if (sprite.XPBar.Sprite.Rectangle.HasValue)
                {
                    barIconHeight = sprite.XPBar.Sprite.Rectangle.Value.Height;
                }

                var barVector = vector2;
                barVector.Y   += heroIconHeight;
                sprite.Offset += heroIconHeight;

                if (HUDConfig.DrawXP)
                {
                    sprite.Offset += barIconHeight;
                    var xp = Math.Min(Math.Max(0, sprite.Champion.CurrentXPPercent()), 100);
                    sprite.XPBar.Sprite.Scale = new Vector2(1 * (xp / 100), 1);
                    sprite.EmptyBar.Sprite.Draw(barVector);
                    sprite.XPBar.Sprite.Draw(barVector);
                }
                else
                {
                    barVector.Y -= barIconHeight;
                }

                if (HUDConfig.DrawHP)
                {
                    sprite.Offset += barIconHeight;
                    barVector.Y   += barIconHeight;
                    var hp = sprite.Champion.IsDead ? 0 : Math.Min(Math.Max(0, sprite.Champion.HealthPercent), 100);
                    sprite.HPBar.Sprite.Scale = new Vector2(1 * (hp / 100), 1);
                    sprite.EmptyBar.Sprite.Draw(barVector);
                    sprite.HPBar.Sprite.Draw(barVector);
                }

                if (HUDConfig.DrawMP)
                {
                    sprite.Offset += barIconHeight;
                    barVector.Y   += barIconHeight;
                    var mp = sprite.Champion.IsDead ? 0 : Math.Min(Math.Max(0, sprite.Champion.ManaPercent), 100);
                    sprite.MPBar.Sprite.Scale = new Vector2(1 * (mp / 100), 1);
                    sprite.EmptyBar.Sprite.Draw(barVector);
                    sprite.MPBar.Sprite.Draw(barVector);
                }

                try
                {
                    if (HUDConfig.DrawRecall)
                    {
                        var tpInfo = sprite.Champion.GetTeleportInfo();
                        if (tpInfo != null && (tpInfo.Started || ((tpInfo.Aborted || tpInfo.Finished) && tpInfo.Duration > Core.GameTickCount - tpInfo.StartTick)))
                        {
                            if (RecallText == null)
                            {
                                var SIZE = sprite.Icon.Sprite.Rectangle.Value.Height + sprite.Icon.Sprite.Rectangle.Value.Width;
                                RecallText = new Text("Lato", new Font(FontFamily.GenericSerif, SIZE * 0.067f, FontStyle.Bold));
                            }

                            if (tpInfo.Args.Type == TeleportType.Unknown)
                            {
                                Logger.Warn($"KappAIO: Unknown TP type {tpInfo.Args.TeleportName} - Caster: {tpInfo.Caster.BaseSkinName} Duration: {tpInfo.Args.Duration}");
                            }

                            var c     = new Color();
                            var color = ScaleColors.FirstOrDefault(s => s.Sprite.Equals(sprite));
                            if (color != null)
                            {
                                c = color.CurrentColor;
                            }
                            else
                            {
                                var scaleColor = new ScaleColor(sprite, Color.White, Color.Gold)
                                {
                                    Duration = tpInfo.Duration
                                };
                                ScaleColors.Add(scaleColor);
                                c = scaleColor.CurrentColor;
                            }

                            var text      = tpInfo.Finished || tpInfo.Aborted ? tpInfo.Args.Status.ToString() : tpInfo.Name;
                            var modx      = vector2.X * 1.01f;
                            var modY      = (vector2.Y * 2 + sprite.Icon.Sprite.Rectangle.Value.Height) / 2;
                            var recallPos = new Vector2(modx, modY);
                            RecallText?.Draw(text.ToUpper(), c, recallPos);
                        }
                        else
                        {
                            ScaleColors.RemoveAll(s => s.Sprite.Equals(sprite));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex.Message);
                }

                vector2.X += heroIconWidth;
                foreach (var spell in sprite.SpellSprites.OrderBy(s => s.Slot))
                {
                    if (spell.IsOnCoolDown(sprite.Champion))
                    {
                        if (CDText == null)
                        {
                            var cdtextsize = spell.Icon.Sprite.Rectangle.Value.Height + spell.Icon.Sprite.Rectangle.Value.Width;
                            CDText = new Text("", new Font(FontFamily.GenericSerif, cdtextsize * 0.22f, FontStyle.Regular))
                            {
                                Color = Color.AliceBlue
                            };
                        }

                        var cdPos = new Vector2(vector2.X + spell.Icon.Sprite.Rectangle.Value.Width * 1.3f, vector2.Y);
                        CDText.Draw(spell.CurrentCD(sprite.Champion), Color.AliceBlue, cdPos);
                    }

                    spell.CurrentSprite(sprite.Champion).Draw(vector2);
                    vector2.Y += spellIconHeight;
                }

                if (LevelText == null)
                {
                    var size = (heroIconHeight + heroIconWidth) * 0.1f;
                    LevelText = new Text("", new Font(FontFamily.GenericSerif, size, FontStyle.Bold));
                }
                var lvlpos = new Vector2(iconPos.X + heroIconWidth * 0.69f, iconPos.Y + heroIconHeight * 0.69f);
                LevelText.Draw(sprite.Champion.Level.ToString(), Color.Red, lvlpos);

                if (sprite.Champion.IsDead)
                {
                    if (DeadText == null)
                    {
                        var size = (heroIconHeight + heroIconWidth) * 0.125f;
                        DeadText = new Text("Arial", new Font(FontFamily.GenericSerif, size, FontStyle.Bold));
                    }
                    DeadText.Draw(sprite.Champion.GetDeathDuration().ToTimeSpan(), Color.Red, new Vector2(iconPos.X + heroIconWidth * 0.225f, iconPos.Y + heroIconHeight * 0.375f));
                }
            }
            catch (Exception e)
            {
                if (e.Message.Contains("D3DERR_INVALIDCALL"))
                {
                    TextureManager.Reload();
                }
            }
        }