local ItemGetUI = class("ItemGetUI", BaseUI) function ItemGetUI:isFullScreen() return false end function ItemGetUI:getPrefabPath() return "assets/prefabs/ui/dungeon/item_get_ui.prefab" end function ItemGetUI:onPressBackspace() self:closeUI() end function ItemGetUI:onClose() end function ItemGetUI:ctor(parmas) self.target = parmas end function ItemGetUI:onLoadRootComplete() local uiMap = self.root:genAllChildren() self.txTitle = uiMap["item_get_ui.content.title.tx_title"] self.btnClose = uiMap["item_get_ui.content.btn_close"] self.rewardCell = uiMap["item_get_ui.content.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) self.txDesc = uiMap["item_get_ui.content.tx_desc"] self.txGet = uiMap["item_get_ui.content.tx_get"] self.scrollRectComp = uiMap["item_get_ui.content.scroll_view"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) self.scrollRectComp:addInitCallback(function() return "app/ui/dungeon/cell/dungeon_target_cell" end) self.scrollRectComp:addRefreshCallback(function(index, cell) cell:refresh(self.target, self.wayType, self.wayList[index]) end) self.btnClose:addClickListener(function() self:closeUI() end) self:addEventListener(EventManager.CUSTOM_EVENT.GO_DUNGEON_UI, function() self:closeUI() end) self:bind(DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_WEAPON), "isDirty", function() self:onRefresh() end) self:bind(DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_ARMOR), "isDirty", function() self:onRefresh() end) end function ItemGetUI:onRefresh() self.txTitle:setText(I18N:getText("item", self.target.id, "name")) self.txDesc:setText(I18N:getText("item", self.target.id, "desc")) self.txGet:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_23)) self.rewardCell:refreshItemById(self.target.id) local itemCfg = ConfigManager:getConfig("item")[self.target.id] if itemCfg == nil or itemCfg.get_way_type == nil or itemCfg.get_way == nil or #itemCfg.get_way == 0 then self:closeUI() return end self.wayType = itemCfg.get_way_type local weaponData if self.wayType == GConst.DungeonConst.TYPE.WEAPON then weaponData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_WEAPON) elseif self.wayType == GConst.DungeonConst.TYPE.ARMOR then weaponData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_ARMOR) end local farm = {} local unlock = {} local lock = {} for index, id in ipairs(itemCfg.get_way) do if weaponData:canFarmChapter(id) and weaponData:getRemianFarmCount(id) > 0 then table.insert(farm, id) elseif weaponData:canFightChapter(id) then table.insert(unlock, id) else table.insert(lock, id) end end table.sort(farm, function(a, b) return a > b end) table.sort(unlock, function(a, b) return a > b end) table.sort(lock, function(a, b) return a > b end) unlock = table.addArray(farm, unlock) self.wayList = table.addArray(unlock, lock) self.scrollRectComp:clearCells() self.scrollRectComp:refillCells(#self.wayList) end return ItemGetUI