197 lines
9.6 KiB
Lua
197 lines
9.6 KiB
Lua
require("Base/BasePanel")
|
||
RoleTalentPopup = Inherit(BasePanel)
|
||
local heroConfig,breakId,upStarId
|
||
local breakSkillDataList = {}
|
||
local upStarSkillDataList = {}
|
||
local passiveSkillLogicConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
|
||
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
||
local heroRankupConfig=ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
|
||
--初始化组件(用于子类重写)
|
||
function RoleTalentPopup:InitComponent()
|
||
self.spLoader = SpriteLoader.New()
|
||
self.breakSkillGoList = {}
|
||
self.upStarSkillGoList = {}
|
||
self.BackMask = Util.GetGameObject(self.transform, "BackMask")
|
||
self.breakOpenSkill =Util.GetGameObject(self.transform, "GameObject/grid/bg/breakOpenSkill")
|
||
self.upStarOpenSkill =Util.GetGameObject(self.transform, "GameObject/grid/bg/upStarOpenSkill")
|
||
self.breakSkillTextPre =Util.GetGameObject(self.transform, "breakSkillTextPre")
|
||
self.breakOpenSkillGrid =Util.GetGameObject(self.transform, "GameObject/grid/bg/breakOpenSkill/Mask")
|
||
self.upStarSkillTextPre =Util.GetGameObject(self.transform, "upStarSkillTextPre")
|
||
self.upStarOpenSkill =Util.GetGameObject(self.transform, "GameObject/grid/bg/upStarOpenSkill/Mask")
|
||
self.grid =Util.GetGameObject(self.transform, "GameObject/grid"):GetComponent("RectTransform")
|
||
self.gridVerticalL =Util.GetGameObject(self.transform, "GameObject/grid"):GetComponent("VerticalLayoutGroup")
|
||
self.gridLayoutE =Util.GetGameObject(self.transform, "GameObject/grid"):GetComponent("LayoutElement")
|
||
self.gridBg =Util.GetGameObject(self.transform, "GameObject/grid/bg"):GetComponent("RectTransform")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function RoleTalentPopup:BindEvent()
|
||
Util.AddClick(self.BackMask, function()
|
||
self:ClosePanel()
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function RoleTalentPopup:AddListener()
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function RoleTalentPopup:RemoveListener()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
--传三个参数 是因为图鉴也要用
|
||
function RoleTalentPopup:OnOpen(_heroConfig,_breakId,_upStarId)
|
||
heroConfig = _heroConfig
|
||
breakId = _breakId
|
||
upStarId = _upStarId
|
||
end
|
||
|
||
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
function RoleTalentPopup:OnShow()
|
||
self:GetTalentDataShow()
|
||
end
|
||
function RoleTalentPopup:GetTalentDataShow()
|
||
breakSkillDataList = {}
|
||
upStarSkillDataList = {}
|
||
local heroRankUpConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
|
||
LogError("upstarid =="..upStarId)
|
||
local openNum=0
|
||
local OpenPassiveSkillRules = (upStarId and upStarId ~=0 and heroRankUpConfig[upStarId].OpenStar >= HeroManager.awakeNextStarIndex) and heroConfig.Awaken or heroConfig.OpenPassiveSkillRules
|
||
if OpenPassiveSkillRules then
|
||
for i = 1, #OpenPassiveSkillRules do
|
||
if OpenPassiveSkillRules[i][1] == 1 then--突破
|
||
local titleStr = NumToSimplenessFont[heroRankupConfig[OpenPassiveSkillRules[i][2]].Phase[2]] .. Language[11795]
|
||
local curBreakId = OpenPassiveSkillRules[i][2]
|
||
if breakId >= curBreakId then
|
||
if breakSkillDataList[curBreakId] then
|
||
breakSkillDataList[curBreakId] = {index = curBreakId,str = breakSkillDataList[curBreakId].str .. " <color=#00F800>"..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
else
|
||
openNum=openNum+1
|
||
breakSkillDataList[curBreakId] = {index = curBreakId,str ="<color=#00F800>"..titleStr..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
end
|
||
else
|
||
if breakSkillDataList[curBreakId] then
|
||
breakSkillDataList[curBreakId] = {index = curBreakId,str =breakSkillDataList[curBreakId].str .. " <color=#B9AC97>"..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
else
|
||
openNum=openNum+1
|
||
breakSkillDataList[curBreakId] = {index = curBreakId,str ="<color=#B9AC97>"..titleStr..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
end
|
||
end
|
||
else--升星
|
||
|
||
local curUpStarId = OpenPassiveSkillRules[i][2]
|
||
local titleStr = ""
|
||
if curUpStarId>11 then
|
||
|
||
--self.grid.sizeDelta=Vector2.New(969,1000)
|
||
kongStr=" "
|
||
if curUpStarId==25 then
|
||
titleStr="飞升一阶激活:\n"
|
||
elseif curUpStarId==26 then
|
||
titleStr="飞升二阶激活:\n"
|
||
elseif curUpStarId==27 then
|
||
titleStr="飞升三阶激活:\n"
|
||
end
|
||
else
|
||
|
||
titleStr = NumToSimplenessFont[heroRankupConfig[curUpStarId].Phase[2]] .. Language[11792]
|
||
end
|
||
local _passiveSkillId = passiveSkillConfig[OpenPassiveSkillRules[i][3]].Id
|
||
LogError("upstarid=="..upStarId.." curupstarid=="..curUpStarId)
|
||
if upStarId >= curUpStarId then
|
||
if upStarSkillDataList[curUpStarId] then
|
||
upStarSkillDataList[curUpStarId] = {passiveSkillId = _passiveSkillId,index = curUpStarId,str = GetLanguageStrById(upStarSkillDataList[curUpStarId].str) .. "<color=#00F800>"..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
else
|
||
openNum=openNum+1
|
||
upStarSkillDataList[curUpStarId] = {passiveSkillId = _passiveSkillId,index = curUpStarId,str ="<color=#00F800>"..GetLanguageStrById(titleStr)..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
end
|
||
else
|
||
if upStarSkillDataList[curUpStarId] then
|
||
upStarSkillDataList[curUpStarId] = {passiveSkillId = _passiveSkillId,index = curUpStarId,str =GetLanguageStrById(upStarSkillDataList[curUpStarId].str) .. "<color=#B9AC97>"..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
else
|
||
openNum=openNum+1
|
||
upStarSkillDataList[curUpStarId] = {passiveSkillId = _passiveSkillId,index = curUpStarId,str ="<color=#B9AC97>"..GetLanguageStrById(titleStr)..GetLanguageStrById(passiveSkillConfig[OpenPassiveSkillRules[i][3]].Desc).."</color>"}
|
||
end
|
||
end
|
||
end
|
||
end
|
||
if openNum>10 then
|
||
self.gridVerticalL.enabled=false
|
||
self.gridLayoutE.enabled=true
|
||
self.gridBg.anchoredPosition=Vector2.New(380,840)
|
||
else
|
||
self.gridVerticalL.enabled=true
|
||
self.gridLayoutE.enabled=false
|
||
end
|
||
|
||
end
|
||
local breakSkillDataList2 = {}
|
||
for i, v in pairs(breakSkillDataList) do
|
||
table.insert(breakSkillDataList2,v)
|
||
end
|
||
table.sort(breakSkillDataList2, function(a,b) return a.index<b.index end)
|
||
for i = 1, math.max(#breakSkillDataList2, #self.breakSkillGoList) do
|
||
local go = self.breakSkillGoList[i]
|
||
if not go then
|
||
go = newObject(self.breakSkillTextPre)
|
||
go.transform:SetParent(self.breakOpenSkillGrid.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
self.breakSkillGoList[i] = go
|
||
end
|
||
go.gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #breakSkillDataList2 do
|
||
local go = self.breakSkillGoList[i]
|
||
go.gameObject:SetActive(true)
|
||
go:GetComponent("Text").text = breakSkillDataList2[i].str
|
||
end
|
||
local upStarSkillDataList2 = {}
|
||
for i, v in pairs(upStarSkillDataList) do
|
||
table.insert(upStarSkillDataList2,v)
|
||
end
|
||
table.sort(upStarSkillDataList2, function(a,b) return a.index<b.index end)
|
||
for i = 1, math.max(#upStarSkillDataList2, #self.upStarSkillGoList) do
|
||
local go = self.upStarSkillGoList[i]
|
||
if not go then
|
||
go = newObject(self.upStarSkillTextPre)
|
||
go.transform:SetParent(self.upStarOpenSkill.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
self.upStarSkillGoList[i] = go
|
||
end
|
||
go.gameObject:SetActive(false)
|
||
end
|
||
LogError("lem=="..#upStarSkillDataList2)
|
||
for i = 1, #upStarSkillDataList2 do
|
||
local go = self.upStarSkillGoList[i]
|
||
go.gameObject:SetActive(true)
|
||
local flyImg= Util.GetGameObject(go, "flyImg")
|
||
local kongStr = ""
|
||
if passiveSkillLogicConfig[upStarSkillDataList2[i].passiveSkillId].Judge == 1 then
|
||
kongStr = Language[11835]
|
||
end
|
||
if i>5 then
|
||
kongStr = " "
|
||
flyImg.gameObject:SetActive(true)
|
||
else
|
||
kongStr =""
|
||
flyImg.gameObject:SetActive(false)
|
||
end
|
||
-- Util.GetGameObject(go.transform, "Image"):SetActive(passiveSkillLogicConfig[upStarSkillDataList2[i].passiveSkillId].Judge == 1)
|
||
-- Util.GetGameObject(go.transform, "Image"):SetActive(false)
|
||
go:GetComponent("Text").text = kongStr .. upStarSkillDataList2[i].str
|
||
end
|
||
|
||
end
|
||
--界面关闭时调用(用于子类重写)
|
||
function RoleTalentPopup:OnClose()
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function RoleTalentPopup:OnDestroy()
|
||
self.spLoader:Destroy()
|
||
end
|
||
|
||
return RoleTalentPopup |