RoleDataHandler.cs 1.6 KB

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