374 lines
16 KiB
Lua
374 lines
16 KiB
Lua
require("Base/BasePanel")
|
||
RewardEquipSingleShowPopup = Inherit(BasePanel)
|
||
local this = RewardEquipSingleShowPopup
|
||
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
local equipData
|
||
local func
|
||
local isRewardItemPop
|
||
local curSuitProGo = {} --当前套装属性对象
|
||
local baijinProGo = {} --当前套装属性对象
|
||
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
||
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
||
local _MainProList = {}
|
||
local isShowfenjie = true
|
||
--初始化组件(用于子类重写)
|
||
function RewardEquipSingleShowPopup:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
|
||
this.eqiopName = Util.GetGameObject(self.transform, "Content/bg/Text"):GetComponent("Text")
|
||
this.BtnBack = Util.GetGameObject(self.transform, "Content/bg/btnBack")
|
||
--装备详情
|
||
this.icon = Util.GetGameObject(self.transform, "Content/bg/armorInfo/icon"):GetComponent("Image")
|
||
this.frame = Util.GetGameObject(self.transform, "Content/bg/armorInfo/frame"):GetComponent("Image")
|
||
this.equipType = Util.GetGameObject(self.transform, "Content/bg/armorInfo/grid/equipType"):GetComponent("Text")
|
||
-- this.equipPos=Util.GetGameObject(self.transform, "Content/bg/armorInfo/grid/equipPos"):GetComponent("Text")--装备关闭职业限定
|
||
this.equipRebuildLv = Util.GetGameObject(self.transform, "Content/bg/armorInfo/grid/equipRebuildLv")
|
||
this.equipRebuildLv:SetActive(false)
|
||
this.equipQuaText = Util.GetGameObject(self.transform, "Content/bg/armorInfo/equipQuaText"):GetComponent("Text")
|
||
this.equipInfoText = Util.GetGameObject(self.transform, "Content/bg/armorInfo/equipInfoText"):GetComponent("Text")
|
||
this.powerNum = Util.GetGameObject(self.transform, "Content/bg/armorInfo/powerNum"):GetComponent("Text")
|
||
this.star = Util.GetGameObject(self.transform, "Content/bg/armorInfo/star")
|
||
--装备属性
|
||
this.equipOtherProPre = Util.GetGameObject(self.transform, "Content/proPre")
|
||
this.equipProGrid = Util.GetGameObject(self.transform, "Content/proRect/proGrid")
|
||
this.mainPro = Util.GetGameObject(self.transform, "Content/mainPro")
|
||
this.mainProGrid = Util.GetGameObject(self.transform, "Content/mainPro/bg")
|
||
this.mainProItem = Util.GetGameObject(self.transform, "Content/mainPro/bg/curProName")
|
||
this.mainProItem:SetActive(false)
|
||
-- 不朽属性
|
||
this.baijinProPre = Util.GetGameObject(self.transform, "Content/baijinRect/baijinPro")
|
||
this.baijinProGrid = Util.GetGameObject(self.transform, "Content/baijinRect/proGrid")
|
||
|
||
-- this.mainProName=Util.GetGameObject(self.transform, "Content/mainPro/bg/curProName"):GetComponent("Text")
|
||
-- this.mainProVale=Util.GetGameObject(self.transform, "Content/mainPro/bg/curProName/curProVale"):GetComponent("Text")
|
||
--装备获取途径
|
||
--this.getTuPre=Util.GetGameObject(self.transform, "Content/bg/getTuPre")
|
||
this.getTuGrid = Util.GetGameObject(self.transform, "Content/bg/scroll/grid")
|
||
this.equipProGridCom = this.getTuGrid:GetComponent("VerticalLayoutGroup")
|
||
--装备被动技能
|
||
this.skillObject = Util.GetGameObject(self.transform, "Content/skillObject")
|
||
this.skillInfo = Util.GetGameObject(self.transform, "Content/skillObject/skillInfo"):GetComponent("Text")
|
||
this.skillObject:SetActive(false)
|
||
--分解按钮
|
||
this.btnSure = Util.GetGameObject(self.transform, "Content/bg/btnGrid/btnSure")
|
||
this.btnJump = Util.GetGameObject(self.transform, "Content/bg/btnGrid/btnJump")
|
||
this.btnLock = Util.GetGameObject(self.transform, "Content/bg/btnLock")
|
||
this.upLockImage = Util.GetGameObject(self.transform, "Content/bg/btnLock/upLock")
|
||
this.downLockImage = Util.GetGameObject(self.transform, "Content/bg/btnLock/downLock")
|
||
|
||
this.mask = Util.GetGameObject(self.transform, "mask")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function RewardEquipSingleShowPopup:BindEvent()
|
||
Util.AddClick(this.BtnBack, function()
|
||
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.mask, function()
|
||
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.btnJump, function()
|
||
if equipData.itemConfig then
|
||
JumpManager.GoJump(equipData.itemConfig.UseJump)
|
||
end
|
||
end)
|
||
Util.AddClick(this.btnSure, function()
|
||
--数量大于1 ,弹选择框
|
||
if BagManager.GetItemCountById(equipData.id) > 1 then
|
||
UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.EquipSingleSell, equipData, func)
|
||
this:ClosePanel()
|
||
elseif BagManager.GetItemCountById(equipData.id) == 1 then
|
||
--只有一个,分解品质大于4, 弹框
|
||
if equipData.itemConfig.Quantity >= 4 then
|
||
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 2, equipData.itemConfig.ItemBaseType, equipData,
|
||
function()
|
||
if func then
|
||
func()
|
||
end
|
||
end)
|
||
else
|
||
local curResolveAllItemList = {}
|
||
local equip = {}
|
||
equip.itemId = equipData.id
|
||
equip.itemNum = 1
|
||
table.insert(curResolveAllItemList, equip)
|
||
local type = 1
|
||
NetManager.UseAndPriceItemRequest(type, curResolveAllItemList, function(drop)
|
||
this.SendBackResolveReCallBack(drop)
|
||
end)
|
||
end
|
||
else
|
||
PopupTipPanel.ShowTip(Language[12179])
|
||
end
|
||
end)
|
||
Util.AddClick(this.btnLock, function()
|
||
self:OnLockClickEvent()
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function RewardEquipSingleShowPopup:AddListener()
|
||
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function RewardEquipSingleShowPopup:RemoveListener()
|
||
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function RewardEquipSingleShowPopup:OnOpen(_equipData, _func, _isRewardItemPop, _isShowfenjie)
|
||
if not _equipData then
|
||
return
|
||
end
|
||
equipData = _equipData
|
||
func = _func
|
||
isRewardItemPop = _isRewardItemPop and _isRewardItemPop or false
|
||
-- isShowfenjie = not not (_isShowfenjie or false)
|
||
end
|
||
|
||
function RewardEquipSingleShowPopup:OnShow()
|
||
--装备基础信息
|
||
LogBlue(equipData.id)
|
||
-- LogBlue(tonumber(equipData.id))
|
||
local equipConfigData = ConfigManager.GetConfigData(ConfigName.EquipConfig, tonumber(equipData.id))
|
||
local itemConfigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, tonumber(equipData.id))
|
||
this.btnSure:SetActive(itemConfigData.IfResolve == 1)
|
||
--local curEquipData = {}
|
||
-- if func and itemConfigData.IfResolve==1 then
|
||
-- curEquipData = EquipManager.GetSingleEquipData(equipData.id)
|
||
-- -- if curEquipData and curEquipData.upHeroDid == "0" then
|
||
-- -- this.btnSure:SetActive(true)
|
||
-- -- end
|
||
-- end
|
||
-- if curEquipData then
|
||
-- --Log("equipData.isLocked "..curEquipData.isLocked)
|
||
-- --this.upLockImage:SetActive(curEquipData.isLocked == 1)
|
||
-- --this.downLockImage:SetActive(curEquipData.isLocked == 0)
|
||
-- end
|
||
|
||
this.equipQuaText.text = GetStringByEquipQua(equipConfigData.Quality, GetQuaStringByEquipQua(equipConfigData.Quality))
|
||
this.eqiopName.text = GetStringByEquipQua(equipConfigData.Quality, GetLanguageStrById(equipConfigData.Name))
|
||
|
||
--if equipConfigData.IfClear==0 then
|
||
-- this.equipRebuildLv:GetComponent("Text").text="不可重铸"
|
||
--elseif equipConfigData.IfClear==1 then
|
||
-- this.equipRebuildLv:GetComponent("Text").text="重铸等级:"..equipData.rebuildLevel
|
||
--end
|
||
this.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(equipConfigData.Quality))
|
||
this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfigData.ResourceID))
|
||
this.equipInfoText.text = GetLanguageStrById(itemConfigData.ItemDescribe)
|
||
|
||
this.powerNum.text = EquipManager.CalculateWarForce(equipData.id)
|
||
EquipManager.SetEquipStarShow(this.spLoader, this.star, equipConfigData.Id)
|
||
|
||
this.btnJump:SetActive(itemConfigData.UseJump and itemConfigData.UseJump > 0 and BagManager.isBagPanel)
|
||
|
||
local passiveCfg = {}
|
||
if equipData.skillId and equipData.skillId > 0 then
|
||
passiveCfg = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig, equipData.skillId)
|
||
end
|
||
if passiveCfg and equipData.skillId and equipData.skillId > 0 then
|
||
this.skillObject:SetActive(true)
|
||
this.skillInfo.text = GetLanguageStrById(passiveCfg.Desc)
|
||
else
|
||
this.skillObject:SetActive(false)
|
||
end
|
||
this.equipType.text = Language[11172] .. GetEquipPosStrByEquipPosNum(equipConfigData.Position)
|
||
-- this.equipPos.text=string.format("职业限定:%s",GetJobStrByJobNum(equipConfigData.ProfessionLimit)) --装备关闭职业限定
|
||
--装备属性
|
||
for _, item in ipairs(_MainProList) do
|
||
item:SetActive(false)
|
||
end
|
||
if equipConfigData.Property then
|
||
this.mainPro:SetActive(true)
|
||
for index, prop in ipairs(equipConfigData.Property) do
|
||
local proConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, prop[1])
|
||
if proConfigData then
|
||
if not _MainProList[index] then
|
||
_MainProList[index] = newObjToParent(this.mainProItem, this.mainProGrid)
|
||
end
|
||
_MainProList[index]:SetActive(true)
|
||
_MainProList[index]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)
|
||
local vText = Util.GetGameObject(_MainProList[index], "curProVale"):GetComponent("Text")
|
||
if prop[2] > 0 then
|
||
vText.text = "+" .. GetPropertyFormatStr(proConfigData.Style, prop[2])
|
||
else
|
||
vText.text = GetPropertyFormatStr(proConfigData.Style, prop[2])
|
||
end
|
||
end
|
||
end
|
||
else
|
||
this.mainPro:SetActive(false)
|
||
end
|
||
|
||
--套装属性
|
||
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
|
||
if suitConFig[equipConfigData.Star] then
|
||
Util.GetGameObject(self.transform, "Content/proRect"):SetActive(true)
|
||
local curSuitConFig = suitConFig[equipConfigData.Star]
|
||
if curSuitConFig then
|
||
for i = 1, math.max(#curSuitConFig.SuiteValue, #curSuitProGo) do
|
||
local go = curSuitProGo[i]
|
||
if not go then
|
||
go = newObject(this.equipOtherProPre)
|
||
go.transform:SetParent(this.equipProGrid.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
curSuitProGo[i] = go
|
||
end
|
||
go.gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #curSuitConFig.SuiteValue do
|
||
local go = curSuitProGo[i]
|
||
go.gameObject:SetActive(true)
|
||
Util.GetGameObject(go.transform, "proName"):GetComponent("Text").text = "<color=#B9AC97>" ..
|
||
GetLanguageStrById(propertyConfig[curSuitConFig.SuiteValue[i][2]].Info) ..
|
||
"+ " ..
|
||
GetPropertyFormatStr(propertyConfig[curSuitConFig.SuiteValue[i][2]].Style,
|
||
curSuitConFig.SuiteValue[i]
|
||
[3]) .. "</color>"
|
||
Util.GetGameObject(go.transform, "proVale"):GetComponent("Text").text = "<color=#B9AC97>(" ..
|
||
curSuitConFig.SuiteValue[i][1] .. Language[11531]
|
||
end
|
||
end
|
||
else
|
||
Util.GetGameObject(self.transform, "Content/proRect"):SetActive(false)
|
||
end
|
||
--白金套装属性
|
||
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
|
||
local curSuitConFig = suitConFig[equipConfigData.Star]
|
||
if curSuitConFig and curSuitConFig.SuiteSkill then
|
||
this.baijinProGrid.transform.parent.gameObject:SetActive(true)
|
||
if curSuitConFig then
|
||
for i = 1, math.max(#curSuitConFig.SuiteSkill, #baijinProGo) do
|
||
local go = baijinProGo[i]
|
||
if not go then
|
||
go = newObject(this.baijinProPre)
|
||
go.transform:SetParent(this.baijinProGrid.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
baijinProGo[i] = go
|
||
end
|
||
go.gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #curSuitConFig.SuiteSkill do
|
||
local go = baijinProGo[i]
|
||
go.gameObject:SetActive(true)
|
||
local Star = curSuitConFig.Id
|
||
local suitNum = curSuitConFig.SuiteSkill[i][1]
|
||
local passiveId = curSuitConFig.SuiteSkill[i][2]
|
||
go:GetComponent("Text").text = "<color=#B9AC97>" ..
|
||
GetLanguageStrById(passiveSkillConfig[passiveId].Desc) .. "</color>"
|
||
Util.GetGameObject(go.transform, "title/vale"):GetComponent("Text").text = "<color=#B9AC97>(" ..
|
||
GetEquipSuitStr(Star, suitNum) .. ")</color>"
|
||
Util.GetGameObject(go.transform, "title"):GetComponent("Text").text = Language[12180] .. i .. ":"
|
||
end
|
||
end
|
||
else
|
||
this.baijinProGrid.transform.parent.gameObject:SetActive(false)
|
||
end
|
||
|
||
if this.jumpViewList and #this.jumpViewList > 0 then
|
||
for i = 1, #this.jumpViewList do
|
||
SubUIManager.Close(this.jumpViewList[i])
|
||
end
|
||
end
|
||
this.jumpViewList = {}
|
||
|
||
local curitemData = itemConfig[tonumber(equipData.id)]
|
||
if curitemData and curitemData.Jump then
|
||
if curitemData.Jump and #curitemData.Jump > 0 then
|
||
for i = 1, #curitemData.Jump do
|
||
local tempView = nil
|
||
if isRewardItemPop then
|
||
tempView = SubUIManager.Open(SubUIConfig.JumpView, this.getTuGrid.transform, curitemData.Jump[i],
|
||
false)
|
||
else
|
||
tempView = SubUIManager.Open(SubUIConfig.JumpView, this.getTuGrid.transform, curitemData.Jump[i],
|
||
true)
|
||
end
|
||
if tempView then
|
||
table.insert(this.jumpViewList, tempView)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
this.equipProGridCom.spacing = 130
|
||
if this.jumpViewList and #this.jumpViewList then
|
||
this.getTuGrid:GetComponent("RectTransform").sizeDelta = Vector2.New(911.56,
|
||
this.equipProGridCom.spacing * (#this.jumpViewList))
|
||
end
|
||
|
||
ForceRebuildLayout(this.mainPro.transform)
|
||
end
|
||
|
||
--道具 和 装备分解 发送请求后 回调
|
||
function this.SendBackResolveReCallBack(drop)
|
||
local isShowReward = false
|
||
if drop.itemlist ~= nil and #drop.itemlist > 0 then
|
||
for i = 1, #drop.itemlist do
|
||
if drop.itemlist[i].itemNum > 0 then
|
||
isShowReward = true
|
||
break
|
||
end
|
||
end
|
||
end
|
||
if isShowReward then
|
||
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function()
|
||
BagManager.OnShowTipDropNumZero(drop)
|
||
end)
|
||
else
|
||
BagManager.OnShowTipDropNumZero(drop)
|
||
end
|
||
if func then
|
||
func()
|
||
end
|
||
this:ClosePanel()
|
||
end
|
||
|
||
function RewardEquipSingleShowPopup:OnLockClickEvent()
|
||
if equipData and equipData.isLocked == 0 then --未上锁
|
||
NetManager.EquipLockRequest({ equipData.id }, 1, function()
|
||
this.upLockImage:SetActive(true)
|
||
this.downLockImage:SetActive(false)
|
||
end)
|
||
elseif equipData and equipData.isLocked == 1 then --已上锁
|
||
NetManager.EquipLockRequest({ equipData.id }, 2, function()
|
||
this.upLockImage:SetActive(false)
|
||
this.downLockImage:SetActive(true)
|
||
end)
|
||
end
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function RewardEquipSingleShowPopup:OnClose()
|
||
if this.jumpViewList and #this.jumpViewList > 0 then
|
||
for i = 1, #this.jumpViewList do
|
||
SubUIManager.Close(this.jumpViewList[i])
|
||
end
|
||
end
|
||
this.jumpViewList = {}
|
||
--if func then
|
||
-- func()
|
||
--end
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function RewardEquipSingleShowPopup:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
curSuitProGo = {}
|
||
baijinProGo = {}
|
||
_MainProList = {}
|
||
if this.jumpViewList and #this.jumpViewList > 0 then
|
||
for i = 1, #this.jumpViewList do
|
||
SubUIManager.Close(this.jumpViewList[i])
|
||
end
|
||
end
|
||
this.jumpViewList = {}
|
||
end
|
||
|
||
return RewardEquipSingleShowPopup
|