--[[ 自选礼包界面 ]] local UISelectReward = UIViewClass() local SELECTED_YELLOW_STR = "e8d588" function UISelectReward:OnCreated() self.totalGiftCount = 0; self.leftGiftCount = 0; self.itemSelectCount = {}; self.giftBagItemCfgId = 0; self.keyBoardView = nil self.isSelectMax = false self.isSelectMin = false --防止频繁从C#获取国际化字符串 self.selectGiftCountStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Bag_Tips_UseNum"]); self.notActiveStr = UTL.Color.GetColorfulText("AEB0B6","IDS_Bag_GiftBag_ChooseGet_NotActive") self.activeStr = UTL.Color.GetColorfulText("00FF00","IDS_Store_Opt_Activated") self.hasCountStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Bag_Possess"]); self.maxLevelStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Bag_GiftBag_ChooseGet_MaxBreak"]); -- self.canUpdateStr = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Bag_GiftBag_ChooseGet_EnableBreak"]); end function UISelectReward:OnOpened(context) self:InitData(context) end function UISelectReward:InitData(context) self.giftBagItemCfgId = context.data; self.totalGiftCount = MDL.Bag.GetItemCount(self.giftBagItemCfgId); UIUtils.SetLabel(self.UICommonPopUp.txt_Title, UTL.Item.GetItemColorName(self.giftBagItemCfgId)); self.giftbagUseCfg = DataSheetManager.UseableItem:GetDataByUseableID(self.giftBagItemCfgId); if self.giftbagUseCfg.UseableType == LuaConst.ItemGiftBagSelectType.HeroFilter then self.totalGiftCount = 1 --最多只能使用1个 end self.leftGiftCount = self.totalGiftCount; UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, 0, self.totalGiftCount)); local giftBagItemData = CTL.Bag.GetGiftBagItemData(self.giftbagUseCfg) for i, itemID in ipairs(giftBagItemData) do local itemCfgData = DataSheetManager.ItemData:GetDataByID(itemID) if itemCfgData.FirstType == LuaConst.ItemType.Appearance then if itemCfgData.SecondType == MDL.Appearance.AppearanceType.Horse then self.Loop_RewardSelection:AddData(i, 0) else self.Loop_RewardSelection:AddData(i, 1) end else self.Loop_RewardSelection:AddData(i, 0) end end self.btn_Challenge:SetGray(self.leftGiftCount == self.totalGiftCount, true); end function UISelectReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISelectReward:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView(); elseif comp == self.btn_Challenge then if self.totalGiftCount == self.leftGiftCount then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Bag_ChooseItem_Tips_NeedChoose"]); return; end local selectData = {}; if self.giftbagUseCfg.UseableType == LuaConst.ItemGiftBagSelectType.HeroFilter then for i, itemId in ipairs(self.giftbagUseCfg.GiftBagItemID) do if self.itemSelectCount[itemId] and self.itemSelectCount[itemId] > 0 then local itemCfgData = DataSheetManager.ItemData:GetDataByID(itemId) local heroId = itemCfgData.BelongToHero selectData[heroId] = {itemId = itemId, selectCount = self.itemSelectCount[itemId], itemCount = self.giftbagUseCfg.GiftBagItemNum[i]}; break end end else for i, itemId in ipairs(self.giftbagUseCfg.GiftBagItemID) do if self.itemSelectCount[itemId] and self.itemSelectCount[itemId]>0 then selectData[i] = {itemId = itemId, selectCount = self.itemSelectCount[itemId], itemCount = self.giftbagUseCfg.GiftBagItemNum[i]}; end end end UIManager.OpenView(Const_UI_Lua.UIEnum.UIBagSelectionConfirm, {giftItemId = self.giftBagItemCfgId, useCount = self.totalGiftCount-self.leftGiftCount, data = selectData}); end end function UISelectReward:GetItemData(index) local itemCfgData = DataSheetManager.ItemData:GetDataByID(self.giftbagUseCfg.GiftBagItemID[index]) return itemCfgData, self.giftbagUseCfg.GiftBagItemID[index], self.giftbagUseCfg.GiftBagItemNum[index] end function UISelectReward:OnCellInit(scrollRect, index, cellTable, data) local itemCfgData, itemID, itemNum = self:GetItemData(data) local hasSelectCount = self.itemSelectCount[itemID] and self.itemSelectCount[itemID] or 0; self.itemSelectCount[itemID] = hasSelectCount; if hasSelectCount > 0 then -- 选择数量大于0时加选中框 UIUtils.SetActive(cellTable.Img_Selected, true) UIUtils.SetLabel(cellTable.txt_NumSelect, UTL.Color.FormatTextByColor(SELECTED_YELLOW_STR, hasSelectCount)); else UIUtils.SetActive(cellTable.Img_Selected, false) UIUtils.SetLabel(cellTable.txt_NumSelect, hasSelectCount); end UIUtils.SetActive(cellTable.mask, false) cellTable.event_Minus:SetGray(hasSelectCount<=0); cellTable.event_Plus:SetGray(self.leftGiftCount<=0); if itemCfgData.FirstType == LuaConst.ItemType.Appearance then if itemCfgData.SecondType == MDL.Appearance.AppearanceType.Hero then self:SetHeroAppearanceCellData(cellTable, itemID) elseif itemCfgData.SecondType == MDL.Appearance.AppearanceType.Weapon then self:SetWeaponAppearanceCellData(cellTable, itemID) elseif itemCfgData.SecondType == MDL.Appearance.AppearanceType.Horse then self:SetHorseAppearanceCellData(cellTable, itemID, itemCfgData) end else UIUtils.SetActive(cellTable.Item.gameObject, true) UIUtils.SetLabel(cellTable.txt_ItemName, UTL.Item.GetItemColorName(itemID)); UTL.Item.SetItemCell(cellTable.Item, itemID, itemNum); if itemCfgData.FirstType == LuaConst.ItemType.HeroFragment and itemCfgData.SecondType == LuaConst.ItemHeroType.HeroFragment then self:SetHeroFragmentCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.HeroFragment and itemCfgData.SecondType == LuaConst.ItemHeroType.Hero then self:SetHeroCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.Equip then self:SetEquipCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.EquipDebris then self:SetEquipDebrisCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.WeaponFragment then self:SetWeaponFragmentCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.Horse then self:SetHorseCellData(cellTable, itemID, itemCfgData); elseif itemCfgData.FirstType == LuaConst.ItemType.Treasure then self:SetTreasureCellData(cellTable, itemID, itemCfgData); else self:SetBagCellData(cellTable, itemID, itemCfgData); end end end function UISelectReward:SetBagCellData(cellTable, giftBagItemID, itemCfgData) UIUtils.SetActive(cellTable.img_ActivationFrame, true) local hasItemCount = 0 if itemCfgData.FirstType == LuaConst.ItemType.HorseSoul then for i, v in ipairs(MDL.HorseSoul.GetSoulItemList()) do local soulInfo = MDL.HorseSoul.GetSoulInfoById(v) if soulInfo.itemData.ID == giftBagItemID then hasItemCount = hasItemCount + 1 end end else hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); end local isActive = false if itemCfgData.FirstType == LuaConst.ItemType.Portrait then local portraitData = MDL.Character.GetPortraitDataByItemId(itemCfgData.ID) isActive = MDL.Character.IsActiveByInfo(portraitData) UIUtils.SetActive(cellTable.mask, hasItemCount > 0 or isActive) elseif itemCfgData.FirstType == LuaConst.ItemType.Frame then local frameData = MDL.Character.GetFrameDataByItemId(itemCfgData.ID) isActive = MDL.Character.IsActiveByInfo(frameData) UIUtils.SetActive(cellTable.mask, hasItemCount > 0 or isActive) elseif itemCfgData.FirstType == LuaConst.ItemType.Title then local titleData = CTL.Title.GetTitleDataByItemId(itemCfgData.ID) isActive = MDL.Title.HasTitleByGeneralTitleID(titleData.ID) UIUtils.SetActive(cellTable.mask, hasItemCount > 0 or isActive) elseif itemCfgData.FirstType == LuaConst.ItemType.GiftBag and itemCfgData.ThirdType == LuaConst.ItemGiftBagThirdType.GiftChooseGiftBag then isActive = self:IsGiftChooseGiftBagOwned(itemCfgData.ID) else UIUtils.SetActive(cellTable.img_ActivationFrame, false) end if isActive then UIUtils.SetLabel(cellTable.txt_Unactivated, self.activeStr) else UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr) end UIUtils.SetActive(cellTable.img_InUse, false); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); end function UISelectReward:IsGiftChooseGiftBagOwned(itemID) local giftRewardGetData = DataSheetManager.GiftRewardGet:GetDataByGiftID(itemID).Item_Table for _, item in ipairs(giftRewardGetData) do local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(item.ItemID) if hasItemCount > 0 then return true end local itemCfgData = DataSheetManager.ItemData:GetDataByID(item.ItemID) if itemCfgData.SecondType == MDL.Appearance.AppearanceType.Hero then local appearanceCfgId = MDL.Appearance.GetAppearanceCfgIdByItemId(item.ItemID) local appearanceCfg = DataSheetManager.HeroAppearance:GetDataByID(appearanceCfgId) local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(appearanceCfg.HeroID, appearanceCfgId, MDL.Appearance.AppearanceType.Hero) if appearanceData.isActive then return true end elseif itemCfgData.SecondType == MDL.Appearance.AppearanceType.Weapon then local appearanceCfgId = MDL.Appearance.GetAppearanceCfgIdByItemId(item.ItemID) local appearanceCfg = DataSheetManager.WeaponAppearance:GetDataByID(appearanceCfgId) local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(appearanceCfg.HeroID, appearanceCfgId, MDL.Appearance.AppearanceType.Weapon) if appearanceData.isActive then return true end end end return false end function UISelectReward:SetHeroFragmentCellData(cellTable, itemID, itemCfgData) local needCount = 0; local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(itemID); local heroId = CTL.Bag.GetHeroCfgIdByItemId(itemID); UIUtils.SetActive(cellTable.img_InUse, CTL.Formation.IsHeroInFormation(heroId)); local heroInfo = MDL.HeroSelect.GetHeroInfo(heroId); if not heroInfo then UIUtils.SetActive(cellTable.img_ActivationFrame, true); needCount = DataSheetManager.HeroNum:GetDataByID(heroId).UnlockPiece; UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); elseif CTL.HeroStar.IsHeroReachMaxStar(heroId) then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetLabel(cellTable.txt_Unactivated, self.maxLevelStr); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); else UIUtils.SetActive(cellTable.img_ActivationFrame, false); needCount = self:GetHeroBreakCount(heroId, itemID); -- UIUtils.SetLabel(cellTable.txt_Unactivated, self.canUpdateStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); end end function UISelectReward:GetHeroBreakCount(heroCfgId, itemCfgId) local returnCount = 0; local heroInfo = MDL.HeroSelect.GetHeroInfo(heroCfgId) if heroInfo then local curStarConfig = DataSheetManager.HeroStar:GetDataByHeroID_Star(heroCfgId, heroInfo.starLevel); for i=heroInfo.starStage + 1, #curStarConfig.Item_Table do local nextStarStageBreakCost = DataSheetManager.HeroStarItemRepeat:GetDataByItemRepeatID(curStarConfig.Item_Table[i].ItemRepeat).Item_Table; if nextStarStageBreakCost then for __, costData in ipairs(nextStarStageBreakCost) do if costData.ItemID == itemCfgId then returnCount = returnCount + costData.ItemNum; end end end end end return returnCount; end function UISelectReward:SetHeroCellData(cellTable, giftBagItemID, itemCfgData) local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, CTL.Formation.IsHeroInFormation(itemCfgData.BelongToHero)); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); local isActive = false if DataSheetManager.UseableItem:GetDataByUseableID(self.giftBagItemCfgId).UseableType == LuaConst.ItemGiftBagSelectType.HeroFilter then isActive = MDL.HeroSelect.IsHasHero(itemCfgData.BelongToHero) end if isActive then UIUtils.SetActive(cellTable.mask, true) UIUtils.SetActive(cellTable.img_ActivationFrame, true) UIUtils.SetLabel(cellTable.txt_Unactivated, self.activeStr) else UIUtils.SetActive(cellTable.mask, false) UIUtils.SetActive(cellTable.img_ActivationFrame, false) end end function UISelectReward:SetEquipCellData(cellTable, giftBagItemID, itemCfgData) local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, false); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); end function UISelectReward:SetEquipDebrisCellData(cellTable, giftBagItemID, itemCfgData) local needCount = 0; local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); --装备碎片 UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, false); local equipId = CTL.Bag.GetEquipCfgIdByItemId(giftBagItemID); needCount = DataSheetManager.EquipData:GetDataByID(equipId).ItemNum; if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); end function UISelectReward:SetWeaponFragmentCellData(cellTable, giftBagItemID, itemCfgData) local needCount = 0; local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); local magicWeaponCfgId = CTL.Bag.GetMagicWeaponCfgIdByItemId(giftBagItemID); local heroInfo = MDL.HeroSelect.GetHeroInfo(magicWeaponCfgId); if heroInfo and heroInfo.isMagicWeaponActive then UIUtils.SetActive(cellTable.img_InUse, CTL.Formation.IsHeroInFormation(magicWeaponCfgId)); --区分下铸图还是神兵 if itemCfgData.SecondType == LuaConst.ItemWeaponType.WeaponFragment then --神兵碎片 if heroInfo.magicWeaponLevel == MDL.DivineWeapon.GetBreakMax(magicWeaponCfgId) then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetLabel(cellTable.txt_Unactivated, self.maxLevelStr); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); else UIUtils.SetActive(cellTable.img_ActivationFrame, false); needCount = self:GetMagicWeaponBreakCount(magicWeaponCfgId, giftBagItemID); -- UIUtils.SetLabel(cellTable.txt_Unactivated, self.canUpdateStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)) end else UIUtils.SetActive(cellTable.img_ActivationFrame, false) UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); end else UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, false); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); end end function UISelectReward:GetMagicWeaponBreakCount(magicWeaponCfgId, itemCfgId) local returnCount = 0; local heroInfo = MDL.HeroSelect.GetHeroInfo(magicWeaponCfgId) if heroInfo then local curStarConfig = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(magicWeaponCfgId, heroInfo.magicWeaponLevel); for i=heroInfo.magicWeaponStar + 1, #curStarConfig.Item_Table do local nextStarStageBreakCost = DataSheetManager.MagicWeaponStarItem:GetDataByItemRepeatID(curStarConfig.Item_Table[i].ItemRepeat).Item_Table; if nextStarStageBreakCost then for __, costData in ipairs(nextStarStageBreakCost) do if costData.ItemID == itemCfgId then returnCount = returnCount + costData.ItemNum; end end end end end return returnCount; end function UISelectReward:SetHorseCellData(cellTable, giftBagItemID) local needCount = 0; local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); local warHorseCfgId = CTL.Bag.GetWarHorseCfgIdByItemId(giftBagItemID); local warHorseData = MDL.WarHorse.GetInfoByID(warHorseCfgId); local warHorseCfgData = DataSheetManager.HorseData:GetDataByHorseID(warHorseCfgId); if not warHorseData then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetActive(cellTable.img_InUse, false); for __, costData in ipairs(warHorseCfgData.Item_Table) do if costData.ItemID == giftBagItemID then needCount = costData.ItemNum; end end UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); elseif not CTL.WarHorse.GetNextBreakItemConfig(warHorseCfgId) then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetActive(cellTable.img_InUse, warHorseData.HeroID and warHorseData.HeroID>0 or false); UIUtils.SetLabel(cellTable.txt_Unactivated, self.maxLevelStr); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); else UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, warHorseData.HeroID and warHorseData.HeroID>0 or false); needCount = self:GetHorseBreakCount(warHorseCfgId, giftBagItemID); -- UIUtils.SetLabel(cellTable.txt_Unactivated, self.canUpdateStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); end end function UISelectReward:GetHorseBreakCount(horseCfgId, itemCfgId) local returnCount = 0; local horseInfo = MDL.WarHorse.GetInfoByID(horseCfgId); if horseInfo and horseInfo.HorseInfo then local curStarConfig = DataSheetManager.HorseStar:GetDataByHorseID_Star(horseCfgId, horseInfo.HorseInfo.starLevel); for i=horseInfo.HorseInfo.starStage + 1, #curStarConfig.ItemRepeat do local nextStarStageBreakCost = DataSheetManager.HorseStarItem:GetDataByItemRepeatID(curStarConfig.ItemRepeat[i]).Item_Table; if nextStarStageBreakCost then for __, costData in ipairs(nextStarStageBreakCost) do if costData.ItemID == itemCfgId then returnCount = returnCount + costData.ItemNum; end end end end end return returnCount; end function UISelectReward:SetTreasureCellData(cellTable, giftBagItemID, itemCfgData) local needCount = 0; local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID); local treasureCfgId = CTL.Bag.GetTreasureCfgIdByItemId(giftBagItemID); local treasureData = MDL.Treasure.GetTreasureInfo(treasureCfgId); local treasureCfgData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureCfgId); if not treasureData then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetActive(cellTable.img_InUse, false); for __, costData in ipairs(treasureCfgData.Item_Table) do if costData.ItemID == giftBagItemID then needCount = costData.ItemNum; end end UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); elseif not CTL.Treasure.GetNextBreakItemData(treasureCfgId) then UIUtils.SetActive(cellTable.img_ActivationFrame, true); UIUtils.SetActive(cellTable.img_InUse, treasureData.EquipHeroId and treasureData.EquipHeroId>0 or false); UIUtils.SetLabel(cellTable.txt_Unactivated, self.maxLevelStr); UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)); else UIUtils.SetActive(cellTable.img_ActivationFrame, false); UIUtils.SetActive(cellTable.img_InUse, treasureData.EquipHeroId and treasureData.EquipHeroId>0 or false); needCount = self:GetTreasureBreakCount(treasureCfgId, giftBagItemID); -- UIUtils.SetLabel(cellTable.txt_Unactivated, self.canUpdateStr); if hasItemCount >= needCount then hasItemCount = UTL.Color.FormatTextByColor(UTL.Color.Green, hasItemCount) end UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s/%s", self.hasCountStr, hasItemCount, needCount)); end end function UISelectReward:GetTreasureBreakCount(treasureCfgId, itemCfgId) local returnCount = 0; local treasureinfo = MDL.Treasure.GetTreasureInfo(treasureCfgId) if treasureinfo and treasureinfo.TreasureInfo then local curStarConfig = DataSheetManager.TreasureStar:GetDataByTreasureID_Star(treasureCfgId, treasureinfo.TreasureInfo.starLevel); for i=treasureinfo.TreasureInfo.starStage + 1, #curStarConfig.ItemRepeat do local nextStarStageBreakCost = DataSheetManager.TreasureStarItem:GetDataByItemRepeatID(curStarConfig.ItemRepeat[i]).Item_Table; if nextStarStageBreakCost then for __, costData in ipairs(nextStarStageBreakCost) do if costData.ItemID == itemCfgId then returnCount = returnCount + costData.ItemNum; end end end end end return returnCount; end function UISelectReward:SetHorseAppearanceCellData(cellTable, giftBagItemID) UIUtils.SetActive(cellTable.img_ActivationFrame, true); local appearanceCfgId = MDL.WarHorse.GetAppearanceDataByItemID(giftBagItemID).ID local activeState = MDL.WarHorse.GetOwnType(appearanceCfgId) local isCurNotActive = activeState == MDL.WarHorse.OwnedType.UnOwned or activeState == MDL.WarHorse.OwnedType.Overdue if isCurNotActive then UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr) else UIUtils.SetLabel(cellTable.txt_Unactivated, self.activeStr) end local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID) UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)) UIUtils.SetActive(cellTable.mask, hasItemCount > 0 or not isCurNotActive) UIUtils.SetActive(cellTable.Item.gameObject, true) UIUtils.SetLabel(cellTable.txt_ItemName, UTL.Item.GetItemColorName(giftBagItemID)); UTL.Item.SetItemCell(cellTable.Item, giftBagItemID); end function UISelectReward:SetHeroAppearanceCellData(cellTable, giftBagItemID) UIUtils.SetActive(cellTable.hero_AppearanceIcon, true); UIUtils.SetActive(cellTable.weapon_AppearanceIcon, false); local appearanceCfgId = MDL.Appearance.GetAppearanceCfgIdByItemId(giftBagItemID) local appearanceCfg = DataSheetManager.HeroAppearance:GetDataByID(appearanceCfgId) local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(appearanceCfg.HeroID, appearanceCfgId, MDL.Appearance.AppearanceType.Hero) if appearanceData.isActive then UIUtils.SetLabel(cellTable.txt_Unactivated, self.activeStr) else UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr) end local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID) UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)) -- 背景图 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceBg, appearanceCfg.HeroQuality, UTL.Color.QualityType.AppearanceInfoBase) -- 外观框 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceFrame,appearanceCfg.HeroQuality, UTL.Color.QualityType.AppearanceBase_Frame) -- 半身立绘 UIUtils.SetImageByAssetBundle(cellTable.hero_AppearanceIcon, appearanceCfg.PreviewCardImage) -- 皮肤名 UIUtils.SetLabelText(cellTable.txt_AppearanceName, Const_IDS[appearanceCfg.AppearanceName]) -- 特效 cellTable.effect_HeroAppearance:StopUIEffect() UTL.Color.PlayQualityEffect(cellTable.effect_HeroAppearance, appearanceCfg.EffectID, UTL.Color.EffectType.Skin) end function UISelectReward:SetWeaponAppearanceCellData(cellTable, giftBagItemID) UIUtils.SetActive(cellTable.hero_AppearanceIcon, false); UIUtils.SetActive(cellTable.weapon_AppearanceIcon, true); local appearanceCfgId = MDL.Appearance.GetAppearanceCfgIdByItemId(giftBagItemID) local appearanceCfg = DataSheetManager.WeaponAppearance:GetDataByID(appearanceCfgId) local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(appearanceCfg.HeroID, appearanceCfgId, MDL.Appearance.AppearanceType.Weapon) if appearanceData.isActive then UIUtils.SetLabel(cellTable.txt_Unactivated, self.activeStr) else UIUtils.SetLabel(cellTable.txt_Unactivated, self.notActiveStr) end local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(giftBagItemID) UIUtils.SetLabel(cellTable.txt_GiftInStock, string.format("%s: %s", self.hasCountStr, hasItemCount)) -- 背景图 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceBg, appearanceCfg.MagicWeaponQuality, UTL.Color.QualityType.AppearanceInfoBase) -- 外观框 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceFrame,appearanceCfg.MagicWeaponQuality, UTL.Color.QualityType.AppearanceBase_Frame) -- 半身立绘 UIUtils.SetImageByAssetBundle(cellTable.weapon_AppearanceIcon, appearanceCfg.PreviewCardImage) -- 皮肤名 UIUtils.SetLabelText(cellTable.txt_AppearanceName, Const_IDS[appearanceCfg.AppearanceName]) -- 特效 cellTable.effect_WeaponAppearance:StopUIEffect() UTL.Color.PlayQualityEffect(cellTable.effect_WeaponAppearance, appearanceCfg.EffectID, UTL.Color.EffectType.Skin) end function UISelectReward:OnCellClicked(scrollRect, index, cellTable, target, data) local itemCfgData, itemID, itemNum = self:GetItemData(data) if target == cellTable.event_Minus then self.isSelectMax = false self.isSelectMin = false self.itemSelectCount[itemID] = self.itemSelectCount[itemID]-1; self.leftGiftCount = self.leftGiftCount+1; self.Loop_RewardSelection:RefreshCells(); UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)); elseif target == cellTable.event_Plus then if (itemCfgData.FirstType == LuaConst.ItemType.Appearance and itemCfgData.SecondType == MDL.Appearance.AppearanceType.Horse) or itemCfgData.FirstType == LuaConst.ItemType.Portrait or itemCfgData.FirstType == LuaConst.ItemType.Frame or itemCfgData.FirstType == LuaConst.ItemType.Title then self:ChooseMaxOne(itemID) else self.isSelectMax = false self.isSelectMin = false self.itemSelectCount[itemID] = self.itemSelectCount[itemID]+1; self.leftGiftCount = self.leftGiftCount-1; self.Loop_RewardSelection:RefreshCells(); UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)); end elseif target == cellTable.event_Max and not self.isSelectMax then if (itemCfgData.FirstType == LuaConst.ItemType.Appearance and itemCfgData.SecondType == MDL.Appearance.AppearanceType.Horse) or itemCfgData.FirstType == LuaConst.ItemType.Portrait or itemCfgData.FirstType == LuaConst.ItemType.Frame or itemCfgData.FirstType == LuaConst.ItemType.Title then --最多选择一个 self:ChooseMaxOne(itemID) else self.isSelectMin = false self.isSelectMax = true self.itemSelectCount[itemID] = self.itemSelectCount[itemID] + self.leftGiftCount self.leftGiftCount = 0 self.Loop_RewardSelection:RefreshCells() UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)) end elseif target == cellTable.event_Min and not self.isSelectMin then self.isSelectMax = false self.isSelectMin = true self.leftGiftCount = self.leftGiftCount + self.itemSelectCount[itemID] self.itemSelectCount[itemID] = 0 self.Loop_RewardSelection:RefreshCells() UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)) elseif cellTable.Item and target == cellTable.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(itemID, false); elseif target == cellTable.apperance_event_Click then UTL.ItemTips.ShowCommonTipsById(itemID, false) elseif target == cellTable.event_Count then if not self.keyBoardView then local eventClickPos = self:GetCountTextPos(cellTable.event_Count.transform.position); local maxNum if itemCfgData.FirstType == LuaConst.ItemType.Appearance and itemCfgData.SecondType == MDL.Appearance.AppearanceType.Horse then maxNum = 1 --坐骑外观最多选择一个 else maxNum = self.leftGiftCount+self.itemSelectCount[itemID] end self.keyBoardView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIKeypad), {parentView = self, callBackParam = data, x = eventClickPos.x+70, y = 200, minNum = 0, maxNum = maxNum}, nil, nil); end elseif target == cellTable.mask then if self.giftbagUseCfg.UseableType == LuaConst.ItemGiftBagSelectType.HeroFilter then CTL.Tips.AddTipsMsg(Const_IDS["IDS_New_GoldHeroGift_Tips"]); else CTL.Tips.AddTipsMsg(Const_IDS["IDS_ItemAlreadyGot"]); end end self.btn_Challenge:SetGray(self.leftGiftCount == self.totalGiftCount, true); end --最多选择一个(坐骑外观) function UISelectReward:ChooseMaxOne(itemID) self.isSelectMin = false if self.itemSelectCount[itemID] == 0 and self.leftGiftCount > 0 then self.itemSelectCount[itemID] = self.itemSelectCount[itemID] + 1 self.leftGiftCount = self.leftGiftCount - 1 self.Loop_RewardSelection:RefreshCells() UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_MaxChosenNum"]); end self.isSelectMax = self.leftGiftCount == 0 end function UISelectReward:ExcuteKeyBoardBack(count, paramData) self:SetSelectCount(paramData, count) self.isSelectMax = false self.isSelectMin = false end function UISelectReward:CloseKeyBoardView() self.keyBoardView:CloseView() self.keyBoardView = nil end function UISelectReward:GetCountTextPos(countTextPos) return self.gameObject.transform:InverseTransformVector(countTextPos); end function UISelectReward:SetSelectCount(data, count) local _, itemID, _ = self:GetItemData(data) self.leftGiftCount = self.leftGiftCount - (count - self.itemSelectCount[itemID]); self.itemSelectCount[itemID] = count; self.Loop_RewardSelection:RefreshCells(); UIUtils.SetLabel(self.txt_SelectedAmount, string.format(self.selectGiftCountStr, self.totalGiftCount-self.leftGiftCount, self.totalGiftCount)); end return UISelectReward