miduo_client/Assets/ManagedResources/~Lua/Modules/Practice/FourQuadrantGongmingPopup.lua

145 lines
5.3 KiB
Lua

require("Base/BasePanel")
FourQuadrantGongmingPopup = Inherit(BasePanel)
local this = FourQuadrantGongmingPopup
local ProfessionType = {
[1] = 2,--输出
[2] = 1,--肉盾
[3] = 3,--控制
[4] = 4,--辅助
}
local propertyType = {
[1] = 2,--攻击
[2] = 1,--生命
[3] = 3,--护甲
[4] = 4,--魔抗
}
--属性id对应属性名称
local PropertyName={
[1] = "生命",
[2] = "攻击",
[3] = "护甲",
[4] = "魔抗",
}
--初始化组件(用于子类重写)
function this:InitComponent()
this.spLoader = SpriteLoader.New()
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.backBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.professionGrid = Util.GetGameObject(self.gameObject, "bg/professionGrid")
this.curGomgmingLv = Util.GetGameObject(self.gameObject, "bg/propertyAddGrid/curAdd/curGomgmingLv"):GetComponent("Text")
this.curPropertyGrid = Util.GetGameObject(self.gameObject, "bg/propertyAddGrid/curAdd/curPropertyGrid")
this.nextGongmingLv = Util.GetGameObject(self.gameObject, "bg/propertyAddGrid/nextAdd/nextGongmingLv"):GetComponent("Text")
this.nextPropertyGrid = Util.GetGameObject(self.gameObject, "bg/propertyAddGrid/nextAdd/nextPropertyGrid")
this.professionList={}
for i = 1, this.professionGrid.transform.childCount do
local obj= this.professionGrid.transform:GetChild(i-1)
local professionId=ProfessionType[i]
Util.GetGameObject(obj,"professionName"):GetComponent("Text").text=GetProfessionNameById(professionId)
Util.GetGameObject(obj,"professionIcon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroProfessionById(professionId))
local btn=Util.GetGameObject(obj,"btn")
Util.AddClick(btn, function()
self:ClosePanel()
local fourQuadUi = UIManager.GetOpenPanel(UIName.FourQuadrantPopup)
if fourQuadUi then
fourQuadUi.UpdateData(professionId)
fourQuadUi.SetSelectBtn(professionId)
end
end)
this.professionList[i]={}
this.professionList[i].professionId=professionId
this.professionList[i].progressBar=Util.GetGameObject(obj,"progress/progressBar"):GetComponent("Image")
this.professionList[i].btnText=Util.GetGameObject(obj,"btn/Text"):GetComponent("Text")
this.professionList[i].lv=Util.GetGameObject(obj,"lv"):GetComponent("Text")
end
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddClick(this.mask, function()
self:ClosePanel()
end)
Util.AddClick(this.backBtn, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function this:AddListener()
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
end
--界面打开时调用(用于子类重写)
function this:OnOpen(data)
for i = 1, #this.professionList do
local professionId=this.professionList[i].professionId
local progressVle=0
if PracticeManager.FourQuadrantData[professionId] then
progressVle=PracticeManager.FourQuadrantData[professionId].level
end
this.professionList[i].progressBar.fillAmount = progressVle/5
if progressVle>=5 then
this.professionList[i].btnText.text="已达上限"
else
this.professionList[i].btnText.text="强 化"
end
this.professionList[i].lv.text=string.format("(%s/5)",progressVle)
end
local curGongmingLv=PracticeManager.GetFourQuadrantGongmingLv()
this.curGomgmingLv.text=string.format("当前共鸣:%s级",curGongmingLv)
this.SetPropAdd(this.curPropertyGrid,curGongmingLv)
local nextGongmingLv=curGongmingLv+1
this.nextGongmingLv.text=string.format("下级共鸣:%s级",nextGongmingLv)
this.SetPropAdd(this.nextPropertyGrid,nextGongmingLv,true)
end
function this.SetPropAdd(_propAddObj,_gongmingLv,isNext)
if _gongmingLv<=5 then
local curFourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",_gongmingLv)
_propAddObj.transform.parent.gameObject:SetActive(true)
for i = 1, #propertyType do
local propertyObj=_propAddObj.transform:GetChild(i-1)
local propertyId=propertyType[i]
local propertyText=propertyObj:GetComponent("Text")
local propertyIcon= Util.GetGameObject(propertyObj,"Image"):GetComponent("Image")
local addNum=0
if curFourQuadConfig.PropResonance then
addNum=curFourQuadConfig.PropResonance[propertyId][2]/10000*100
end
if isNext then
propertyText.text=string.format("全体%s加成 <color=#5AC283>+%s%%</color>",PropertyName[propertyId],addNum)
else
propertyText.text=string.format("全体%s加成 +%s%%",PropertyName[propertyId],addNum)
end
propertyIcon.sprite= this.spLoader:LoadSprite(PropertyTypeIconDef[propertyId])
end
else
_propAddObj.transform.parent.gameObject:SetActive(false)
end
end
function this:OnShow()
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
this.spLoader:Destroy()
end
return FourQuadrantGongmingPopup