local UIBattleBuffDetailTips = UIViewClass() local MaxTime = 99999 local NeutralBuffColor = "e8d588" function UIBattleBuffDetailTips:OnOpened(context) self:RegistSystemEvent(EventID.UI_UpdateBuff_Tips, self.UpdateBuffTips) self:RegistSystemEvent(EventID.Level_Pause, self.PauseCD) self.entityId = context.entityId self.isRefreshCD = false self.isBeginTimer = false self:UpdateBuffTips(self.entityId, context.buffInfoList) UIUtils.SetActive(self.rect_Close, true) self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) if BattleDataGetter.GetEntityByEntityID(self.entityId).components.base.HidingNeedUpdate then self:PauseCD(true) end end function UIBattleBuffDetailTips:OnButtonClicked(comp) if comp == self.rect_Close then self:CloseView() end end function UIBattleBuffDetailTips:UpdateBuffTips(entityId, buffInfoList) if self.entityId == entityId then self.buffInfoList = buffInfoList if #self.buffInfoList == 0 then self:CloseView() end self.loop_BuffInfo.enabled = false self.loop_BuffInfo:ReloadAll(self.buffInfoList) self.loop_BuffInfo.enabled = true end end function UIBattleBuffDetailTips:PauseCD(pause) self.isRefreshCD = true self.isBeginTimer = pause self.loop_BuffInfo:RefreshCells() self.isRefreshCD = false end function UIBattleBuffDetailTips:OnCellInit(scrollRect, index, cellTable, data) local buffData = data.BuffInfoData UIUtils.SetImageByAssetBundle(cellTable.img_Buff, buffData.BuffIcon) UIUtils.SetLabelText(cellTable.txt_BuffName, Const_IDS[buffData.BuffName]) cellTable.txt_BuffInfo.text = UTL.String.FormatCombineTextByID(buffData.BuffDescribe) --BUFF来源 local sourceEntityId = data.SourceEntityId local sourceEntity = BattleDataGetter.GetEntityByEntityID(sourceEntityId) local entity = BattleDataGetter.GetEntityByEntityID(self.entityId) if sourceEntity then if sourceEntity:IsPlayerSelf() or (not entity:IsPlayerSelf()) then UIUtils.SetActive(cellTable.txt_Source, false) else --增益绿色,否则为红色 local playerName = BattleDataGetter.GetBuffSourceEntityName(sourceEntity) if buffData.GainType == LuaConst.EBuffGainType.BAD then playerName = UTL.Color.FormatRedColor(playerName) elseif buffData.GainType == LuaConst.EBuffGainType.GOOD then playerName = UTL.Color.FormatGreenColor(playerName) end cellTable.txt_Source.text = string.FormatByIdsId(Const_IDS.IDS_OfficialPrivilege_UseForYou, playerName) UIUtils.SetActive(cellTable.txt_Source, true) end else UIUtils.SetActive(cellTable.txt_Source, false) end --BUFF时间 if self.isRefreshCD then if data.BuffTimer <= MaxTime then if self.isBeginTimer then cellTable.sprite_CDMask:PauseTimer() cellTable.timer_Buff:PauseTimer() else cellTable.sprite_CDMask:ResumeTimer() cellTable.timer_Buff:ResumeTimer() end else cellTable.sprite_CDMask:EndTimer() cellTable.sprite_CDMask:SetSpriteMaskFillAmount(0) cellTable.timer_Buff:EndTimer() cellTable.timer_Buff:SetSpriteMaskFillAmount(0) end else local buffTime = data.BuffTimer cellTable.sprite_CDMask:SetSpriteMaskFillAmount (0) cellTable.timer_Buff:EndTimer() cellTable.sprite_CDMask:EndTimer() if buffTime and buffTime > 0 then if buffTime > MaxTime then if buffData.GainType == LuaConst.EBuffGainType.BAD then cellTable.timer_Buff.CDText.text = UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Title_Forever)) elseif buffData.GainType == LuaConst.EBuffGainType.GOOD then cellTable.timer_Buff.CDText.text = UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Title_Forever)) else cellTable.timer_Buff.CDText.text = UTL.Color.FormatTextByColor(NeutralBuffColor, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Title_Forever)) end else local leftTime = BattleDataGetter.GetEntityBuffUpdateTimerByID(entity, data.BuffID) leftTime = leftTime > 0 and leftTime or buffTime if buffData.GainType == LuaConst.EBuffGainType.BAD then local dayStr = UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)) local hourStr = UTL.Color.FormatRedColor("{0}:{1}:{2}") local minStr = UTL.Color.FormatRedColor("{0}:{1}") cellTable.timer_Buff:SetDHMSStr(dayStr, hourStr, minStr, minStr) elseif buffData.GainType == LuaConst.EBuffGainType.GOOD then local dayStr = UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)) local hourStr = UTL.Color.FormatGreenColor("{0}:{1}:{2}") local minStr = UTL.Color.FormatGreenColor("{0}:{1}") cellTable.timer_Buff:SetDHMSStr(dayStr, hourStr, minStr, minStr) else local dayStr = UTL.Color.FormatTextByColor(NeutralBuffColor, UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)) local hourStr = UTL.Color.FormatTextByColor(NeutralBuffColor, "{0}:{1}:{2}") local minStr = UTL.Color.FormatTextByColor(NeutralBuffColor, "{0}:{1}") cellTable.timer_Buff:SetDHMSStr(dayStr, hourStr, minStr, minStr) end cellTable.timer_Buff:ResetAndBeginCustomTimer(false, leftTime, buffTime, "") cellTable.sprite_CDMask:ResetAndBeginTimer(true, buffTime - leftTime, buffTime) end end end local layer = data.BuffLayer if layer and layer > 1 then cellTable.lab_FloorNum.text = layer else cellTable.lab_FloorNum.text = nil end end return UIBattleBuffDetailTips