RoleDataHandler.cs 1.8 KB

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