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

390 lines
18 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
RewardItemSingleShowPopup = Inherit(BasePanel)
local this = RewardItemSingleShowPopup
local JumpConfig = ConfigManager.GetConfig(ConfigName.JumpConfig)
local itemSid
local heroBackData
local itemConfigData
local itemNu = 0
local func
local armorType = 0
local lanTuData = {}
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local isBagPanel = false
--初始化组件(用于子类重写)
function RewardItemSingleShowPopup:InitComponent()
this.itemName = Util.GetGameObject(self.transform, "bg/name"):GetComponent("Text")
this.BtnBack = Util.GetGameObject(self.transform, "bg/btnBack")
this.icon = Util.GetGameObject(self.transform, "bg/armorInfo/frame/icon"):GetComponent("Image")
this.frameMask = Util.GetGameObject(self.transform, "bg/armorInfo/frameMask")
this.frame = Util.GetGameObject(self.transform, "bg/armorInfo/frame")
this.pokemonFrame = Util.GetGameObject(self.transform, "bg/armorInfo/pokemonFrame")
this.pokemonImage = Util.GetGameObject(self.transform, "bg/armorInfo/pokemonFrame/pokemonImage"):GetComponent("Image")
this.armorType = Util.GetGameObject(self.transform, "bg/armorInfo/armorType"):GetComponent("Text")
this.armorLanTuNum = Util.GetGameObject(self.transform, "armorInfo/armorLanTuNum")
this.armorInfo = Util.GetGameObject(self.transform, "bg/armorInfo/armorInfo"):GetComponent("Text")
this.equipOtherProPre = Util.GetGameObject(self.transform, "getTuPre")
this.equipProGrid = Util.GetGameObject(self.transform, "bg/scroll/grid")
this.btnJump = Util.GetGameObject(self.transform, "bg/btnGrid/btnJump")
this.btnSure = Util.GetGameObject(self.transform, "bg/btnGrid/btnSure")
this.btnSureText = Util.GetGameObject(this.btnSure.transform, "Text"):GetComponent("Text")
this.equipQuaText = Util.GetGameObject(self.transform, "bg/armorInfo/equipQuaText"):GetComponent("Text")
this.innateImage=Util.GetGameObject(self.transform, "bg/armorInfo/innateImage")
this.fragmentIcon=Util.GetGameObject(self.transform, "bg/armorInfo/fragmentIcon")
this.innateText=Util.GetGameObject(self.transform, "bg/armorInfo/innateImage/Text"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function RewardItemSingleShowPopup:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.btnSure, function()
if itemConfigData.ItemType == ItemType.HeroDebris then
2020-12-24 15:03:14 +08:00
local sum = BagManager.GetItemCountById(itemSid) / BagManager.bagDatas[itemSid].itemConfig.UsePerCount
if sum >= 2 then
2020-05-09 13:31:21 +08:00
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
func()
end)
2020-12-24 15:03:14 +08:00
elseif sum >= 1 and sum < 2 then
2020-12-22 20:41:51 +08:00
-- body
local compoundNum = 1
local _itemData = BagManager.bagDatas[itemSid]
local item={}
item.itemId= _itemData.id
item.itemNum=compoundNum*_itemData.itemConfig.UsePerCount
local gameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1)
local endHeroNum=gameSetting.HeroNumlimit-LengthOfTable(HeroManager.GetAllHeroDatas())
if endHeroNum > 0 then
NetManager.HeroComposeRequest(item,function (drop)
this.SendBackCompoundReCallBack(drop)
end)
if compoundNum<=0 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[10183])
end
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12157])
2020-12-22 20:41:51 +08:00
end
2020-05-09 13:31:21 +08:00
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11509])
2020-05-09 13:31:21 +08:00
end
elseif itemConfigData.ItemType == ItemType.Blueprint then
if lanTuData and lanTuData[1] == true then
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
func()
end)
elseif lanTuData and lanTuData[1] == false and lanTuData[2] > 0 then
NetManager.GetWorkShopAvtiveLanTuRequest(lanTuData[2], 2, function()
--刷新工坊解锁蓝图数据
this.DeleteActiveLanTuData()
end)
end
elseif itemConfigData.ItemType == ItemType.Box then
local _itemData = BagManager.bagDatas[itemSid]
2020-06-13 11:47:13 +08:00
if itemConfig[itemSid].UseType ~= 2 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 4, _itemData, function()
func()
end)
end
2020-05-09 13:31:21 +08:00
elseif itemConfigData.ItemType == ItemType.ChangeName then
UIManager.OpenPanel(UIName.CreateNamePopup)
2020-11-03 17:27:32 +08:00
elseif itemConfigData.ItemType == ItemType.Skin then
2020-11-05 14:18:32 +08:00
local group = ConfigManager.GetConfigData(ConfigName.RewardGroup,tonumber(itemConfig[itemSid].ResolveReward)).ShowItem
2021-04-09 12:26:35 +08:00
MsgPanel.ShowTwo(string.format(Language[11510],group[1][2],GetLanguageStrById(itemConfig[group[1][1]].Name)),function()
2020-11-03 17:27:32 +08:00
end, function()
local curResolveAllItemList = {}
table.insert(curResolveAllItemList,{itemId = itemSid,itemNum = 1})
NetManager.UseAndPriceItemRequest(1,curResolveAllItemList,function (drop)
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1)
self:ClosePanel()
end)
2021-04-09 12:26:35 +08:00
end,Language[10731],Language[10732],Language[11511],false,"")
2020-05-09 13:31:21 +08:00
else
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
func()
end)
end
end)
Util.AddClick(this.btnJump, function()
2020-11-03 17:27:32 +08:00
if itemConfigData.ItemType == ItemType.Skin then
2020-11-05 16:02:49 +08:00
local skinConfig = ConfigManager.GetConfigData(ConfigName.HeroSkin,itemSid)
local have,overtime = HeroSkinManager.IsExist(skinConfig.Type)
if have then
if overtime < 0 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12169])
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11512])
end
else
2020-11-03 17:27:32 +08:00
local curResolveAllItemList = {}
table.insert(curResolveAllItemList,{itemId = itemSid,itemNum = 1})
NetManager.UseAndPriceItemRequest(0,curResolveAllItemList,function (drop)
self:ClosePanel()
2020-11-05 16:02:49 +08:00
if HeroManager.GetCurHeroIsHaveBySid(skinConfig.HeroId) then
2021-04-09 12:26:35 +08:00
MsgPanel.ShowTwo(string.format(Language[11513],GetLanguageStrById(skinConfig.ReadingName)),function() end,function()
2020-11-05 16:02:49 +08:00
local herodata = HeroManager.GetHeroDataByHeroSIdAndMinSortIdAndSkinId(skinConfig.HeroId,skinConfig.Type)
LogGreen("herodata.dynamicId:"..tostring(herodata.dynamicId))
UIManager.OpenPanel(UIName.RoleInfoPanel,herodata, HeroManager.GetAllHeroDatas(),true,5)
2021-04-09 12:26:35 +08:00
end,Language[10731],Language[10732],"",false,"")
2020-11-06 20:21:20 +08:00
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(string.format(Language[11514],GetLanguageStrById(skinConfig.ReadingName)))
2021-01-26 17:08:39 +08:00
end
2020-11-03 17:27:32 +08:00
end)
end
2021-01-15 21:06:48 +08:00
elseif itemConfigData.ItemType == ItemType.HeadFrame then
2021-01-18 10:33:32 +08:00
HeadManager.GetCurFrameId()
local theFrameData = HeadManager.GetSingleFrame(itemSid)
if theFrameData then
2021-04-09 12:26:35 +08:00
MsgPanel.ShowTwo(Language[12170],nil,function()
2021-01-18 10:33:32 +08:00
NetManager.UseHeadFrameRequestFun(itemSid,function (msg)
HeadManager.SetSineleHeadFrameAllData(itemSid,msg.validTime)
self:ClosePanel()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12171])
2021-01-18 10:33:32 +08:00
end)
end)
else
NetManager.UseHeadFrameRequestFun(itemSid,function (msg)
HeadManager.SetSineleHeadFrameAllData(itemSid,msg.validTime)
self:ClosePanel()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12171])
2021-01-18 10:33:32 +08:00
end)
end
elseif itemConfigData.ItemType == ItemType.Ride then
local oldPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
if PlayerManager.userMountList[itemConfigData.Id] then
2021-04-09 12:26:35 +08:00
MsgPanel.ShowTwo(Language[12254],nil,function()
NetManager.ActiveUserMountRequest(itemSid,function (msg)
PlayerManager.SetPlayerMountTime(itemSid,msg.validTime)
self:ClosePanel()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12255])
this.WarPowerChange(oldPowerNum)
end)
end)
else
NetManager.ActiveUserMountRequest(itemSid,function (msg)
PlayerManager.SetPlayerMountTime(itemSid,msg.validTime)
self:ClosePanel()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12255])
this.WarPowerChange(oldPowerNum)
end)
end
2020-11-03 17:27:32 +08:00
elseif itemConfigData then
JumpManager.GoJump(itemConfigData.UseJump,function ()
this:ClosePanel()
end)
2020-05-09 13:31:21 +08:00
end
end)
end
2020-12-22 20:41:51 +08:00
local callBackFun
function this.SendBackCompoundReCallBack(drop)
--this:ClosePanel()
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function ()
--UIManager.OpenPanel(UIName.BagPanel)
-- if callBackFun then
-- callBackFun()
func()
-- end
end,nil,nil,nil,true)
--改为后端刷新了
--BagManager.UpdateItemsNum(itemData.id,compoundNum*itemData.itemConfig.UsePerCount)
end
2020-05-09 13:31:21 +08:00
--扣除解锁蓝图材料 并数据
function this.DeleteActiveLanTuData()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11515] .. GetLanguageStrById(itemConfigData.Name))
2020-05-09 13:31:21 +08:00
if lanTuData and lanTuData[1] == false and lanTuData[2] > 0 then
WorkShopManager.UpdataWorkShopLanTuActiveState(2, lanTuData[2], itemConfigData.Id)--
end
if func then
func()
end
this:ClosePanel()
end
--添加事件监听(用于子类重写)
function RewardItemSingleShowPopup:AddListener()
end
--移除事件监听(用于子类重写)
function RewardItemSingleShowPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RewardItemSingleShowPopup:OnOpen(...)
isBagPanel = BagManager.isBagPanel
itemNu = 0
local data = { ... }
itemSid = data[1]
itemConfigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, itemSid)
this.isRewardItemPop=data[3]
if data[2] then
func = data[2]
end
end
function RewardItemSingleShowPopup:OnShow()
this.innateImage:SetActive(false)
this.fragmentIcon:SetActive(false)
2020-06-18 20:39:29 +08:00
--判断自选宝箱界面是否开启
local isBoxOpen = UIManager.IsOpen(314)
if isBagPanel and isBoxOpen then
this.btnSure:SetActive(false)
elseif isBagPanel and itemConfigData.IfResolve == 1 and func then--是否可分解
2020-05-09 13:31:21 +08:00
this.btnSure:SetActive(true)
2021-04-09 12:26:35 +08:00
this.btnSureText.text = Language[10197]
2020-05-09 13:31:21 +08:00
elseif isBagPanel and itemConfigData.ItemType == 2 and func then--是否是碎片可合成
2021-04-09 12:26:35 +08:00
this.btnSureText.text = Language[10193]
2020-05-09 13:31:21 +08:00
this.btnSure:SetActive(true)
elseif isBagPanel and itemConfigData.ItemType == 10 and func then--是否宝箱可使用
this.btnSure:SetActive(true)
2021-04-09 12:26:35 +08:00
this.btnSureText.text = Language[10195]
2020-05-09 13:31:21 +08:00
elseif isBagPanel and itemConfigData.ItemType == 12 and func then-- 改名卡
this.btnSure:SetActive(true)
2021-04-09 12:26:35 +08:00
this.btnSureText.text = Language[10195]
2020-05-09 13:31:21 +08:00
else
this.btnSure:SetActive(false)
2021-04-09 12:26:35 +08:00
this.btnSureText.text = Language[10197]
2020-05-09 13:31:21 +08:00
end
this.btnJump:SetActive(itemConfigData.UseJump and itemConfigData.UseJump > 0 and isBagPanel)
Log("itemConfigData.Id " .. itemConfigData.Id)
this.equipQuaText.text = GetStringByEquipQua(itemConfigData.Quantity, GetQuaStringByEquipQua(itemConfigData.Quantity))
2021-01-26 17:08:39 +08:00
this.itemName.text = GetStringByEquipQua(itemConfigData.Quantity, GetLanguageStrById(itemConfigData.Name))
2020-05-09 13:31:21 +08:00
if itemConfigData.ItemType==4 then --妖魂
this.pokemonFrame:SetActive(true)
this.frame:SetActive(false)
this.pokemonFrame:GetComponent("Image").sprite = Util.LoadSprite(YaoHunFrame[itemConfigData.Quantity])
this.pokemonImage.sprite = Util.LoadSprite(GetResourcePath(itemConfigData.ResourceID))
else
this.frame:SetActive(true)
this.pokemonFrame:SetActive(false)
this.frame:GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(itemConfigData.Quantity))
this.icon.sprite = Util.LoadSprite(GetResourcePath(itemConfigData.ResourceID))
end
2020-07-21 14:36:15 +08:00
this.armorType.text = this.getType()--道具类型显示
2020-05-09 13:31:21 +08:00
this.armorLanTuNum:SetActive(true)
2021-04-09 12:26:35 +08:00
this.armorLanTuNum:GetComponent("Text").text = Language[11516] .. BagManager.GetItemCountById(itemSid)
2021-01-26 17:08:39 +08:00
this.armorInfo.text = string.gsub(GetLanguageStrById(itemConfigData.ItemDescribe), "\\n", "")
2020-05-09 13:31:21 +08:00
this.frameMask:SetActive(false)
2020-11-02 11:52:00 +08:00
if itemConfigData.ItemType == 2 or itemConfigData.ItemType == 22 then
2020-05-09 13:31:21 +08:00
this.frameMask:SetActive(true)
this.frameMask:GetComponent("Image").sprite = Util.LoadSprite(GetHeroChipQuantityImageByquality(itemConfigData.Quantity))
local propertyName=itemConfig[itemConfigData.Id].PropertyName
if(propertyName~=0) then
this.fragmentIcon:SetActive(true)
this.fragmentIcon:GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(propertyName))
end
end
if itemConfigData.ItemType == 9 then
if itemConfigData.RingLevel > 0 then
this.innateImage:SetActive(true)
this.innateText.text = "+" .. itemConfigData.RingLevel
else
this.innateImage:SetActive(false)
this.innateText.text = ""
end
end
--装备获得途径
Util.ClearChild(this.equipProGrid.transform)
if itemConfigData and itemConfigData.Jump then
if itemConfigData.Jump and #itemConfigData.Jump>0 then
local jumpSortData = {}
local isLevel = false
for i = 1, #itemConfigData.Jump do--为关卡跳转做的排序数据
local jumpData = {}
jumpData.id = itemConfigData.Jump[i]
jumpData.data = JumpConfig[itemConfigData.Jump[i]]
--jumpData.state = 0
2020-06-13 11:47:13 +08:00
LogGreen("itemConfigData.Jump[i] "..itemConfigData.Jump[i])
2020-05-09 13:31:21 +08:00
if jumpData.data.Type == JumpType.Level then--关卡按钮特殊处理
isLevel = true
end
table.insert(jumpSortData,jumpData)
end
for i = 1, #jumpSortData do
if jumpSortData[i].id > 0 then
-- type 大于 10000为活动 直接显示按钮如果小于1000 为功能 开启才显示
if JumpConfig[jumpSortData[i].id].Type >= 10000 or ActTimeCtrlManager.SingleFuncState(JumpConfig[jumpSortData[i].id].Type) then
-- if not ActTimeCtrlManager.SingleFuncState(JumpConfig[jumpSortData[i].id].Type) then break end
if not RECHARGEABLE then--(是否开启充值)
if this.isRewardItemPop == true or itemConfigData.Id == 61 or itemConfigData.Id == 19 or itemConfigData.ItemType == 17 then
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,false,self)
else
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,true,self)
end
2020-07-31 13:35:15 +08:00
else
if this.isRewardItemPop == true or itemConfigData.ItemType == 17 then
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,false,self)
else
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,true,self)
end
2020-07-31 13:35:15 +08:00
end
2020-05-09 13:31:21 +08:00
end
end
end
end
end
end
2020-07-21 14:36:15 +08:00
--获取道具种类
function this.getType()
local type = itemConfig[itemSid].ItemBaseType
if type == 1 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[11517]
2020-07-21 14:36:15 +08:00
elseif type == 2 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[10201]
2020-07-21 14:36:15 +08:00
elseif type == 4 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[11518]
2020-07-21 14:36:15 +08:00
elseif type == 5 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[11519]
2020-07-21 14:36:15 +08:00
elseif type == 6 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[11520]
2020-07-21 14:36:15 +08:00
elseif type == 7 then
2021-04-09 12:26:35 +08:00
return Language[11089]..Language[11521]
2020-07-21 14:36:15 +08:00
end
end
2020-05-09 13:31:21 +08:00
--为关卡跳转做的排序
function this.JumpSort(jumps)
table.sort(jumps, function(a, b)
if a.state == b.state then
if a.state == 2 and b.state == 2 then
return a.data.SortId > b.data.SortId
end
else
return a.state > b.state
end
end)
end
--道具 和 装备分解 发送请求后 回调
function this.SendBackResolveReCallBack(drop, curResolveAllItemList)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
if func then
func()
end
this:ClosePanel()
end
--界面关闭时调用(用于子类重写)
function RewardItemSingleShowPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function RewardItemSingleShowPopup:OnDestroy()
end
function this.WarPowerChange(oldPowerNum)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnBagShowWarPowerChange,oldPowerNum)
local newPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
if oldPowerNum ~= newPowerNum then
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPowerNum,newValue = newPowerNum})
end
end
2020-06-23 18:36:24 +08:00
return RewardItemSingleShowPopup