Damage.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Client.MirControls;
  2. namespace Client.MirObjects
  3. {
  4. public class Damage
  5. {
  6. public string Text;
  7. public Color Colour;
  8. public int Distance;
  9. public long ExpireTime;
  10. public double Factor;
  11. public int Offset;
  12. public MirLabel DamageLabel;
  13. public Damage(string text, int duration, Color colour, int distance = 50)
  14. {
  15. ExpireTime = (long)(CMain.Time + duration);
  16. Text = text;
  17. Distance = distance;
  18. Factor = duration / this.Distance;
  19. Colour = colour;
  20. }
  21. public void Draw(Point displayLocation)
  22. {
  23. long timeRemaining = ExpireTime - CMain.Time;
  24. if (DamageLabel == null)
  25. {
  26. DamageLabel = new MirLabel
  27. {
  28. AutoSize = true,
  29. BackColour = Color.Transparent,
  30. ForeColour = Colour,
  31. OutLine = true,
  32. OutLineColour = Color.Black,
  33. Text = Text,
  34. Font = new Font(Settings.FontName, 8F, FontStyle.Bold)
  35. };
  36. }
  37. displayLocation.Offset((int)(15 - (Text.Length * 3)), (int)(((int)((double)timeRemaining / Factor)) - Distance) - 75 - Offset);
  38. DamageLabel.Location = displayLocation;
  39. DamageLabel.Draw();
  40. }
  41. }
  42. }