local UIWarHorseInfo = UIViewClass() function UIWarHorseInfo:OnOpened(config) self:RegistSystemEvent(EventID.BagItem_Update, self.UpdateItemInfo) self:UpdateInfo(config) end function UIWarHorseInfo:UpdateInfo(config) self.config = config UIUtils.SetLabel(self.txt_WarHorse, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[config.HorseName]), config.HorseQuality)) UIUtils.SetLabel(self.txt_WarHorseTalent, config.HorseTalent) local index = 0 --属性数量 local activeInfo = MDL.WarHorse.GetInfoByID(config.HorseID) if activeInfo then self.obj_state:SetState(0) UIUtils.SetLabel(self.txt_Break, string.FormatByIdsId(Const_IDS.IDS_Horse_Star_2, activeInfo.HorseInfo.starLevel)) --战力 UTL.Attr.SetAttrItemByCompName(self.group_AttrList[1], 0, activeInfo.HorseInfo.gs, true) index = 1 --属性 for i = 1, 3 do local v = activeInfo.HorseInfo.attr.attrs[i] index = index + 1 UIUtils.SetActive(self.group_AttrList[index].gameObject, true) UTL.Attr.SetAttrItemByCompName(self.group_AttrList[index], i, math.floor(v + 0.5), true) end self.scroll_Content:SetSizeDelta(631, 360) else self.obj_state:SetState(1) --战力 local fight = UTL.Attr.CalculateFight(config.Attr_Table) UTL.Attr.SetAttrItemByCompName(self.group_AttrList[1], 0, fight, true) index = 1 --属性 for i = 1, 3 do index = index + 1 UIUtils.SetActive(self.group_AttrList[index].gameObject, true) UTL.Attr.SetAttrItemByCompName(self.group_AttrList[index], config.Attr_Table[i].AttrType, config.Attr_Table[i].AttrNum, true) end --激活道具 self:UpdateItemInfo() self.scroll_Content:SetSizeDelta(631, 140) end --速度 local horseModeData = DataSheetManager.HorseModelData:GetDataByHorseModelID(config.HorseModelID) local horseMoveData = DataSheetManager.HorseMoveData:GetDataByID(horseModeData.MoveID) local speed = math.floor(FP.tonumberV1(horseMoveData.MaxSpd * horseMoveData.SpdGear) * 10) index = index + 1 local speedCell = self.group_AttrList[index] UTL.Item.SetAtlasSprite(speedCell.img_Attr, "UI_Common", UTL.Attr.SpecialAttr.Speed) UIUtils.SetLabelText(speedCell.lab_Attr, Const_IDS["IDS_Horse_Information_4"]) speedCell.txt_Attr.text = speed UIUtils.SetLabelText(self.txt_Introduce01, Const_IDS[config.HorseDes]) --描述 end function UIWarHorseInfo: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 UIWarHorseInfo:OnButtonClicked(comp) if comp == self.event_BackTown then self:CloseView() elseif comp == self.btn_Act then --激活 if self.isEnough then MDL.WarHorse.HorseActiveRequest(self.config.HorseID) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Horse_Information_6"]) end elseif comp == self.event_Attr then UIManager.OpenView(Const_UI_Lua.UIEnum.UIWarHorseAttrInfoView, {horseId = self.config.HorseID}, Const_UI_Lua.UIEnum.UITreasureInfoView) elseif comp == self.group_Item.item.event_Click then UTL.ItemTips.ShowCommonTipsById(self.config.Item_Table[1].ItemID) elseif self.btn_Enlarge == comp then CTL.WarHorse.OpenPreviewPanel(self.config.HorseID) end end return UIWarHorseInfo