RoleDataHandler.cs 1.5 KB

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