local UIRogueBattleAttackPanel = UIViewClass() local SkillImagePath = ConstAssetPathConfig.SkillImagePath local MathFloor = math.floor function UIRogueBattleAttackPanel:OnOpened(context) self:RegistSystemEvent(EventID.RogueLike_ExpChange, self.ExpChange) self:RegistSystemEvent(EventID.RogueLike_SkillGradeUp, self.RefreshSkillList) self.skillList = {} UIUtils.SetAtlasImageFillAmount(self.img_ProgressBar, 0) UIUtils.SetLabel(self.txt_Level, string.FormatByIdsId(Const_IDS.IDS_HeroBreakThough_To_Level, 1)) self:OnUpdateFun() self:StartRepeatFunc(self.OnUpdateFun, 1) self:RefreshSkillList() self.skillView = self.skillRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleAttackPanel), nil, Const_UI_Lua.UIEnum.UIRogueDodgeBattleAttackPanel) end function UIRogueBattleAttackPanel:ExpChange(curGrade, curGradeExp, curGradeExpMax) UIUtils.SetAtlasImageFillAmount(self.img_ProgressBar, curGradeExp / curGradeExpMax) UIUtils.SetLabel(self.txt_Level, string.FormatByIdsId(Const_IDS.IDS_HeroBreakThough_To_Level, curGrade)) --播放音效 CTL.Sound.PlayGameSound("UI_qte_click") end function UIRogueBattleAttackPanel:OnUpdateFun(deltaTime, timeSinceUpdate) local curTimer = BattleDataGetter.GetRemainTime() UIUtils.SetLabel(self.txt_Time, UTL.Time.FormatTimeBySeconds(curTimer)) self:RefreshScore() end function UIRogueBattleAttackPanel:RefreshScore() local curScore = BattleDataGetter.GetLevelScore() curScore = MathFloor(curScore) UIUtils.SetLabel(self.txt_Score, curScore) end function UIRogueBattleAttackPanel:RefreshSkillList() local skillList = BattleDataGetter.GetRogueLikeSkillInfo() local collection = self.cells for i= 1, 4 do local skillInfo = skillList[i] local itemCell = collection[i] if not itemCell then itemCell = self:InstantiateCollection(collection, collection[1].gameObject) UIUtils.SetActive(itemCell.gameObject, true) end if skillInfo then local skillDataCfg = DataSheetManager.RogueSkillData:GetDataBySkillID(skillInfo[1]) UIUtils.SetImageByAssetBundle(itemCell.sprite_Skill, string.format(SkillImagePath, skillDataCfg.SkillIcon)) UIUtils.SetLabel(itemCell.txt_Level, skillInfo[2]) UIUtils.SetActive(itemCell.btn_Skill, true) if not self.skillList[skillInfo[1]] then itemCell.effect_Get:PlayUIEffect() self.skillList[skillInfo[1]] = skillInfo[2] elseif self.skillList[skillInfo[1]] ~= skillInfo[2] then itemCell.effect_LvUp:PlayUIEffect() self.skillList[skillInfo[1]] = skillInfo[2] end else UIUtils.SetActive(itemCell.btn_Skill, false) end end end function UIRogueBattleAttackPanel:OnButtonClicked(comp) if comp == self.btn_Exit then CTL.Setting.BackToTown() end end return UIRogueBattleAttackPanel