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)); } }
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); } } }; for (int i = 0; i < _summonerSpellSlots.Length; i++) { var index = i; var spell = Hero.SummonerSpellbook.GetSpell(_spellSlots[index]); 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, 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); } }