213 lines
8.0 KiB
Lua
213 lines
8.0 KiB
Lua
require("Base/BasePanel")
|
|
HeroPotencyPanel = Inherit(BasePanel)
|
|
local potentialConfig = ConfigManager.GetConfig(ConfigName.PotentialNewConfig)
|
|
local this = HeroPotencyPanel
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData = {
|
|
[1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[2] },
|
|
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[1] },
|
|
[3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[3] },
|
|
[4] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[4] },
|
|
}
|
|
local _TabFontColor = {
|
|
default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
select = Color.New(154 / 255, 78 / 255, 36 / 255, 1)
|
|
}
|
|
local skills = {}
|
|
local pros = {}
|
|
local materals = {}
|
|
local curIndex = 1
|
|
|
|
local curSeletSkill = {}
|
|
local allSkillData = {}
|
|
local materialNoId = 0
|
|
local endLv = 0
|
|
local isMaxLv = true
|
|
|
|
local tabRedPotList = {}
|
|
local oldWarPowerValue = 0
|
|
local newWarPowerValue = 0
|
|
local oldLv
|
|
|
|
local data
|
|
--长按升级状态
|
|
local _isClicked = false
|
|
local _isReqLvUp = false
|
|
local curHeroData = nil
|
|
local heroListData = nil
|
|
local index = 0
|
|
--初始化组件(用于子类重写)
|
|
function HeroPotencyPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.tabBox = Util.GetGameObject(self.gameObject, "bg/TabBox")
|
|
this.backBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
|
|
this.btnUpLv = Util.GetGameObject(self.gameObject, "bg/btnUpLv")
|
|
this.btnRest = Util.GetGameObject(self.gameObject, "bg/btnRest")
|
|
this.helpBtn = Util.GetGameObject(self.gameObject, "bg/HelpBtn")
|
|
this.heroBg = Util.GetGameObject(self.gameObject, "bg/Hero/Frame"):GetComponent("Image")
|
|
this.heroImg = Util.GetGameObject(self.gameObject, "bg/Hero/Icon"):GetComponent("Image")
|
|
this.helpPos = this.helpBtn:GetComponent("RectTransform").localPosition
|
|
this.titleText = Util.GetGameObject(self.gameObject, "bg/titleText"):GetComponent("Text")
|
|
this.titleText.text = Language[11505]
|
|
this.selectImage = Util.GetGameObject(self.gameObject, "bg/skills/selectImage")
|
|
this.upLvTrigger = Util.GetEventTriggerListener(this.btnUpLv)
|
|
this.btn_left = Util.GetGameObject(self.gameObject, "bg/btn_left")
|
|
this.btn_right = Util.GetGameObject(self.gameObject, "bg/btn_right")
|
|
this.allEquipList = {}
|
|
this.redList = {}
|
|
for i = 1, 8 do
|
|
local obj = Util.GetGameObject(self.gameObject, "bg/skills/frame (" .. i .. ")")
|
|
local skillItem = {}
|
|
skillItem.obj = obj
|
|
skillItem.icon = Util.GetGameObject(obj, "icon"):GetComponent("Image")
|
|
skillItem.btn = Util.GetGameObject(obj, "icon")
|
|
skillItem.selectPar = Util.GetGameObject(obj, "selectImageParent")
|
|
skillItem.lv = Util.GetGameObject(obj, "lvImage/Text"):GetComponent("Text")
|
|
skillItem.lock = Util.GetGameObject(obj, "lock")
|
|
skillItem.red = Util.GetGameObject(obj, "redpoint")
|
|
table.insert(this.redList, skillItem.red)
|
|
table.insert(this.allEquipList, skillItem)
|
|
end
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function HeroPotencyPanel:BindEvent()
|
|
Util.AddClick(this.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Potency, this.helpPos.x, this.helpPos.y)
|
|
end)
|
|
Util.AddClick(this.backBtn, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnUpLv, function()
|
|
if Time.realtimeSinceStartup - this.timePressStarted <= 0.4 then
|
|
this.LvUpClick(true)
|
|
end
|
|
end)
|
|
|
|
Util.AddClick(this.btnRest, function()
|
|
if data and data[1] and data[1].lv <= 1 then
|
|
PopupTipPanel.ShowTip(Language[11506])
|
|
return
|
|
end
|
|
NetManager.PotentialBackLvRequest(curHeroData.dynamicId, function()
|
|
HeroManager.ResetHeroPotentialData(curHeroData.dynamicId)
|
|
this.RefreshWindowData()
|
|
end)
|
|
end)
|
|
|
|
Util.AddClick(this.btn_left, function()
|
|
index = (index - 1 > 0 and index - 1 or #heroListData)
|
|
curHeroData = heroListData[index]
|
|
this.RefreshWindowData()
|
|
end)
|
|
Util.AddClick(this.btn_right, function()
|
|
index = (index + 1 <= #heroListData and index + 1 or 1)
|
|
curHeroData = heroListData[index]
|
|
this.RefreshWindowData()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function HeroPotencyPanel:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function HeroPotencyPanel:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function HeroPotencyPanel:OnOpen(_curHeroData, list)
|
|
curHeroData = _curHeroData
|
|
heroListData = list
|
|
for i = 1, #heroListData do
|
|
if curHeroData == heroListData[i] then
|
|
index = i
|
|
end
|
|
end
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function HeroPotencyPanel:OnShow()
|
|
oldWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
local list = {}
|
|
for k, v in ConfigPairs(potentialConfig) do
|
|
table.insert(list, v)
|
|
end
|
|
table.sort(potentialConfig, function(a, b)
|
|
return a.Position < b.Position
|
|
end)
|
|
this.RefreshWindowData()
|
|
end
|
|
|
|
function this.RefreshWindowData()
|
|
this.heroBg.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality,
|
|
curHeroData.star))
|
|
this.heroImg.sprite = this.spLoader:LoadSprite(curHeroData.icon)
|
|
data = HeroManager.GetPotentialData(curHeroData.dynamicId)
|
|
local giftLv = GiftManager.GetHeroPotencyLvById(curHeroData.dynamicId)
|
|
for i = 1, 8 do
|
|
local item = this.allEquipList[i]
|
|
if item == nil then
|
|
return
|
|
end
|
|
local config = ConfigManager.GetConfigDataByKey(ConfigName.PotentialNewConfig, "Position", i)
|
|
item.icon.sprite = this.spLoader:LoadSprite(config.Icon)
|
|
local type = config.Type
|
|
if data[type] then
|
|
local lv = data[type].lv
|
|
--LogError("lv======================="..lv.." giftlv==="..data[type].giftLv)
|
|
item.lv.text = lv + giftLv
|
|
--判断下一级是否可以升级
|
|
local lvConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PotentialNew, "Type", type, "Level",
|
|
lv + 1)
|
|
if lvConfig then
|
|
if lvConfig.Open and #lvConfig.Open > 0 and lvConfig.Open[1] ~= nil and lvConfig.Open[2] ~= nil then
|
|
--LogError("lvconfig===============id============"..lvConfig.Id.." open[1]=="..lvConfig.Open[1].." open[2]=="..lvConfig.Open[2])
|
|
if data[lvConfig.Open[1]] and data[lvConfig.Open[1]].lv >= lvConfig.Open[2] then
|
|
item.lock:SetActive(false)
|
|
else
|
|
item.lock:SetActive(true)
|
|
end
|
|
else
|
|
item.lock:SetActive(false)
|
|
end
|
|
else
|
|
item.lock:SetActive(false)
|
|
end
|
|
else
|
|
item.lv.text = 0
|
|
item.lock:SetActive(true)
|
|
end
|
|
item.red:SetActive(HeroManager.CheckPotencyRedPointByType(curHeroData.dynamicId, type))
|
|
Util.AddClick(item.btn, function()
|
|
UIManager.OpenPanel(UIName.HeroPotencyLvUpPanel, type, curHeroData.dynamicId, config, this)
|
|
--UIManager.OpenPanel(UIName.HeroPotencyInfoPopup)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function this.RefreshTabRedPoint(index)
|
|
if index then
|
|
tabRedPotList[index]:SetActive(false)
|
|
else
|
|
for i = 1, #tabRedPotList do
|
|
tabRedPotList[curIndexChangeFun[i]]:SetActive(GuildSkillManager.GuildSkillRedPoint(curIndexChangeFun[i]))
|
|
end
|
|
end
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function HeroPotencyPanel:OnClose()
|
|
tabRedPotList = {}
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Role.UpdateSodSoulLayout)
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function HeroPotencyPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.allEquipList = {}
|
|
this.redList = {}
|
|
end
|
|
|
|
return HeroPotencyPanel
|