RoleDataHandler.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using FairyGUI;
  2. namespace GFGGame
  3. {
  4. public class RoleDataHandler
  5. {
  6. //单位秒
  7. private const int INTERVAL_HEARTBEAT = 20;
  8. private static int _heartbeatCDEnd = 0;
  9. public static void StartUpdate()
  10. {
  11. _heartbeatCDEnd = ServerDataManager.currentTimeSecs + INTERVAL_HEARTBEAT;
  12. StopUpdate();
  13. Timers.inst.Add(1, 0, OnUpdate);
  14. }
  15. public static void StopUpdate()
  16. {
  17. Timers.inst.Remove(OnUpdate);
  18. }
  19. private static void OnUpdate(object param)
  20. {
  21. if(!RoleDataManager.CheckPowerFull())
  22. {
  23. int passTime = ServerDataManager.currentTimeSecs - RoleDataManager.powerTime;
  24. if(passTime >= GameConst.INTERVAL_TIME_SECONDS_POWER)
  25. {
  26. RoleDataManager.power++;
  27. }
  28. }
  29. int currentTimeSecs = ServerDataManager.currentTimeSecs;
  30. if(currentTimeSecs >= _heartbeatCDEnd)
  31. {
  32. //GameProxy.ReqUpdateTime();
  33. _heartbeatCDEnd = currentTimeSecs + INTERVAL_HEARTBEAT;
  34. }
  35. int day = ServerDataManager.CurrentDay;
  36. int recommendDay = StoryDataManager.recommendDay;
  37. if(recommendDay >= 0 && recommendDay != day)
  38. {
  39. StoryDataManager.ResetDailyData();
  40. }
  41. }
  42. }
  43. }