local UIRebornRecast = UIViewClass() --越南地区修改背景板高度 local RecastSecondHeightVN = 400 function UIRebornRecast:OnOpened(context) self:RegistSystemEvent(EventID.UI_Reborn_Recast_RecastSuccess, self.InitRecastDataListByIndex) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshSelectRecastCost) self:RegistSystemEvent(EventID.UI_Shop_Refresh_Currency, self.RefreshSelectRecastCost) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshSelectRecastCost) self.selectId = nil self.costEnough = false self.type = MDL.Reborn.RebornType.Hero if context and context.RecastType then self.type = context.RecastType end for i = 1, 6 do if GameAppInfo.IsVietnamPackage() and i == 5 then --越南地区屏蔽坐骑魂珠的显示入口 else self.loop_Tab:AddData({state = i-1}, 0) end end self:InitRecastDataListByIndex(self.type) self:RefreshSwitchTabListStatus(false) CTL.Currency.OpenCurrencyPanel(self.__viewClassPath, self.currency_Info) self:UIAdjustRegion() end function UIRebornRecast:RefreshSwitchTabListStatus(flag) UIUtils.SetActive(self.btn_Close.gameObject, flag) UIUtils.SetActive(self.group_RecastSecondTab, flag) if flag then self.RecastTab.state_Arrow:SetState(1) else self.RecastTab.state_Arrow:SetState(0) end end function UIRebornRecast:OnButtonClicked(comp) if comp == self.btn_Recast then if self.selectId then if self.costEnough then if (self.type == MDL.Reborn.RebornType.Hero or self.type == MDL.Reborn.RebornType.Weapon) and CTL.HeroAwaken.IsEnableAwake(self.selectId) then local heroNameIDS = DataSheetManager.HeroNum:GetDataByID(self.selectId).NameIDS UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_EquipMelting_Rebirth_Title, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_UnAwaken, UIUtils.GetLocalizedTxt(Const_IDS[heroNameIDS])), function() MDL.Reborn.RecastReq(self.type, tonumber(self.selectId)) end) else MDL.Reborn.RecastReq(self.type, tonumber(self.selectId)) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_Rebirth_ShortHint) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_1) end elseif comp == self.RecastTab.img_Selected then self:RefreshSwitchTabListStatus(true) self.loop_Tab:RefreshCells(false) elseif comp == self.btn_Close then self:RefreshSwitchTabListStatus(false) end end function UIRebornRecast:InitRecastDataListByIndex(index) self.type = index or self.type self.RecastTab.state_RecastTab:SetState(self.type) self.selectId = nil self.costEnough = false if self.loop_RecastList.Count > 0 then self.loop_RecastList:ClearCells() end for i, v in ipairs(MDL.Reborn.GetRecastDataListByType(self.type)) do self.loop_RecastList:AddData(v, 0) end UIUtils.SetActive(self.img_Empty, self.loop_RecastList.Count == 0) self:RefreshSelectRecastInfo() end function UIRebornRecast:RefreshSelectRecastInfo() local isHasSelect = self.selectId and true or false UIUtils.SetActive(self.img_ChooseItem, not isHasSelect) UIUtils.SetActive(self.group_RecastInfo, isHasSelect) UIUtils.SetActive(self.group_Cost, isHasSelect) self.btn_Recast:SetGray(not isHasSelect, true) if isHasSelect then self.effect_SparkTrace:PlayUIEffect() else self.effect_SparkTrace:StopUIEffect() end if isHasSelect then local RebornTypeEnum = MDL.Reborn.RebornType UIUtils.SetActive(self.item_Before.group_Level, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(self.item_Before.group_Position, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(self.item_Before.group_Star.gameObject, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(self.item_After.group_Level, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(self.item_After.group_Position, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(self.item_After.group_Star.gameObject, self.type == RebornTypeEnum.HorseSoul) if self.type == RebornTypeEnum.Hero then local heroId = self.selectId local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) local heroQuality = heroData.HeroQuality local heroName = UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]) self.txt_NameBefore.text = UTL.Color.FormatQualityText(heroName .. "+" .. MDL.HeroStar.GetHeroStarLevel(heroId), heroQuality) self.txt_NameAfter.text = UTL.Color.FormatQualityText(heroName .. "+" .. heroData.RebirthStarLevel, heroQuality) self:SetIcon(self.type, heroId, self.item_Before) self:SetIcon(self.type, heroId, self.item_After) elseif self.type == RebornTypeEnum.Weapon then local heroId = self.selectId local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(heroId) local weaponQuality = weaponData.MagicWeaponQuality local weaponName = UIUtils.GetLocalizedTxt(Const_IDS[weaponData.MagicWeaponName]) self.txt_NameBefore.text = UTL.Color.FormatQualityText(weaponName .. "+" .. MDL.HeroSelect.GetHeroInfo(heroId).magicWeaponLevel, weaponQuality) self.txt_NameAfter.text = UTL.Color.FormatQualityText(weaponName .. "+" .. weaponData.RebirthStarLevel, weaponQuality) self:SetIcon(self.type, heroId, self.item_Before) self:SetIcon(self.type, heroId, self.item_After) elseif self.type == RebornTypeEnum.Horse then local horseId = self.selectId local horseData = DataSheetManager.HorseData:GetDataByHorseID(horseId) local horseQuality = horseData.HorseQuality local horseName = UIUtils.GetLocalizedTxt(Const_IDS[horseData.HorseName]) self.txt_NameBefore.text = UTL.Color.FormatQualityText(horseName .. "+" .. MDL.WarHorse.GetInfoByID(horseId).HorseInfo.starLevel, horseQuality) self.txt_NameAfter.text = UTL.Color.FormatQualityText(horseName .. "+" .. horseData.RebirthStarLevel, horseQuality) self:SetIcon(self.type, horseId, self.item_Before) self:SetIcon(self.type, horseId, self.item_After) elseif self.type == RebornTypeEnum.Treasure then local treasureId = self.selectId local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureId) local treasureQuality = treasureData.TreasureQuality local treasureName = UIUtils.GetLocalizedTxt(Const_IDS[treasureData.TreasureName]) self.txt_NameBefore.text = UTL.Color.FormatQualityText(treasureName .. "+" .. MDL.Treasure.GetTreasureInfo(treasureId).TreasureInfo.starLevel, treasureQuality) self.txt_NameAfter.text = UTL.Color.FormatQualityText(treasureName .. "+" .. treasureData.RebirthStarLevel, treasureQuality) self:SetIcon(self.type, treasureId, self.item_Before) self:SetIcon(self.type, treasureId, self.item_After) elseif self.type == RebornTypeEnum.HorseSoul then local horseSoulId = self.selectId local soulInfo = MDL.HorseSoul.GetSoulInfoById(horseSoulId) self:SetIcon(self.type, horseSoulId, self.item_Before) self.item_Before.txt_Level.text = soulInfo.levelInfo.level self.txt_NameBefore.text = UTL.Color.FormatQualityText(UTL.Item.GetItemDataSpliceByType(soulInfo.itemData.ID).Name, soulInfo.itemData.Color) local soulInfo = MDL.HorseSoul.GetSoulInfoById(soulInfo.id) CTL.HorseSoul.SetStarLevel(self.item_Before.group_Star, soulInfo.star) self:SetIcon(self.type, horseSoulId, self.item_After) self.item_After.txt_Level.text = 1 self.txt_NameAfter.text = UTL.Color.FormatQualityText(UTL.Item.GetItemDataSpliceByType(soulInfo.itemData.ID).Name, soulInfo.itemData.Color) CTL.HorseSoul.SetStarLevel(self.item_After.group_Star, 0) elseif self.type == RebornTypeEnum.GodBeast then local godBeastId = self.selectId self:SetIcon(self.type, godBeastId, self.item_Before) self:SetIcon(self.type, godBeastId, self.item_After) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastId) local godBeastName = UIUtils.GetLocalizedTxt(Const_IDS[godBeastData.GodBeastName]) self.txt_NameBefore.text = UTL.Color.FormatQualityText(godBeastName .. "+" .. MDL.GodBeast.GetGodBeastInfoByID(godBeastId).starLevel, godBeastData.GodBeastQuality) self.txt_NameAfter.text = UTL.Color.FormatQualityText(godBeastName .. "+" .. godBeastData.RebirthStarLevel, godBeastData.GodBeastQuality) end self.costEnough = self:RefreshSelectRecastCost() if self.loop_RecastReward.Count > 0 then self.loop_RecastReward:ClearCells() end for i, v in ipairs(MDL.Reborn.GetRecastRewardListByTypeAndId(self.type, self.selectId)) do self.loop_RecastReward:AddData(v, 0) end end end function UIRebornRecast:RefreshSelectRecastCost() local isEnough = false if self.selectId then local costId, costNum = MDL.Reborn.GetRecastCostByTypeAndId(self.type, self.selectId) local hasCount = UTL.Item.GetItemStockCount(costId) UTL.Item.ItemIconWithoutBg(self.img_Currency, costId) isEnough = hasCount >= costNum self.txt_Number.text = isEnough and costNum or UTL.Color.FormatRedColor(costNum) end return isEnough end function UIRebornRecast:SetIcon(type, id, cell) local RebornTypeEnum = MDL.Reborn.RebornType if type == RebornTypeEnum.Hero then local heroItemId = DataSheetManager.HeroNum:GetDataByID(id).HeroItem UTL.Item.ItemSquareIcon(cell.img_Item, cell.sprite_Rank, heroItemId) elseif type == RebornTypeEnum.Weapon then local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(id) local weaponIcon = string.format(MDL.Bag.ItemIconPathTemplete, weaponData.MagicWeaponPicture) UIUtils.SetImageByAssetBundle(cell.img_Item, weaponIcon) UTL.Color.SetQualityImageByType(cell.sprite_Rank, weaponData.MagicWeaponQuality, UTL.Color.QualityType.Square) elseif type == RebornTypeEnum.Horse then local horseData = DataSheetManager.HorseData:GetDataByHorseID(id) UIUtils.SetImageByAssetBundle(cell.img_Item, horseData.HorseIcon) UTL.Color.SetQualityImageByType(cell.sprite_Rank, horseData.HorseQuality, UTL.Color.QualityType.Square) elseif type == RebornTypeEnum.Treasure then local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(id) UIUtils.SetImageByAssetBundle(cell.img_Item, treasureData.TreasureIcon) UTL.Color.SetQualityImageByType(cell.sprite_Rank, treasureData.TreasureQuality, UTL.Color.QualityType.Square) elseif type == RebornTypeEnum.HorseSoul then local soulInfo = MDL.HorseSoul.GetSoulInfoById(id) UTL.Item.ItemSquareIcon(cell.img_Item, cell.sprite_Rank, soulInfo.cfgId) UIUtils.SetActive(cell.group_Position, true) UIUtils.SetActive(cell.group_Level, true) CTL.HorseSoul.SetPositionImage(cell.img_Pos, soulInfo.soulData.HorseSoulPositionID) elseif type == RebornTypeEnum.GodBeast then local beastItem = DataSheetManager.GodBeastData:GetDataByID(id).PieceItem UTL.Item.ItemSquareIcon(cell.img_Item, cell.sprite_Rank, beastItem) end end function UIRebornRecast:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_RecastList then local RebornTypeEnum = MDL.Reborn.RebornType UIUtils.SetActive(cellTable.bg_Break, self.type ~= RebornTypeEnum.HorseSoul) UIUtils.SetActive(cellTable.group_Level, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(cellTable.group_Position, self.type == RebornTypeEnum.HorseSoul) UIUtils.SetActive(cellTable.group_Star.gameObject, self.type == RebornTypeEnum.HorseSoul) if self.type == RebornTypeEnum.Hero then self:SetIcon(self.type, data.heroId, cellTable.item) cellTable.lab_Break.text = "+" .. data.starLevel elseif self.type == RebornTypeEnum.Weapon then self:SetIcon(self.type, data.heroId, cellTable.item) cellTable.lab_Break.text = "+" .. data.magicWeaponLevel elseif self.type == RebornTypeEnum.Horse then self:SetIcon(self.type, data.ID, cellTable.item) cellTable.lab_Break.text = "+" .. data.HorseInfo.starLevel elseif self.type == RebornTypeEnum.Treasure then self:SetIcon(self.type, data.TreasureID, cellTable.item) cellTable.lab_Break.text = "+" .. data.TreasureInfo.starLevel elseif self.type == RebornTypeEnum.HorseSoul then self:SetIcon(self.type, data.id, cellTable.item) cellTable.txt_Level.text = data.levelInfo.level UIUtils.SetActive(cellTable.group_Position, true) CTL.HorseSoul.SetPositionImage(cellTable.img_Pos, data.soulData.HorseSoulPositionID) local soulInfo = MDL.HorseSoul.GetSoulInfoById(data.id) CTL.HorseSoul.SetStarLevel(cellTable.group_Star, soulInfo.star) elseif self.type == RebornTypeEnum.GodBeast then self:SetIcon(self.type, data.godBeastId, cellTable.item) cellTable.lab_Break.text = "+" .. data.starLevel end UIUtils.SetActive(cellTable.img_Selected, false) elseif scrollRect == self.loop_RecastReward then local RebornTypeEnum = MDL.Reborn.RebornType if self.type == RebornTypeEnum.HorseSoul then local itemData = DataSheetManager.ItemData:GetDataByID(data.ItemID) UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) if itemData.FirstType == LuaConst.ItemType.HorseSoul then cellTable.item.txt_Level.text = 1 CTL.HorseSoul.SetStarLevel(cellTable.item.group_Star, 0) end else UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end elseif scrollRect == self.loop_Tab then UIUtils.SetActive(cellTable.img_Selected, self.type == index) cellTable.state_RecastSecondTab:SetState(data.state) end end function UIRebornRecast:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RecastList then if target == cellTable.item.event_Click then local recastId local RebornTypeEnum = MDL.Reborn.RebornType if self.type == RebornTypeEnum.Hero then recastId = data.heroId elseif self.type == RebornTypeEnum.Weapon then recastId = data.heroId elseif self.type == RebornTypeEnum.Horse then recastId = data.ID elseif self.type == RebornTypeEnum.Treasure then recastId = data.TreasureID elseif self.type == RebornTypeEnum.HorseSoul then recastId = data.id elseif self.type == RebornTypeEnum.GodBeast then recastId = data.godBeastId end if self.selectId then if self.selectId == recastId then self.selectId = nil self.costEnough = false else CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_4) -- 已选择重生物品 end else if self.type == RebornTypeEnum.Hero then local heroData = DataSheetManager.HeroNum:GetDataByID(data.heroId) if data.starLevel < heroData.CanRebirthStarLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]), heroData.CanRebirthStarLevel) return end elseif self.type == RebornTypeEnum.Weapon then local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(data.heroId) if data.magicWeaponLevel < weaponData.CanRebirthStarLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[weaponData.MagicWeaponName]), weaponData.CanRebirthStarLevel) return end elseif self.type == RebornTypeEnum.Horse then local horseData = data.ConfigInfo if data.HorseInfo.starLevel < horseData.CanRebirthStarLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[horseData.HorseName]), horseData.CanRebirthStarLevel) return end elseif self.type == RebornTypeEnum.Treasure then local treasureData = data.TreasureData if data.TreasureInfo.starLevel < treasureData.CanRebirthStarLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[treasureData.TreasureName]), treasureData.CanRebirthStarLevel) return end elseif self.type == RebornTypeEnum.GodBeast then local godBeastData = DataSheetManager.GodBeastData:GetDataByID(data.godBeastId) if data.starLevel < godBeastData.CanRebirthStarLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_EquipMelting_RebirthHint_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[godBeastData.GodBeastName]), godBeastData.CanRebirthStarLevel) return end end self.selectId = recastId end UIUtils.SetActive(cellTable.img_Selected, self.selectId == recastId) if self.type == RebornTypeEnum.HorseSoul then UIUtils.SetActive(cellTable.img_MaskTriangle, self.selectId == recastId) end self:RefreshSelectRecastInfo() end elseif scrollRect == self.loop_RecastReward then if target == cellTable.item.event_Click then local itemData = DataSheetManager.ItemData:GetDataByID(data.ItemID) if itemData.FirstType == LuaConst.ItemType.HorseSoul then CTL.HorseSoul.OpenSoulTips(0, data.ItemID) else UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end elseif scrollRect == self.loop_Tab then --越南屏蔽了中间的坐骑魂珠 if GameAppInfo.IsVietnamPackage() and index == 4 then self:InitRecastDataListByIndex(index + 1) else self:InitRecastDataListByIndex(index) end self:RefreshSwitchTabListStatus(false) end end function UIRebornRecast:UIAdjustRegion() if GameAppInfo.IsVietnamPackage() then self.toggle_RecastType:SetToggleActive(5, false) end end function UIRebornRecast:OnClosed() MDL.Reborn.ResetRecastRewardList() end function UIRebornRecast:UIAdjustRegion() if GameAppInfo.IsVietnamPackage() then self.toggle_RecastType:SetToggleActive(5, false) --越南先屏蔽背景框 所以需要修改选择框的背景板高度 UIUtils.ChangeHeight(self.group_RecastSecondTab.gameObject, RecastSecondHeightVN) end end return UIRebornRecast