--[[ 神兽详情界面 ]]-- local UIGodBeastInfo = UIViewClass() function UIGodBeastInfo:OnOpened(context) self:RegistSystemEvent(EventID.BagItem_Update, self.UpdateItemInfo) self:RegistSystemEvent(EventID.UI_GodBeastRefresh, self.RefreshPanel) self.config = context.config self:RefreshPanel() end function UIGodBeastInfo:RefreshPanel() self.activeBeastInfo = MDL.GodBeast.GetGodBeastInfoByID(self.config.ID) -- 资质 UIUtils.SetLabel(self.txt_GodBeastTalent, self.config.GodBeastTalent) -- 姓名 CTL.GodBeast.SetGodBeastName(self.txt_GodBeast, self.config.ID) -- 描述 UIUtils.SetLabelText(self.txt_Introduce01, Const_IDS[self.config.GodBeastDes]) -- 技能描述 CTL.GodBeast.SetSkillInfo(self.sprite_Skill, self.txt_SkillName, self.txt_SkillDesc, self.config.ID) -- 天赋信息 self:InitTalentInfo() -- 突破命轮几重 if self.activeBeastInfo then -- Info_Introduce 组件显隐 self.obj_state:SetState(0) UIUtils.SetLabel(self.txt_Break, "+" .. self.activeBeastInfo.starLevel) self:InitAttr() else self.obj_state:SetState(1) UIUtils.SetLabel(self.txt_Break, "+" .. 0) self:InitAttr(true) end self:UpdateItemInfo() end function UIGodBeastInfo:InitTalentInfo() local talentCount = self.config.TalentCount for line = 1, talentCount do local curLearnPoint = MDL.GodBeast.GetTalentPointProgress(self.config.ID, line) local content = self.talent_Content[line] if not content then content = self:InstantiateCollection(self.talent_Content, self.cell_Talent.gameObject) end -- 线描述 UIUtils.SetActive(content.gameObject, true) local talentConfig = DataSheetManager.GodBeastTalent:GetDataByID_LevelID_PointId(self.config.ID, line, 1) UIUtils.SetLabelText(content.txt_Skill, Const_IDS[talentConfig.GodBeast_TalentType]) for idx = 1, 4 do -- 点位描述 local talentPointData = DataSheetManager.GodBeastTalent:GetDataByID_LevelID_PointId(self.config.ID, line, idx) local subCol = content.talent_Arr[idx] UIUtils.SetActive(subCol.gameObject, true) UIUtils.SetLabel(subCol.txt_Info, UTL.String.FormatCombineTextByID(talentPointData.Desc_3)) if idx <= curLearnPoint then -- 已点亮 subCol.state_Info:SetState(2) else subCol.state_Info:SetState(0) end end end end function UIGodBeastInfo:InitAttr(isBase) -- 设置战力fight if not self.group_AttrList[1] then self:InstantiateCollection(self.group_AttrList, self.group_AttrList[1].gameObject) end UIUtils.SetActive(self.group_AttrList[1].gameObject, true) UTL.Attr.SetAttrItemByCompName(self.group_AttrList[1], 0, MDL.GodBeast.GetGodBeastDevelopGSByID(self.config.ID), true) local attrTable if isBase then attrTable = MDL.GodBeast.GetBeastAttrList(self.config.ID) else attrTable = self.activeBeastInfo.attr end local index = 2 for attrType, attrNum in ipairs(attrTable) do if attrNum > 0 then local attrObj = self.group_AttrList[index] if not attrObj then attrObj = self:InstantiateCollection(self.group_AttrList, self.group_AttrList[1].gameObject) end UIUtils.SetActive(attrObj.gameObject, true) UTL.Attr.SetAttrItemByCompName(attrObj, attrType, attrNum, true) index = index + 1 end end end function UIGodBeastInfo:UpdateItemInfo() --激活道具 local config = self.config local costItem = config.Item_Table[1] --目前为1个材料 local count = MDL.Bag.GetItemCount(costItem.ItemID) or 0 if count >= costItem.ItemNum then self.isEnough = true UTL.Item.SetItemCell(self.group_Item.item, costItem.ItemID, UTL.Color.FormatGreenColor(count) .. "/" .. costItem.ItemNum) else self.isEnough = false UTL.Item.SetItemCell(self.group_Item.item, costItem.ItemID, UTL.Color.FormatRedColor(count) .. "/" .. costItem.ItemNum) end self.btn_Act:SetRedPoint(self.isEnough) self.btn_Act:SetGray(not self.isEnough, true) end function UIGodBeastInfo:OnButtonClicked(comp) if comp == self.btn_Act then --激活 if self.isEnough then MDL.GodBeast.GodBeastActivateReq(self.config.ID) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Horse_Information_6"]) end elseif comp == self.group_Item.item.event_Click then UTL.ItemTips.ShowCommonTipsById(self.config.Item_Table[1].ItemID) end end return UIGodBeastInfo