local UIWarHorseRelationPopUp = UIViewClass() ------------------------------- 系统函数 ---------------------------- function UIWarHorseRelationPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_UpdateWarHorseInfo, self.RefreshPanel) self.CurHorseID = context.horseID self.CurHorseBreakLV = -1 self.CurHorseName = "" -- 防止频繁取值 再此保存一下 self:RefreshPanel() end function UIWarHorseRelationPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIWarHorseRelationPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIWarHorseRelationPopUp:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Relation then local heroData = DataSheetManager.HeroNum:GetDataByID(data) local hasHero = MDL.HeroSelect.IsHasHero(data) UIUtils.SetActive(cellTable.img_Gray, not hasHero) -- 只有当英雄和坐骑全都激活才不显示蒙版 if MDL.HeroAwaken.GetIsHeroAwaken(data) then UTL.Item.SetItemCell(cellTable.hero, CTL.HeroAwaken.GetItemIconId(data), nil, nil, nil, hasHero) else UTL.Item.SetItemCell(cellTable.hero, heroData.HeroItem, nil, nil, nil, hasHero) end local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroData:GetDataByID(data).NameIDS]) cellTable.txt_Hero.text = string.FormatByIdsId(Const_IDS.IDS_HorseRelation_RideHero, heroName) local curRelationData = CTL.WarHorse.GetHorousBreakRelation(self.CurHorseID, data, false) if curRelationData then local skillData = DataSheetManager.HorseSkillData:GetDataByHorseSkill(curRelationData.RelationSkill) if skillData then UIUtils.SetLabel(cellTable.txt_EffectNow, UTL.String.FormatCombineTextByID(skillData.HorseSkillDes)) else logging.error(LTAG.ERROR, "战骑羁绊配表错误 : 未找到该技能;horseID = ", self.CurHorseID, ",heroID = ", data, ",技能Id = ", curRelationData.RelationSkill) end else logging.error(LTAG.ERROR, "战骑羁绊配表错误 : 请检查;horseID = ", self.CurHorseID, ",heroID = ", data, "这一条数据") end local nextRelationData = CTL.WarHorse.GetHorousBreakRelation(self.CurHorseID, data, true) if nextRelationData ~= nil then -- 羁绊技能不满级时才有下一级效果 local skillData = DataSheetManager.HorseSkillData:GetDataByHorseSkill(nextRelationData.RelationSkill) if skillData then UIUtils.SetLabel(cellTable.txt_EffectNext, UTL.String.FormatCombineTextByID(skillData.HorseSkillDes)) else logging.error(LTAG.ERROR, "战骑羁绊配表错误 : 未找到该技能;horseID = ", self.CurHorseID, ",heroID = ", data, ",技能Id = ", nextRelationData.RelationSkill) end end end end ---------------------------------------------------------------------- function UIWarHorseRelationPopUp:RefreshPanel() local breakLV = CTL.WarHorse.GetCurHorousBreak(self.CurHorseID) if self.CurHorseBreakLV == breakLV then return end -- 此时等级相同不刷新界面,减少刷新 self.CurHorseBreakLV = breakLV self.CurHorseName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HorseData:GetDataByHorseID(self.CurHorseID).HorseName]) local nextRelationBreakLV = CTL.WarHorse.GetHorousRelationBreakLV(self.CurHorseID, true) self:UpdateRelationLoop(nextRelationBreakLV) self:UpdateTextUI(nextRelationBreakLV) end function UIWarHorseRelationPopUp:UpdateRelationLoop(nextRelationBreakLV) if self.loop_Relation.Count > 0 then self.loop_Relation:ClearCells() end for _, heroID in CTL.WarHorse.GetHorseRelationHeroList(self.CurHorseID) do local cellIndex = 0 if nextRelationBreakLV == nil then cellIndex = 1 end self.loop_Relation:AddData(heroID, cellIndex) end end function UIWarHorseRelationPopUp:UpdateTextUI(nextRelationBreakLV) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_HorseRelation_HeroEffect) local curRelationBreakLV = CTL.WarHorse.GetHorousRelationBreakLV(self.CurHorseID, false) if curRelationBreakLV == nil then curRelationBreakLV = 0 end if nextRelationBreakLV == nil then UIUtils.SetActive(self.group_Break.gameObject, false) UIUtils.SetActive(self.txt_Max.gameObject, true) UIUtils.SetActive(self.txt_Remind.gameObject, false) self.txt_Max.text = string.FormatByIdsId(Const_IDS.IDS_HorseRelation_Tips2, self.CurHorseName) else UIUtils.SetActive(self.group_Break.gameObject, true) UIUtils.SetActive(self.txt_Max.gameObject, false) UIUtils.SetActive(self.txt_Remind.gameObject, true) self.txt_Remind.text = string.FormatByIdsId(Const_IDS.IDS_HorseRelation_Tips1, self.CurHorseName, curRelationBreakLV, nextRelationBreakLV) self.txt_Now.text = string.FormatByIdsId(Const_IDS.IDS_HorseRelation_LevelBreak, self.CurHorseName, curRelationBreakLV) self.txt_Next.text = string.FormatByIdsId(Const_IDS.IDS_HorseRelation_LevelBreak, self.CurHorseName, nextRelationBreakLV) end end return UIWarHorseRelationPopUp