RoleDataHandler.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. CommonSProxy.ResetDailyData().Coroutine();
  45. RechargeSProxy.ReqRequestGiftBagInfo().Coroutine();
  46. RechargeSProxy.ReqExchangeInfo().Coroutine();
  47. DailyTaskSProxy.ReqDailyTaskInfos().Coroutine();
  48. SuitFosterProxy.SendGetSuitInfos().Coroutine();
  49. FieldSProxy.ReqFieldInstanceInfos().Coroutine();
  50. }
  51. }
  52. }
  53. }