using FairyGUI; namespace GFGGame { public class RoleDataHandler { //单位秒 private const int INTERVAL_HEARTBEAT = 20; private static int _heartbeatCDEnd = 0; public static void StartUpdate() { _heartbeatCDEnd = ServerDataManager.currentTimeSecs + INTERVAL_HEARTBEAT; StopUpdate(); Timers.inst.Add(1, 0, OnUpdate); } public static void StopUpdate() { Timers.inst.Remove(OnUpdate); } private static void OnUpdate(object param) { if(!RoleDataManager.CheckPowerFull()) { int passTime = ServerDataManager.currentTimeSecs - RoleDataManager.powerTime; if(passTime >= GameConst.INTERVAL_TIME_SECONDS_POWER) { RoleDataManager.power++; } } int currentTimeSecs = ServerDataManager.currentTimeSecs; if(currentTimeSecs >= _heartbeatCDEnd) { GameProxy.ReqUpdateTime(); _heartbeatCDEnd = currentTimeSecs + INTERVAL_HEARTBEAT; } int day = ServerDataManager.CurrentDay; int recommendDay = StoryDataManager.recommendDay; if(recommendDay >= 0 && recommendDay != day) { StoryDataManager.ResetDailyData(); } } } }