WaitEventList.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. namespace script
  4. {
  5. public class WaitEventList
  6. {
  7. public void EventCheck()
  8. {
  9. if (this.event_list_.Count <= 0)
  10. {
  11. return;
  12. }
  13. for (int i = 0; i < this.event_list_.Count; i++)
  14. {
  15. WaitEventList.Event @event = this.event_list_[i];
  16. if (@event.start_tick_count != -1)
  17. {
  18. if (@event.wait_time <= GameMain.tick_count - @event.start_tick_count && @event.IsPossibleDelete())
  19. {
  20. @event.call_back_delegate();
  21. @event.start_tick_count = -1;
  22. }
  23. }
  24. }
  25. this.event_list_.RemoveAll((WaitEventList.Event target) => target.start_tick_count < 0);
  26. }
  27. public void Add(Action exec_delegate, int wait)
  28. {
  29. WaitEventList.Event @event = new WaitEventList.Event(exec_delegate, wait);
  30. @event.start_tick_count = GameMain.tick_count;
  31. this.event_list_.Add(@event);
  32. }
  33. public void Clear()
  34. {
  35. this.event_list_.Clear();
  36. }
  37. public List<WaitEventList.Event> list
  38. {
  39. get
  40. {
  41. return this.event_list_;
  42. }
  43. }
  44. protected List<WaitEventList.Event> event_list_ = new List<WaitEventList.Event>();
  45. public class Event
  46. {
  47. public Event()
  48. {
  49. this.start_tick_count = -1;
  50. }
  51. public Event(Action call_back_delegate, int wait_time)
  52. {
  53. this.wait_time = wait_time;
  54. this.call_back_delegate = call_back_delegate;
  55. this.start_tick_count = -1;
  56. }
  57. public virtual bool IsPossibleDelete()
  58. {
  59. return true;
  60. }
  61. public int wait_time { get; set; }
  62. public Action call_back_delegate { get; set; }
  63. public int start_tick_count { get; set; }
  64. }
  65. }
  66. }