local Advanced_Controller = {} local private = {} local colorStr = "%s" function Advanced_Controller.OnStartup() end function Advanced_Controller.OnShutdown() end function Advanced_Controller.GetFirstAdvanceHeroId() local slotIds = MDL.Formation.GetSlotHeroIds() for i, v in ipairs(slotIds) do if v > 0 and (MDL.Advanced.IsHeroCanAdvance(v) or MDL.Advanced.IsHeroCanGatherToAdvance(v)) then return v end end for i, v in ipairs(slotIds) do if v > 0 and not Advanced_Controller.IsReachMaxAdvanceLevel(v) then return v end end return next(slotIds) end function Advanced_Controller.IsMaterialAlreadyEquip(heroId, index) local advancedInfo = MDL.Advanced.GetHeroAdvancedMaterialInfo(heroId) if not advancedInfo then return false else return advancedInfo[index] end end function Advanced_Controller.IsCouldAdvance(heroId) local advancedInfo = MDL.Advanced.GetHeroAdvancedMaterialInfo(heroId) for i, v in ipairs(advancedInfo) do if not v then return false end end return true end function Advanced_Controller.IsReachMaxAdvanceLevel(heroId) local advancedLevel = MDL.Advanced.GetHeroAdvancedInfo(heroId) local LevelLength = DataSheetManager.HeroAdvance:GetDataCount() if advancedLevel == LevelLength then --CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroAdvanceMax"]) return true else return false end end function Advanced_Controller.IsHeroLevelReachLimit(heroId) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(MDL.Advanced.GetHeroAdvancedInfo(heroId)) if MDL.HeroSelect.GetHeroLevel(heroId) >= advancedData.LevelLimit then return true else return false end end function Advanced_Controller.IsAdvanceItemEnough(heroId) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(MDL.Advanced.GetHeroAdvancedInfo(heroId)) local advancedItemData = advancedData.PointItem_Table for i, v in ipairs(advancedItemData) do local itemId = v.PointItemID local itemNum = v.PointItemNum local count = MDL.Currency.IsMoneyTypeByItemID(itemId) and MDL.Currency.GetMoneyCount(itemId) or MDL.Bag.GetItemCount(itemId) if count < itemNum then return false end end return true end function Advanced_Controller.IsSingleMaterialEnough(heroId, index) local advancedInfo = MDL.Advanced.GetHeroAdvancedMaterialInfo(heroId) local indexItemData = MDL.Advanced.GetRequireMaterialTable(heroId)[index] if not advancedInfo[index] then if MDL.Currency.GetSoftTokenCountById(indexItemData.ItemID) >= indexItemData.ItemNum then return true else CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroAdvanceLackOfMaterial"]) return false end end end function Advanced_Controller.IsMaterialEnough(heroId) local advancedInfo = MDL.Advanced.GetHeroAdvancedMaterialInfo(heroId) local advancedItemData = MDL.Advanced.GetRequireMaterialTable(heroId) local materialIndexTable = {} for i, v in ipairs(advancedInfo) do if not v then local count = MDL.Currency.GetSoftTokenCountById(advancedItemData[i].ItemID) or 0 if count >= advancedItemData[i].ItemNum then table.insert(materialIndexTable, i-1) end end end if next(materialIndexTable) then return materialIndexTable else return nil end end function Advanced_Controller.IsGreatAdvanced(heroId) local nowAdvanceId = MDL.Advanced.GetHeroAdvancedInfo(heroId) local lastAdvanceId = nowAdvanceId - 1 local nowAdvancedStage = DataSheetManager.HeroAdvance:GetDataByAdvanceID(nowAdvanceId).Stage local lastAdvancedStage = DataSheetManager.HeroAdvance:GetDataByAdvanceID(lastAdvanceId).Stage if nowAdvancedStage > lastAdvancedStage then return true else return false end end function Advanced_Controller.GetNextBigAdvanceTitleAndDesc(heroId, advanceId) for i, v in DataSheetManager.HeroAdvanceAttr:GetDataByAdvanceTemplateID_AdvanceID(DataSheetManager.HeroNum:GetDataByID(heroId).AdvanceTemplateID) do if v.AdvanceID >= advanceId then if v.BigLvupAttr and v.BigLvupAttr > 0 then local desc = string.FormatByIdsId(Const_IDS.IDS_HeroAdvanceNew_Hint_11, v.BigLvupAttrDesc1, string.format(colorStr, UTL.Attr.FormatNumberToPercentage(v.BigLvupAttrDesc2, 0))) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(v.AdvanceID) local title = string.FormatByIdsId(Const_IDS.IDS_HeroAdvanceNew_Hint_10, advancedData.Stage, advancedData.LightStar) return title, desc end end end return nil, UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroAdvanceNew_Hint_13) end function Advanced_Controller.IsHasLevelCanSweep(itemId) local levelIdList = MDL.Advanced.GetSortedLevelIdByItemId(itemId) for i, v in ipairs(levelIdList) do local starNum = MDL.LevelSelect.GetLevelStarNumById(v) if starNum > 0 then return true --else -- local difficult = MDL.LevelSelect.GetDifficultById(v) -- local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(difficult) or 0 -- if unlockLevelId >= v then -- return true -- end end end return false end function Advanced_Controller.InstantiateStarCell(view, cellObj, compTable, totalStar, lightStar, starIcon, starBg) for i = 1, totalStar do if compTable[i] == nil then view:InstantiateCollection(compTable, cellObj) end local starCell = compTable[i] local starImg = starCell.img_Star UIUtils.SetActive(starCell.gameObject, true) UTL.Item.SetAtlasSprite(starCell.img_StarBg, "UI_Hero", starBg) if i <= lightStar then UTL.Item.SetAtlasSprite(starImg, "UI_Hero", starIcon) UIUtils.SetActive(starImg.gameObject, true) else UIUtils.SetActive(starImg.gameObject, false) end end for i = #compTable, totalStar + 1, -1 do view:DestroyCollection(compTable, i) end end return Advanced_Controller