245 lines
9.5 KiB
Lua
245 lines
9.5 KiB
Lua
require("Base/BasePanel")
|
|
GodWeaponInfoPanel = Inherit(BasePanel)
|
|
local this = GodWeaponInfoPanel
|
|
local godwData
|
|
--初始化组件(用于子类重写)
|
|
function this:InitComponent()
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
this.leftBtn = Util.GetGameObject(self.gameObject, "leftBtn/btn")
|
|
this.rightBtn = Util.GetGameObject(self.gameObject, "rightBtn/btn")
|
|
this.spLoader = SpriteLoader.New()
|
|
this.icon= Util.GetGameObject(self.gameObject, "iconBg/icon"):GetComponent("Image")
|
|
this.nameText=Util.GetGameObject(self.gameObject, "nameInfo/nameText"):GetComponent("Text")
|
|
this.starGrid= Util.GetGameObject(self.gameObject, "starGrid/starGrid")
|
|
this.propGrid=Util.GetGameObject(self.gameObject, "infoLayout/propertyInfo/grid")
|
|
this.upStarBtn=Util.GetGameObject(self.gameObject,"infoLayout/propertyInfo/upStarBtn")
|
|
this.upLvBtn=Util.GetGameObject(self.gameObject,"infoLayout/propertyInfo/upLvBtn")
|
|
this.resetBtn=Util.GetGameObject(self.gameObject,"infoLayout/propertyInfo/resetBtn")
|
|
this.skillGrid=Util.GetGameObject(self.gameObject,"infoLayout/skill/scroll/grid")
|
|
this.unloadBtn = Util.GetGameObject(self.gameObject, "infoLayout/unloadBtn")
|
|
this.changeBtn = Util.GetGameObject(self.gameObject, "infoLayout/changeBtn")
|
|
this.upLvBtnRedPoint = Util.GetGameObject(this.upLvBtn, "redPoint")
|
|
this.upStarBtnRedPoint = Util.GetGameObject(this.upStarBtn, "redPoint")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function this:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.leftBtn, function()
|
|
local posIndex= 1
|
|
local allTeam= GodWeaponManager.GetAllTeamWeapon()
|
|
local posList=GodWeaponManager.GetAllTeamWeaponPos()
|
|
for i = 1, #posList do
|
|
if godwData.point==posList[i] then
|
|
posIndex=i
|
|
end
|
|
end
|
|
posIndex=posIndex-1
|
|
if posIndex<=0 then
|
|
posIndex=#posList
|
|
end
|
|
local _data= allTeam[posList[posIndex]]
|
|
this.UpdateWin(_data)
|
|
end)
|
|
Util.AddClick(this.rightBtn, function()
|
|
local posIndex= 1
|
|
local allTeam= GodWeaponManager.GetAllTeamWeapon()
|
|
local posList=GodWeaponManager.GetAllTeamWeaponPos()
|
|
for i = 1, #posList do
|
|
if godwData.point==posList[i] then
|
|
posIndex=i
|
|
end
|
|
end
|
|
posIndex=posIndex+1
|
|
if posIndex>#posList then
|
|
posIndex=1
|
|
end
|
|
local _data= allTeam[posList[posIndex]]
|
|
this.UpdateWin(_data)
|
|
end)
|
|
Util.AddClick(this.upLvBtn, function()
|
|
UIManager.OpenPanel(UIName.GodWeaponUpPanel,1,godwData)
|
|
end)
|
|
Util.AddClick(this.upStarBtn, function()
|
|
UIManager.OpenPanel(UIName.GodWeaponUpPanel,2,godwData)
|
|
end)
|
|
|
|
Util.AddClick(this.unloadBtn, function()
|
|
local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
NetManager.RequestMagicSoldierLocation(godwData.Did,0,function()
|
|
PopupTipPanel.ShowTip("下阵成功")
|
|
this.unloadBtn.gameObject:SetActive(false)
|
|
this.changeBtn.gameObject:SetActive(false)
|
|
GodWeaponManager.SetWeaponUpZhen(godwData.Did,0)
|
|
local newWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
--飘战力
|
|
PokemonManager.PiaoWarPowerChange(oldWarPower,newWarPower)
|
|
CheckRedPointStatus(RedPointType.GodWeapon)
|
|
end)
|
|
end)
|
|
Util.AddClick(this.changeBtn, function()
|
|
UIManager.OpenPanel(UIName.GodWeaponListPanel,1,godwData,godwData.point)
|
|
end)
|
|
Util.AddClick(this.resetBtn, function()
|
|
this.ResetBtnOnClick()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function this:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.GodWeapon.RefreshGodWeaponInfoPanel, this.UpdateWin)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function this:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.GodWeapon.RefreshGodWeaponInfoPanel, this.UpdateWin)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function this:OnOpen(_data)
|
|
this.UpdateWin(_data)
|
|
end
|
|
|
|
function this:OnShow()
|
|
local newData=GodWeaponManager.GetSingleWeaponData(godwData.Did)
|
|
this.UpdateWin(newData)
|
|
end
|
|
|
|
function this.UpdateWin(_data)
|
|
if _data.point and _data.point>0 then
|
|
this.unloadBtn.gameObject:SetActive(true)
|
|
this.changeBtn.gameObject:SetActive(true)
|
|
this.leftBtn.gameObject:SetActive(true)
|
|
this.rightBtn.gameObject:SetActive(true)
|
|
else
|
|
this.unloadBtn.gameObject:SetActive(false)
|
|
this.changeBtn.gameObject:SetActive(false)
|
|
this.leftBtn.gameObject:SetActive(false)
|
|
this.rightBtn.gameObject:SetActive(false)
|
|
end
|
|
|
|
godwData=_data
|
|
local upLvRed = GodWeaponManager.CheckUpLvRedPoint(godwData)
|
|
this.upLvBtnRedPoint:SetActive(upLvRed)
|
|
local upStarRed = GodWeaponManager.CheckUpStarRedPoint(godwData)
|
|
this.upStarBtnRedPoint:SetActive(upStarRed)
|
|
this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(_data.config.Icon))
|
|
this.nameText.text=_data.config.Name
|
|
local starSize = Vector2.New(65,65)
|
|
PokemonManager.SetHeroStars(this.spLoader, this.starGrid,_data.star,1,starSize)
|
|
local allPropDic=GodWeaponManager.GetSinglePokemonAddProData(_data.Did,_data.star)
|
|
local propInfoList={}
|
|
propInfoList[1]={}
|
|
propInfoList[1].name="等级"
|
|
propInfoList[1].val=_data.lv
|
|
propInfoList[2]={}
|
|
propInfoList[2].name="星级"
|
|
propInfoList[2].val=_data.star
|
|
local index=3
|
|
for key, value in pairs(allPropDic) do
|
|
propInfoList[index]={}
|
|
local propConfig=ConfigManager.GetConfigData(ConfigName.PropertyConfig,key)
|
|
propInfoList[index].name=propConfig.Info
|
|
propInfoList[index].val=value
|
|
index=index+1
|
|
end
|
|
for i = 1, this.propGrid.transform.childCount do
|
|
local propText=this.propGrid.transform:GetChild(i-1).gameObject
|
|
if i>#propInfoList then
|
|
propText:SetActive(false)
|
|
else
|
|
propText:SetActive(true)
|
|
propText:GetComponent("Text").text=propInfoList[i].name
|
|
Util.GetGameObject(propText,"val"):GetComponent("Text").text=propInfoList[i].val
|
|
end
|
|
end
|
|
|
|
local skillInfo=GodWeaponManager.GetSingleGodWeaponSkillDes(_data.Did)
|
|
for i = 1,this.skillGrid.transform.childCount do
|
|
local skillObj=this.skillGrid.transform:GetChild(i-1).gameObject
|
|
if i>#skillInfo then
|
|
skillObj:SetActive(false)
|
|
else
|
|
Util.GetGameObject(skillObj,"titleBg/title"):GetComponent("Text").text=skillInfo[i].title
|
|
Util.GetGameObject(skillObj,"titleBg/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(skillInfo[i].icon)
|
|
Util.GetGameObject(skillObj,"des"):GetComponent("Text").text=skillInfo[i].des
|
|
skillObj:SetActive(true)
|
|
local allSkillData=ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.ShenBingSkill,"SkillPanDuan",skillInfo[i].skillPanDuan,"SpiritAnimalMatch",_data.id)
|
|
local helpBtn=Util.GetGameObject(skillObj,"titleBg/helpBtn")
|
|
Util.AddOnceClick(helpBtn, function()
|
|
UIManager.OpenPanel(UIName.GodWeaponSkillInfoPopup,skillInfo[i].title,allSkillData)
|
|
end)
|
|
end
|
|
end
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(this.skillGrid.transform)
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function this.ResetBtnOnClick()
|
|
if godwData.point>0 then
|
|
PopupTipPanel.ShowTip("上阵名刀无法进行重铸")
|
|
return
|
|
end
|
|
if godwData.lv==1 and godwData.star <= 0 then
|
|
PopupTipPanel.ShowTip("未强化名刀无法进行重铸")
|
|
return
|
|
end
|
|
|
|
local lv=godwData.lv
|
|
local star=godwData.star
|
|
local qua=godwData.config.Quality
|
|
--所有材料
|
|
local allMaterials={}
|
|
--升级消耗
|
|
local lvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Level",lv,"Quality",qua)
|
|
if lvConfig then
|
|
local matrs=lvConfig.SumConsume
|
|
if matrs then
|
|
for i = 1, #matrs do
|
|
local mat=matrs[i]
|
|
if mat[2]>0 then
|
|
table.insert(allMaterials,{mat[1],mat[2]})
|
|
end
|
|
end
|
|
end
|
|
end
|
|
--升星消耗
|
|
local lingshouConfig=ConfigManager.GetConfigData(ConfigName.ShenBing,godwData.id)
|
|
if star>0 then
|
|
local starConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Star",star,"Quality",qua)
|
|
if starConfig then
|
|
--消耗本体数量
|
|
if starConfig.SumItemNum>=1 then
|
|
table.insert(allMaterials,{godwData.id,starConfig.SumItemNum})
|
|
end
|
|
end
|
|
end
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.PokemonResolve,lingshouConfig,allMaterials,2,function ()
|
|
NetManager.MagicSoldierReturnRequest(godwData.Did,function(msg)
|
|
PopupTipPanel.ShowTip("回炉成功")
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
GodWeaponManager.ResetGodWeapon(godwData.Did,1,0)
|
|
this.UpdateWin(GodWeaponManager.GetSingleWeaponData(godwData.Did))
|
|
end)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
function this:OnSortingOrderChange()
|
|
this.sortingOrder = self.sortingOrder
|
|
end
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function this:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return this |