142 lines
4.2 KiB
Lua
142 lines
4.2 KiB
Lua
local TalentMainUI = class("TalentMainUI", BaseUI)
|
|
|
|
local TALENT_CELL = "app/ui/talent/cell/talent_cell"
|
|
|
|
function TalentMainUI:ctor()
|
|
end
|
|
|
|
function TalentMainUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function TalentMainUI:getCurrencyParams()
|
|
if self.currencyParams == nil then
|
|
self.currencyParams = {
|
|
itemIds = {
|
|
GConst.ItemConst.ITEM_ID_GOLD,
|
|
}
|
|
}
|
|
end
|
|
return self.currencyParams
|
|
end
|
|
|
|
function TalentMainUI:getPrefabPath()
|
|
return "assets/prefabs/ui/talent/talent_ui.prefab"
|
|
end
|
|
|
|
function TalentMainUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
uiMap["talent_ui.close_btn"]:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
|
|
self.getBtn = uiMap["talent_ui.get_btn"]
|
|
self.costIcon = uiMap["talent_ui.get_btn.cost.icon"]
|
|
self.costTx = uiMap["talent_ui.get_btn.cost.cost_tx"]
|
|
self.descTx = uiMap["talent_ui.desc_tx"]
|
|
self.upNode = uiMap["talent_ui.up_node"]
|
|
self.upTalentCell = uiMap["talent_ui.up_node.node.talent_cell"]:addLuaComponent(TALENT_CELL)
|
|
self.upDescTx = uiMap["talent_ui.up_node.desc_tx"]
|
|
self.upNode:setActive(false)
|
|
self.vfx01s = {}
|
|
self.vfx02s = {}
|
|
for i = 1, 3 do
|
|
self.vfx01s[i] = uiMap["talent_ui.up_node.vfx_c1_ui_tianfu_0" .. i .. "_1"]
|
|
self.vfx02s[i] = uiMap["talent_ui.up_node.vfx_c1_ui_tianfu_0" .. i .. "_2"]
|
|
end
|
|
|
|
uiMap["talent_ui.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.TALENT_DESC_1))
|
|
uiMap["talent_ui.get_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.TALENT_DESC_2))
|
|
self.scrollRect = uiMap["talent_ui.bottom_bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.scrollRect:addInitCallback(function()
|
|
return TALENT_CELL
|
|
end)
|
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
|
cell:refresh(index, self.list[index])
|
|
end)
|
|
self.scrollRect:clearCells()
|
|
|
|
self.getBtn:addClickListener(function()
|
|
if not GFunc.checkCost(self.cfg.cost.id, self.cfg.cost.num, true) then
|
|
return
|
|
end
|
|
local can, stage = DataManager.TalentData:checkStage()
|
|
if not can then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.TALENT_DESC_3, stage))
|
|
return
|
|
end
|
|
ModuleManager.TalentManager:talentUpgrade()
|
|
end)
|
|
|
|
self.upNode:addClickListener(function()
|
|
self.upNode:setActive(false)
|
|
DataManager.HeroData:calcPower()
|
|
end)
|
|
|
|
self:bind(DataManager.TalentData, "isDirty", function()
|
|
self:onUpgrade()
|
|
self:onRefresh()
|
|
end)
|
|
end
|
|
|
|
function TalentMainUI:onRefresh()
|
|
self.list = DataManager.TalentData:getCfgList()
|
|
self.scrollRect:refillCells(#self.list)
|
|
|
|
local stage = DataManager.TalentData:getStage()
|
|
self.cfg = DataManager.TalentData:getPlayerExpCfgList(stage)
|
|
self.costIcon:setSprite(GFunc.getIconRes(self.cfg.cost.id))
|
|
if not GFunc.checkCost(self.cfg.cost.id, self.cfg.cost.num) then
|
|
self.costTx:setText("<color=#FA3939>" .. self.cfg.cost.num .. "</color>")
|
|
else
|
|
self.costTx:setText(self.cfg.cost.num)
|
|
end
|
|
|
|
if not DataManager.TalentData:checkStage() then
|
|
self.descTx:setActive(true)
|
|
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.TALENT_DESC_3, stage))
|
|
else
|
|
self.descTx:setActive(false)
|
|
end
|
|
self.getBtn:setActive(not DataManager.TalentData:isAllMax())
|
|
end
|
|
|
|
function TalentMainUI:onUpgrade()
|
|
local upData = DataManager.TalentData:getUpData()
|
|
if not upData then
|
|
return
|
|
end
|
|
self.upNode:setActive(true)
|
|
self.upTalentCell:refresh(upData.id, self.list[upData.id], true)
|
|
|
|
local attr, num = DataManager.TalentData:getAttrById(upData.id)
|
|
local str = I18N:getText("talent", upData.id, "desc")
|
|
if attr and #attr > 0 then
|
|
str = str .. GFunc.getFinalAttrValue(attr[1].type, attr[1].num)
|
|
elseif self.id == DataManager.TalentData.SELECT_SKILL_ID then
|
|
elseif self.id == DataManager.TalentData.SKILL_REFESH_ID then
|
|
str = str .. (num or 0)
|
|
elseif self.id == DataManager.TalentData.HP_RESTORE_ID then
|
|
str = str .. (num or 0) // GConst.DEFAULT_FACTOR
|
|
else
|
|
str = str .. (num or 0) // 100 .. "%"
|
|
end
|
|
self.upDescTx:setText(str)
|
|
self.upDescTx:setActive(false)
|
|
self.root:performWithDelayGlobal(function()
|
|
self.upDescTx:setActive(true)
|
|
end, 0.5)
|
|
|
|
local qlt = self.list[upData.id].qlt
|
|
for i = 1, 3 do
|
|
if i == qlt then
|
|
self.vfx01s[i]:setActive(true)
|
|
self.vfx02s[i]:setActive(true)
|
|
else
|
|
self.vfx01s[i]:setActive(false)
|
|
self.vfx02s[i]:setActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
return TalentMainUI |