miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/RewardEquipSingleShowPopup.lua

359 lines
16 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
RewardEquipSingleShowPopup = Inherit(BasePanel)
local this=RewardEquipSingleShowPopup
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipData
local func
local isRewardItemPop
local curSuitProGo = {}--当前套装属性对象
2021-09-26 17:13:12 +08:00
local baijinProGo = {}--当前套装属性对象
2020-05-09 13:31:21 +08:00
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2021-09-26 17:13:12 +08:00
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
2020-06-13 11:47:13 +08:00
local _MainProList = {}
local isShowfenjie =true
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function RewardEquipSingleShowPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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")
2020-06-13 11:47:13 +08:00
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)
2021-09-26 17:13:12 +08:00
-- 不朽属性
this.baijinProPre = Util.GetGameObject(self.transform, "Content/baijinRect/baijinPro")
this.baijinProGrid = Util.GetGameObject(self.transform, "Content/baijinRect/proGrid")
2020-06-13 11:47:13 +08:00
-- 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")
2020-05-09 13:31:21 +08:00
--装备获取途径
--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")
2020-05-09 13:31:21 +08:00
--装备被动技能
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")
2020-05-09 13:31:21 +08:00
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)
2020-05-09 13:31:21 +08:00
Util.AddClick(this.btnJump, function()
2020-07-06 20:35:39 +08:00
if equipData.itemConfig then
JumpManager.GoJump(equipData.itemConfig.UseJump)
2020-05-09 13:31:21 +08:00
end
end)
Util.AddClick(this.btnSure, function()
2020-07-11 16:21:15 +08:00
--数量大于1 ,弹选择框
2020-07-10 18:29:38 +08:00
if BagManager.GetItemCountById(equipData.id) > 1 then
2020-07-11 16:21:15 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.EquipSingleSell,equipData,func)
2020-07-13 11:15:53 +08:00
this:ClosePanel()
2020-07-11 16:21:15 +08:00
elseif BagManager.GetItemCountById(equipData.id) == 1 then
--只有一个分解品质大于4 弹框
2020-07-10 18:29:38 +08:00
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
2020-07-11 16:21:15 +08:00
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11506])
2020-07-10 18:29:38 +08:00
end
2020-05-09 13:31:21 +08:00
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)
2020-05-09 13:31:21 +08:00
if not _equipData then
return
end
equipData=_equipData
func=_func
isRewardItemPop = _isRewardItemPop and _isRewardItemPop or false
-- isShowfenjie = not not (_isShowfenjie or false)
2020-05-09 13:31:21 +08:00
end
function RewardEquipSingleShowPopup:OnShow()
--装备基础信息
2020-07-06 20:35:39 +08:00
LogBlue(equipData.id)
2020-07-23 11:19:27 +08:00
-- LogBlue(tonumber(equipData.id))
2020-07-06 20:35:39 +08:00
local equipConfigData=ConfigManager.GetConfigData(ConfigName.EquipConfig, tonumber(equipData.id))
local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, tonumber(equipData.id))
this.btnSure:SetActive(itemConfigData.IfResolve==1)
2020-07-06 20:35:39 +08:00
--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
2020-05-09 13:31:21 +08:00
this.equipQuaText.text=GetStringByEquipQua(equipConfigData.Quality,GetQuaStringByEquipQua(equipConfigData.Quality))
2021-01-26 17:08:39 +08:00
this.eqiopName.text=GetStringByEquipQua(equipConfigData.Quality,GetLanguageStrById(equipConfigData.Name))
2020-05-09 13:31:21 +08:00
--if equipConfigData.IfClear==0 then
-- this.equipRebuildLv:GetComponent("Text").text="不可重铸"
--elseif equipConfigData.IfClear==1 then
-- this.equipRebuildLv:GetComponent("Text").text="重铸等级:"..equipData.rebuildLevel
--end
2021-04-21 13:12:04 +08:00
this.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(equipConfigData.Quality))
this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfigData.ResourceID))
2021-01-26 17:08:39 +08:00
this.equipInfoText.text=GetLanguageStrById(itemConfigData.ItemDescribe)
2020-07-06 20:35:39 +08:00
this.powerNum.text=EquipManager.CalculateWarForce(equipData.id)
2021-04-21 13:12:04 +08:00
EquipManager.SetEquipStarShow(this.spLoader, this.star,equipConfigData.Id)
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
this.btnJump:SetActive(itemConfigData.UseJump and itemConfigData.UseJump > 0 and BagManager.isBagPanel)
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
local passiveCfg={}
if equipData.skillId and equipData.skillId>0 then
passiveCfg = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig, equipData.skillId)
end
2020-07-06 20:35:39 +08:00
if passiveCfg and equipData.skillId and equipData.skillId>0 then
this.skillObject:SetActive(true)
2021-01-26 17:08:39 +08:00
this.skillInfo.text=GetLanguageStrById(passiveCfg.Desc)
2020-07-06 20:35:39 +08:00
else
this.skillObject:SetActive(false)
end
2021-03-02 16:53:12 +08:00
this.equipType.text=Language[11089]..GetEquipPosStrByEquipPosNum(equipConfigData.Position)
2020-05-09 13:31:21 +08:00
-- this.equipPos.text=string.format("职业限定:%s",GetJobStrByJobNum(equipConfigData.ProfessionLimit)) --装备关闭职业限定
--装备属性
2020-06-13 11:47:13 +08:00
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)
2021-01-26 17:08:39 +08:00
_MainProList[index]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)
2020-06-13 11:47:13 +08:00
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
2020-05-09 13:31:21 +08:00
--套装属性
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
if suitConFig[equipConfigData.Star] then
2020-05-09 13:31:21 +08:00
Util.GetGameObject(self.transform, "Content/proRect"):SetActive(true)
local curSuitConFig = suitConFig[equipConfigData.Star]
2020-05-09 13:31:21 +08:00
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)
2021-01-26 17:08:39 +08:00
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>"
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform, "proVale"):GetComponent("Text").text = "<color=#B9AC97>(" .. curSuitConFig.SuiteValue[i][1] .. Language[11091]
2020-05-09 13:31:21 +08:00
end
end
else
Util.GetGameObject(self.transform, "Content/proRect"):SetActive(false)
end
2021-09-26 17:13:12 +08:00
--白金套装属性
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, "vale"):GetComponent("Text").text = "<color=#B9AC97>(" .. GetEquipSuitStr(Star,suitNum) .. ")</color>"
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 = {}
2020-07-06 20:35:39 +08:00
local curitemData = itemConfig[tonumber(equipData.id)]
2020-05-09 13:31:21 +08:00
if curitemData and curitemData.Jump then
if curitemData.Jump and #curitemData.Jump>0 then
for i = 1, #curitemData.Jump do
local tempView = nil
2020-05-09 13:31:21 +08:00
if isRewardItemPop then
tempView = SubUIManager.Open(SubUIConfig.JumpView, this.getTuGrid.transform, curitemData.Jump[i],false)
2020-05-09 13:31:21 +08:00
else
tempView = SubUIManager.Open(SubUIConfig.JumpView, this.getTuGrid.transform, curitemData.Jump[i],true)
end
if tempView then
table.insert(this.jumpViewList,tempView)
2020-05-09 13:31:21 +08:00
end
end
end
end
this.equipProGridCom.spacing = 150
if this.jumpViewList and #this.jumpViewList then
this.getTuGrid:GetComponent("RectTransform").sizeDelta = Vector2.New(911.56,this.equipProGridCom.spacing*(#this.jumpViewList))
end
2020-05-09 13:31:21 +08:00
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 = {}
2020-05-09 13:31:21 +08:00
--if func then
-- func()
--end
end
--界面销毁时调用(用于子类重写)
function RewardEquipSingleShowPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
curSuitProGo = {}
2021-09-26 17:13:12 +08:00
baijinProGo = {}
2020-06-13 11:47:13 +08:00
_MainProList = {}
if this.jumpViewList and #this.jumpViewList > 0 then
for i = 1,#this.jumpViewList do
SubUIManager.Close(this.jumpViewList[i])
end
end
this.jumpViewList = {}
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return RewardEquipSingleShowPopup