local UISearchItemView = UIViewClass() local SliderSensitivityParam = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SliderSensitivityParam").FloatValue) local FastBattleItemID = DataSheetManager.ConstData:GetDataByID("FastBattleItemID").IntValue local FastBattleItemNum = DataSheetManager.ConstData:GetDataByID("FastBattleItemNum").IntValue function UISearchItemView:OnOpened(context) self.itemId = context[1] self.equipIndex = context[2] self.needCount = context[3] self.dragDict = {} self.rewardItemIdList = {} -- 关卡非首通奖励 self:RefreshTargetMaterial(self.itemId, self.needCount) self:RefreshLevelLoopScroll(self.itemId) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_Sweep_Title) -- ---这里先这么写了 策划说体力消耗固定是5 UIUtils.SetLabel(self.txt_Cost, 5) UIUtils.SetLabel(self.txt_Cost1, FastBattleItemNum) end function UISearchItemView:RefreshTargetMaterial(itemId, needCount) local itemData = DataSheetManager.ItemData:GetDataByID(itemId) UIUtils.SetLabel(self.txt_ItemName, UTL.Color.FormatQualityText(UTL.Item.GetItemDataSpliceByType(itemId).Name, itemData.Color)) UTL.Item.SetItemCell(self.img_Item, itemId) local haveCount = MDL.Currency.GetSoftTokenCountById(itemId) or 0 UIUtils.SetLabel(self.txt_ItemNum, UTL.Color.FormatRedColor(haveCount).."/"..needCount) --设置属性 local heroId = MDL.HeroSelect.curSelectHeroID local advancedStep = MDL.Advanced.GetHeroAdvancedInfo(heroId) local materialAttr = MDL.Advanced.GetMaterialAttrTableById(heroId, advancedStep, self.equipIndex) for i, v in ipairs(self.group_ItemAttrInfo) do if materialAttr[i] then UIUtils.SetActive(v, true) local attrName = DataSheetManager.AttrData:GetDataByID(materialAttr[i].AttrType).Name UIUtils.SetLabel(v, UIUtils.GetLocalizedTxt(Const_IDS[attrName]).."+"..materialAttr[i].AttrNum) else UIUtils.SetActive(v, false) end end end function UISearchItemView:RefreshLevelLoopScroll(itemId) local remainCount = UTL.Item.GetItemStockCount(FastBattleItemID) self.showFastBattle = remainCount > 0 local levelIdList = MDL.Advanced.GetSortedLevelIdByItemId(itemId) for i, v in ipairs(levelIdList) do local barrierData = DataSheetManager.BarrierChosenData:GetDataByID(v) local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(barrierData.RewardClientShowID) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.loop_StageSelect:AddData({itemData = rewardData, levelData = barrierData}, 0) end end function UISearchItemView:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISearchItemView:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UISearchItemView:OnCellInit(scrollRect, index, cellTable, data) local levelData = data.levelData local levelId = levelData.ID local starNum = MDL.LevelSelect.GetLevelStarNumById(levelId) local difficult = MDL.LevelSelect.GetDifficultById(levelId) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(difficult) or 0 local itemCount = 0 local notFTRewardList = {} for i, itemData in ipairs(data.itemData) do if starNum > 0 and itemData.FristGothrough then -- 如果关卡星级 > 0 (已经通关) ,同时该奖励为首通奖励则不显示该奖励,此处什么都不做 else itemCount = itemCount + 1 local contentItem = cellTable.Content[itemCount] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.itemTemplate_Reward.gameObject) end table.insert(notFTRewardList, itemData.ItemID) UTL.Item.SetItemCell(contentItem, itemData.ItemID, itemData.ItemNum, itemData.FristGothrough) UIUtils.SetActive(contentItem.gameObject, true) end end self.rewardItemIdList[index] = notFTRewardList for i = itemCount + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end cellTable.group_Star:SetState(starNum) --UIUtils.SetLabelText(cellTable.txt_LevelName,Const_IDS[levelData.BarrierName]) --英语、印尼语,只显示章节号-关卡号 if Localization.IsEnglish() or Localization.IsIndonesian() then UIUtils.SetLabelText(cellTable.txt_LevelName, Const_IDS[levelData.BarrierNum]) else cellTable.txt_LevelName.text = CTL.LevelSelect.GetLevelWholeNameById(levelId) end if unlockLevelId >= levelId then if starNum == 0 then UIUtils.SetActive(cellTable.btn_Battle, true) UIUtils.SetActive(cellTable.img_Locked, false) UIUtils.SetActive(cellTable.btn_SweepTen, false) UIUtils.SetActive(cellTable.btn_AutoSweep, false) else UIUtils.SetActive(cellTable.btn_SweepTen, true) UIUtils.SetActive(cellTable.btn_AutoSweep, true) UIUtils.SetActive(cellTable.img_Locked, false) UIUtils.SetActive(cellTable.btn_Battle, false) if self.showFastBattle then UIUtils.SetActive(cellTable.btn_AutoSweep, false) UIUtils.SetActive(cellTable.group_SweepBtn, true) else UIUtils.SetActive(cellTable.btn_AutoSweep, true) UIUtils.SetActive(cellTable.group_SweepBtn, false) end end else UIUtils.SetActive(cellTable.img_Locked, true) UIUtils.SetActive(cellTable.btn_Battle, false) UIUtils.SetActive(cellTable.btn_SweepTen, false) UIUtils.SetActive(cellTable.btn_AutoSweep, false) end scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.BeginDrag, index) scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.Drag, index) scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.EndDrag, index) self.dragDict[cellTable.drag_Obj.gameObject] = cellTable.ItemScrollView.gameObject end function UISearchItemView:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Battle then local levelId = data.levelData.ID local context = { levelId = levelId, index = MDL.LevelSelect.GetIndexById(levelId), chapterId = MDL.LevelSelect.GetChapterIdByLevelId(levelId), difficult = MDL.LevelSelect.GetDifficultById(levelId), } UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UILevelSelectPanel, context) elseif target == cellTable.btn_SweepTen then if DataSheetManager.BarrierChosenData:GetDataByID(data.levelData.ID).Energy <= MDL.Player.GetEnergyValue() then CTL.Sweep.OpenSweepItemView(data.levelData.ID, self.itemId, self.equipIndex, 10, self.needCount) self:CloseView() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Sweep_Finish_NoEnergy"]) UTL.ItemTips.OpenAboutEnergyPillView() end elseif target == cellTable.btn_AutoSweep or target == cellTable.btn_PowerSweep then if DataSheetManager.BarrierChosenData:GetDataByID(data.levelData.ID).Energy <= MDL.Player.GetEnergyValue() then CTL.Sweep.OpenSweepItemView(data.levelData.ID, self.itemId, self.equipIndex, 0, self.needCount) self:CloseView() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Sweep_Finish_NoEnergy"]) UTL.ItemTips.OpenAboutEnergyPillView() end elseif target == cellTable.btn_FastBattleTokenSweep then self:ClickSweepByFastBattle(data.levelData.ID) self:CloseView() end for i,v in ipairs(cellTable.Content) do if v.event_Click == target then UTL.ItemTips.ShowCommonTipsById(self.rewardItemIdList[index][i]) break end end end function UISearchItemView:ClickSweepByFastBattle(id) CTL.Sweep.OpenSweepItemView(id, self.itemId, self.equipIndex, 0, self.needCount, true) end function UISearchItemView:Cell_OnBeginDrag(scrollRect, index, comp, eventData) if math.abs(eventData.delta.x) > SliderSensitivityParam then self.curDragObj = self.dragDict[comp.gameObject] else self.curDragObj = self.loop_StageSelect.gameObject end UIUtils.ExecuteBeginDrag(self.curDragObj, eventData) end function UISearchItemView:Cell_OnDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteDrag(self.curDragObj, eventData) end function UISearchItemView:Cell_OnEndDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteEndDrag(self.curDragObj, eventData) end return UISearchItemView