miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/RewardEquipSingleShowPopup2...

397 lines
18 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2021-10-26 14:04:02 +08:00
local RewardEquipSingleShowPopup2 = Inherit(BasePanel)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
2020-05-09 13:31:21 +08:00
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2021-10-26 14:04:02 +08:00
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen)
local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp)
2021-10-26 14:04:02 +08:00
local _BaseProList = {}--基础属性对象
local _suitProList = {}--套装属性对象
local _superProList = {}--白金属性对象
2021-11-09 10:22:16 +08:00
local typeToUpdate = {
[2] = 2,--已穿戴->卸载单件
[3] = 1,--未穿戴->穿单件
[4] = 3,--未穿戴->替换单件
}
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function RewardEquipSingleShowPopup2:InitComponent()
2021-10-26 14:04:02 +08:00
self.spLoader = SpriteLoader.New()
self.mask = Util.GetGameObject(self.transform, "mask")
self.content = Util.GetGameObject(self.transform, "Content")
--装备详情--topBar
self.topBar = Util.GetGameObject(self.transform, "Content/topBar")
self.eqiopName = Util.GetGameObject(self.topBar, "name"):GetComponent("Text")
self.icon = Util.GetGameObject(self.topBar, "icon"):GetComponent("Image")
self.frame = Util.GetGameObject(self.topBar, "frame"):GetComponent("Image")
self.equipType=Util.GetGameObject(self.topBar, "equipType"):GetComponent("Text")
self.equipQuaText=Util.GetGameObject(self.topBar, "equipQuaText"):GetComponent("Text")
self.equipInfoText=Util.GetGameObject(self.topBar, "equipInfoText"):GetComponent("Text")
self.powerNum=Util.GetGameObject(self.topBar, "powerNum"):GetComponent("Text")
self.star=Util.GetGameObject(self.topBar, "star")
self.powerNumUpDown = Util.GetGameObject(self.topBar, "powerUPorDown"):GetComponent("Image")
2021-11-04 15:44:59 +08:00
self.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian")
2021-12-30 19:02:52 +08:00
self.hLv = Util.GetGameObject(self.topBar, "hLv"):GetComponent("Text")--家园摘星阁强化
self.hProLv = Util.GetGameObject(self.topBar, "hProLv"):GetComponent("Text")--家园摘星阁突破
2021-10-26 14:04:02 +08:00
--装备属性--midBar
--basePro
self.midBar = Util.GetGameObject(self.transform, "Content/midBar")
self.basePro = Util.GetGameObject(self.midBar, "basePro")
self.baseProName = Util.GetGameObject(self.basePro, "PropertyName"):GetComponent("Text")
self.baseProGrid = Util.GetGameObject(self.basePro, "grid")
self.baseProPre = Util.GetGameObject(self.basePro, "grid/curProName")
self.baseProPre:SetActive(false)
--suitPro
self.suitPro = Util.GetGameObject(self.midBar, "suitPro")
self.suitProName = Util.GetGameObject(self.suitPro, "PropertyName"):GetComponent("Text")
self.suitProGrid = Util.GetGameObject(self.suitPro, "proGrid")
self.suitProPre = Util.GetGameObject(self.suitPro, "proGrid/proPre")
self.suitProPre:SetActive(false)
--superPro
self.superPro = Util.GetGameObject(self.midBar, "superPro")
self.superProGrid = Util.GetGameObject(self.superPro, "proGrid")
self.superProPre = Util.GetGameObject(self.superPro, "proGrid/Desc")
self.superProPre:SetActive(false)
2020-05-09 13:31:21 +08:00
2021-10-26 14:04:02 +08:00
--分解按钮--btmBar
self.btmBar = Util.GetGameObject(self.transform, "Content/btmBar")
2021-11-09 10:22:16 +08:00
self.howGet = Util.GetGameObject(self.btmBar, "howGet")
self.btnGrid = Util.GetGameObject(self.btmBar, "btnGrid")
self.btnSure = Util.GetGameObject(self.btnGrid, "btnSure")
self.btnJump = Util.GetGameObject(self.btnGrid, "btnJump")
self.btnWear = Util.GetGameObject(self.btnGrid, "btnWear")
self.btnDown = Util.GetGameObject(self.btnGrid, "btnDown")
self.btnSwitch = Util.GetGameObject(self.btnGrid, "btnSwitch")
2021-10-26 14:04:02 +08:00
--装备获取途径--btmBar
self.canGetPre = Util.GetGameObject(self.btmBar, "scroll/canGetPre")
self.canGetGrid = Util.GetGameObject(self.btmBar, "scroll")
self.canGetScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.canGetGrid.transform,self.canGetPre, nil,
Vector2.New(self.canGetGrid.transform.rect.width, self.canGetGrid.transform.rect.height), 1, 1, Vector2.New(0, 0))
self.canGetScrollView.moveTween.MomentumAmount = 1
self.canGetScrollView.moveTween.Strength = 2
self.canGetScrollView.elastic = false
self.jumpViewList = {}
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function RewardEquipSingleShowPopup2:BindEvent()
2021-10-26 14:04:02 +08:00
Util.AddClick(self.mask, function()
2020-05-09 13:31:21 +08:00
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2021-11-09 10:22:16 +08:00
--跳转
2021-11-05 16:43:09 +08:00
Util.AddClick(self.btnJump, function()
if self.equipData.itemConfig then
JumpManager.GoJump(self.equipData.itemConfig.UseJump)
end
end)
--分解
Util.AddClick(self.btnSure, function()
--数量大于1 ,弹选择框
if BagManager.GetItemCountById(self.equipData.id) > 1 then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.EquipSingleSell,self.equipData)
self:ClosePanel()
elseif BagManager.GetItemCountById(self.equipData.id) == 1 then
--只有一个分解品质大于4 弹框
if self.equipData.itemConfig.Quantity>=4 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel,2,self.equipData.itemConfig.ItemBaseType,self.equipData)
else
local curResolveAllItemList={}
local equip = {}
equip.itemId = self.equipData.id
equip.itemNum = 1
table.insert(curResolveAllItemList,equip)
local type = 1
NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop)
self:SendBackResolveReCallBack(drop)
2021-11-05 16:43:09 +08:00
end)
end
else
PopupTipPanel.ShowTip(Language[11506])
end
end)
2021-11-09 10:22:16 +08:00
--穿戴
Util.AddClick(self.btnWear, function()
local equipIdList={}
local equipDataList={}
table.insert(equipIdList,tostring(self.equipData.id))
table.insert(equipDataList,self.equipData)
NetManager.EquipWearRequest(self.curHeroData.dynamicId,equipIdList,1,function ()
self:ClosePanel()
self.parent.UpdateEquipPosHeroData(1,typeToUpdate[self.openType],equipDataList,0,self.position)
end)
end)
--卸下
Util.AddClick(self.btnDown, function()
local equipIdList={}
local equipDataList={}
table.insert(equipIdList,tostring(self.equipData.id))
table.insert(equipDataList,self.equipData)
NetManager.EquipUnLoadOptRequest(self.curHeroData.dynamicId,equipIdList ,1, function ()
self:ClosePanel()
self.parent.UpdateEquipPosHeroData(1,typeToUpdate[self.openType],equipDataList)
end)
end)
--替换
Util.AddClick(self.btnSwitch, function()
local equipIdList={}
local equipDataList={}
table.insert(equipIdList,tostring(self.equipData.id))
2021-11-17 12:34:39 +08:00
table.insert(equipDataList,self.equipData)
2021-11-09 10:22:16 +08:00
NetManager.EquipWearRequest(self.curHeroData.dynamicId,equipIdList ,1, function ()
self:ClosePanel()
2021-11-17 12:34:39 +08:00
self.parent.UpdateEquipPosHeroData(1,typeToUpdate[self.openType],equipDataList,self.nextEquip,self.position)
2021-11-09 10:22:16 +08:00
end)
end)
2020-05-09 13:31:21 +08:00
end
--道具 和 装备分解 发送请求后 回调
function RewardEquipSingleShowPopup2: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 self.func then
self.func()
end
self:ClosePanel()
end
2020-05-09 13:31:21 +08:00
--添加事件监听(用于子类重写)
function RewardEquipSingleShowPopup2:AddListener()
end
--移除事件监听(用于子类重写)
function RewardEquipSingleShowPopup2:RemoveListener()
end
2021-12-23 16:39:37 +08:00
function RewardEquipSingleShowPopup2:OnSortingOrderChange()
Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
end
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
2021-11-09 10:22:16 +08:00
function RewardEquipSingleShowPopup2:OnOpen(_parent,_equipData,_openType,_isShowGet,_isShowGo,_curHeroData,_position,_targetEquipData,_func)
2021-10-26 14:04:02 +08:00
if not _equipData then
return
end
2021-11-09 10:22:16 +08:00
self.parent = _parent --父界面
self.equipData = _equipData --当前装备数据
self.openType = _openType --0不显示按钮、1背包、2已穿戴显示卸下、3未穿戴显示穿戴、4未穿戴显示替换
self.howGet:SetActive(_isShowGet and true or false)--是否显示获取途径
self.btnGrid:SetActive(self.openType ~= 0)
self.curHeroData = _curHeroData --装备了该装备的英雄数据
self.position = _position --装备的位置
self.nextEquip = _targetEquipData--要替换的目标装备
if _targetEquipData then
LogGreen("Id:"..tostring(_equipData.id).." Id2:"..tostring(_targetEquipData.id))
end
2021-11-09 10:22:16 +08:00
self.isShowGo = _isShowGo and _isShowGo or false--是否显示跳转按钮
self.func = _func
end
function RewardEquipSingleShowPopup2:SetBtns()
local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, tonumber(self.equipData.id))
2021-11-17 12:34:39 +08:00
self.btnSure:SetActive(itemConfigData.IfResolve==1 and BagManager.isBagPanel)
2021-11-09 10:22:16 +08:00
self.btnJump:SetActive(itemConfigData.UseJump and itemConfigData.UseJump > 0 and BagManager.isBagPanel)
self.btnWear:SetActive(self.openType == 3)
self.btnDown:SetActive(self.openType == 2)
self.btnSwitch:SetActive(self.openType == 4)
2021-10-26 14:04:02 +08:00
end
function RewardEquipSingleShowPopup2:OnShow()
--上部装备基础信息
2021-11-09 10:22:16 +08:00
Log("装备id:"..tostring(self.equipData.id).." openType:"..tostring(self.openType))
self:SetBtns()
2021-11-05 16:43:09 +08:00
local equipConfigData=ConfigManager.GetConfigData(ConfigName.EquipConfig, tonumber(self.equipData.id))
local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, tonumber(self.equipData.id))
2021-10-26 14:04:02 +08:00
self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_"..equipConfigData.Quality)
self.equipQuaText.text=GetStringByEquipQua(equipConfigData.Quality,GetQuaStringByEquipQua(equipConfigData.Quality))
self.eqiopName.text=GetStringByEquipQua(equipConfigData.Quality,GetLanguageStrById(equipConfigData.Name))
self.frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(equipConfigData.Quality))
self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfigData.ResourceID))
self.equipInfoText.text=GetLanguageStrById(itemConfigData.ItemDescribe)
2021-11-05 16:43:09 +08:00
self.powerNum.text=EquipManager.CalculateWarForce(self.equipData.id)
2021-10-26 14:04:02 +08:00
EquipManager.SetEquipStarShow(self.spLoader, self.star,equipConfigData.Id)
self.equipType.text=Language[11089]..GetEquipPosStrByEquipPosNum(equipConfigData.Position)
2021-12-30 19:02:52 +08:00
--摘星阁加持
2021-12-30 19:02:52 +08:00
self.hLv.text = ""
self.hProLv.text = ""
if self.equipData.homeEquipLv and self.equipData.homeEquipLv[1] > 0 then
self.hLv.text = self.equipData.homeEquipLv[1] > 0 and self.equipData.homeEquipLv[1] or ""
self.hProLv.text = self.equipData.homeEquipLv[2] > 0 and self.equipData.homeEquipLv[2] or ""
2021-12-30 19:02:52 +08:00
end
2021-10-26 14:04:02 +08:00
--下部按钮信息
2021-11-04 15:44:59 +08:00
self.effectbaijin:SetActive(equipConfigData.Quality==7)
Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
if self.openType == 4 then
self.powerNumUpDown.gameObject:SetActive(true)
local Power = EquipManager.CalculateWarForce(self.equipData.id)
local Power2 = EquipManager.CalculateWarForce(self.nextEquip.id)
2021-11-17 12:34:39 +08:00
-- LogGreen("Id:"..tostring(self.equipData.id).." Power:"..tostring(Power).." Id2:"..tostring(self.equipData.id).." Power2:"..tostring(Power2))
if(Power > Power2) then
self.powerNumUpDown.sprite = self.spLoader:LoadSprite(PowerChangeIconDef[1])
elseif(Power < Power2)then
self.powerNumUpDown.sprite = self.spLoader:LoadSprite(PowerChangeIconDef[2])
else
self.powerNumUpDown.gameObject:SetActive(false)
end
else
self.powerNumUpDown.gameObject:SetActive(false)
end
2021-10-26 14:04:02 +08:00
--basePro基础属性
if equipConfigData.Property then
self.basePro:SetActive(true)
for _, pro in ipairs(_BaseProList) do
pro:SetActive(false)
end
2021-10-26 14:04:02 +08:00
for index, prop in ipairs(equipConfigData.Property) do
local proConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, prop[1])
if proConfigData then
--基础属性
2021-10-26 14:04:02 +08:00
if not _BaseProList[index] then
_BaseProList[index] = newObjToParent(self.baseProPre, self.baseProGrid)
end
_BaseProList[index]:SetActive(true)
_BaseProList[index]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)
local vText = Util.GetGameObject(_BaseProList[index], "curProVale"):GetComponent("Text")
--摘星阁加持
local power = prop[2]
local hText = Util.GetGameObject(vText.gameObject, "homeValue"):GetComponent("Text")
hText.text = ""
if self.equipData.homeEquipLv and self.equipData.homeEquipLv[1] > 0 and proConfigData.Style == 1 then
local num = HomeLandManager.LevelToValue(self.equipData.homeEquipLv,self.equipData.position)
hText.text = string.format("(摘星阁加持:%s",num).."%)"
power = math.ceil(power*(1 + num/100))
end
if power > 0 then
vText.text = "+"..GetPropertyFormatStr(proConfigData.Style, power)
else
vText.text = GetPropertyFormatStr(proConfigData.Style, power)
end
2021-10-26 14:04:02 +08:00
end
end
else
self.basePro:SetActive(false)
end
2020-05-09 13:31:21 +08:00
2021-10-26 14:04:02 +08:00
--suitPro套装属性
2021-11-09 10:22:16 +08:00
local equipSuit = {}
2021-11-05 16:43:09 +08:00
if self.curHeroData then
2021-11-09 10:22:16 +08:00
equipSuit = HeroManager.GetCurHeroEquipSuitPros(self.curHeroData.equipIdList)
2021-11-05 16:43:09 +08:00
end
2021-10-26 14:04:02 +08:00
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
if suitConFig[equipConfigData.Star] then
self.suitPro:SetActive(true)
local curSuitConFig = suitConFig[equipConfigData.Star]
2020-05-09 13:31:21 +08:00
if curSuitConFig then
2021-10-26 14:04:02 +08:00
for i = 1, math.max(#curSuitConFig.SuiteValue, #_suitProList) do
if not _suitProList[i] then
_suitProList[i] = newObjToParent(self.suitProPre, self.suitProGrid)
2020-05-09 13:31:21 +08:00
end
2021-10-26 14:04:02 +08:00
_suitProList[i].gameObject:SetActive(true)
2020-05-09 13:31:21 +08:00
end
for i = 1, #curSuitConFig.SuiteValue do
2021-10-26 14:04:02 +08:00
_suitProList[i].gameObject:SetActive(true)
local name = Util.GetGameObject(_suitProList[i].transform, "proName"):GetComponent("Text")
local value = Util.GetGameObject(_suitProList[i].transform, "proVale"):GetComponent("Text")
2021-11-09 10:22:16 +08:00
local color = #equipSuit >= i and "00ff66" or "FCEBCA"
name.text = string.format("<color=#%s>%s+ %s</color>",color,GetLanguageStrById(propertyConfig[curSuitConFig.SuiteValue[i][2]].Info),GetPropertyFormatStr(propertyConfig[curSuitConFig.SuiteValue[i][2]].Style,curSuitConFig.SuiteValue[i][3]))
value.text = string.format("<color=#%s>(%s件激活)</color>",color,curSuitConFig.SuiteValue[i][1])
2021-10-26 14:04:02 +08:00
end
end
else
self.suitPro:SetActive(false)
end
--super白金套装属性
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
local curSuitConFig = suitConFig[equipConfigData.Star]
if curSuitConFig and curSuitConFig.SuiteSkill then
self.superPro:SetActive(true)
if curSuitConFig then
for i = 1, math.max(#curSuitConFig.SuiteSkill, #_superProList) do
if not _superProList[i] then
_superProList[i] = newObjToParent(self.superProPre, self.superProGrid)
end
_superProList[i].gameObject:SetActive(true)
end
for i = 1, #curSuitConFig.SuiteSkill do
local go = _superProList[i]
2020-05-09 13:31:21 +08:00
go.gameObject:SetActive(true)
2021-11-09 10:22:16 +08:00
local name = Util.GetGameObject(go.transform, "Name"):GetComponent("Text")
local value = Util.GetGameObject(go.transform, "Name/vale"):GetComponent("Text")
local color = #equipSuit >= i and "00ff66" or "FCEBCA"
name.text = string.format("不朽天赋%s",i)
go:GetComponent("Text").text = string.format("<color=#%s>%s</color>",color,GetLanguageStrById(passiveSkillConfig[curSuitConFig.SuiteSkill[i][2]].Desc))
value.text = string.format("<color=#FCEBCA>(%s)</color>",GetEquipSuitStr(curSuitConFig.Id,curSuitConFig.SuiteSkill[i][1]))
2020-05-09 13:31:21 +08:00
end
end
else
2021-10-26 14:04:02 +08:00
self.superPro:SetActive(false)
end
--获取途径
if self.jumpViewList and #self.jumpViewList > 0 then
for i = 1,#self.jumpViewList do
SubUIManager.Close(self.jumpViewList[i])
end
end
2021-11-05 16:43:09 +08:00
local curitemData = itemConfig[tonumber(self.equipData.id)]
2021-10-26 14:04:02 +08:00
if curitemData and curitemData.Jump then
if curitemData.Jump and #curitemData.Jump>0 then
self.canGetScrollView:SetData(curitemData.Jump,function (index, item)
local tempView = nil
2021-11-09 10:22:16 +08:00
if self.isShowGo then
2021-10-26 14:04:02 +08:00
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index],true)
2021-11-09 10:22:16 +08:00
else
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index],false)
2021-10-26 14:04:02 +08:00
end
table.insert(self.jumpViewList,tempView)
end,true,true)
end
2020-05-09 13:31:21 +08:00
end
2021-11-09 10:22:16 +08:00
--(此处需要三遍才能完全打开)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
if self.func then
self.func()
end
2020-05-09 13:31:21 +08:00
end
--界面关闭时调用(用于子类重写)
function RewardEquipSingleShowPopup2:OnClose()
2021-10-26 14:04:02 +08:00
for i = 1, #self.jumpViewList do
destroy(self.jumpViewList[i].gameObject)
end
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function RewardEquipSingleShowPopup2:OnDestroy()
2021-10-26 14:04:02 +08:00
self.spLoader:Destroy()
_BaseProList = {}
_suitProList = {}
_superProList = {}
self.jumpViewList = {}
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return RewardEquipSingleShowPopup2