TimerHelper.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /****************************************************************************
  2. * Copyright (c) 2017 snowcold
  3. * Copyright (c) 2017 liangxie
  4. ****************************************************************************/
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. namespace QFramework
  8. {
  9. public class TimerHelper
  10. {
  11. protected List<TimeItem> m_TimeItemList;
  12. protected bool m_IsUseAble = true;
  13. public void Add(TimeItem item)
  14. {
  15. if (!m_IsUseAble)
  16. {
  17. Debug.LogError("TimeHelper Not Use Able...");
  18. return;
  19. }
  20. if (m_TimeItemList == null)
  21. {
  22. m_TimeItemList = new List<TimeItem>(2);
  23. }
  24. m_TimeItemList.Add(item);
  25. }
  26. public void Clear()
  27. {
  28. if (m_TimeItemList != null)
  29. {
  30. for (int i = m_TimeItemList.Count - 1; i >= 0; --i)
  31. {
  32. m_TimeItemList[i].Cancel();
  33. }
  34. m_TimeItemList.Clear();
  35. }
  36. }
  37. }
  38. }