DeadTime.cs 807 B

12345678910111213141516171819202122232425262728293031
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. namespace OpenVIII
  4. {
  5. public class DeadTime : Slide<int>
  6. {
  7. private static int Lerp(int start, int end, float amount) => checked((int)MathHelper.Lerp(start, end, amount));
  8. private static TimeSpan totalTime(int start) => TimeSpan.FromMilliseconds((1000d / 15d) * start);
  9. public DeadTime() : base(200, 0, totalTime(200), Lerp) => Repeat = true;
  10. protected override void CheckRepeat()
  11. {
  12. if (Done)
  13. {
  14. DoneEvent?.Invoke(this, End);
  15. }
  16. base.CheckRepeat();
  17. }
  18. public override void GotoEnd()
  19. {
  20. DoneEvent?.Invoke(this, End);
  21. base.GotoEnd();
  22. }
  23. public event EventHandler<int> DoneEvent;
  24. }
  25. }