---@class KLUIHurtExpPanel:UIKmlLuaPanelBase ---@field view KLUIHurtExpPanelView local KLUIHurtExpPanel = class(UIKmlLuaPanelBase) local this = KLUIHurtExpPanel ---创建时调用一次 function this:Init() self.end_time = SL:GetConfig("cfg_global",24001).value self.end_time = tonumber(self.end_time) self.last_time = Time.GetServerTime() self.updateID = SL:Schedule(self.updateID,0,5,-1,function() self:RefreshUI() end) self.update2ID = SL:Schedule(self.update2ID,0,1,-1,function() self:CheckSafe() end) end ---创建或者刷新界面数据时调用 function this:Refresh() end function this:CheckSafe() local isSafe = SL:GetMetaValue(EMetaVarGetKey.IN_SAFE_AREA) if isSafe then GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIHurtExp/KLUIHurtExpPanel") end end ---注册UI事件和服务器消息 function this:RegistEvents() --SL:RegisterLUAEvent(LUA_EVENT_NET_PLAYER_DIE, self.PlayerDie, self) --玩家死亡 end function this:RefreshTime() self.last_time = Time.GetServerTime() end function this:RefreshUI() local current_time = Time.GetServerTime() if self.last_time < current_time - 1000 * self.end_time -100 then GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIHurtExp/KLUIHurtExpPanel") return end self:ShowHurt() self:ShowExp() end function this:ShowHurt() local hurt_num = InfoManager.mainUIInfo:GetHurtNum() local str = string.format("伤害 %s/秒",hurt_num) GUI:Text_setString(self.view.hurt,str) end function this:ShowExp() local exp_num = InfoManager.mainUIInfo:GetExpNum() exp_num = math.floor(exp_num) exp_num = SL:GetSimpleNumber(exp_num,0) local str = string.format("经验 %s/分",exp_num) GUI:Text_setString(self.view.exp,str) end function this:Close() if self.updateID then SL:UnSchedule(self.updateID) self.updateID = nil end if self.update2ID then SL:UnSchedule(self.update2ID) self.update2ID = nil end end return this