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

263 lines
11 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
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
if BagManager.GetItemCountById(itemSid) >= BagManager.bagDatas[itemSid].itemConfig.UsePerCount then
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
func()
end)
else
PopupTipPanel.ShowTip(Language[11592])
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]
if itemConfig[itemSid].UseType ~= 2 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 4, _itemData, function()
func()
end)
end
elseif itemConfigData.ItemType == ItemType.ChangeName then
UIManager.OpenPanel(UIName.CreateNamePopup)
else
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
func()
end)
end
end)
Util.AddClick(this.btnJump, function()
if itemConfigData then
JumpManager.GoJump(itemConfigData.UseJump)
end
end)
end
--扣除解锁蓝图材料 并数据
function this.DeleteActiveLanTuData()
PopupTipPanel.ShowTip(Language[11593] .. itemConfigData.Name)
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)
--判断自选宝箱界面是否开启
local isBoxOpen = UIManager.IsOpen(314)
if isBagPanel and isBoxOpen then
this.btnSure:SetActive(false)
elseif isBagPanel and itemConfigData.IfResolve == 1 and func then--是否可分解
this.btnSure:SetActive(true)
elseif isBagPanel and itemConfigData.ItemType == 2 and func then--是否是碎片可合成
this.btnSureText.text = Language[10210]
this.btnSure:SetActive(true)
elseif isBagPanel and itemConfigData.ItemType == 10 and func then--是否宝箱可使用
this.btnSure:SetActive(true)
this.btnSureText.text = Language[10212]
elseif isBagPanel and itemConfigData.ItemType == 12 and func then-- 改名卡
this.btnSure:SetActive(true)
this.btnSureText.text = Language[10212]
else
this.btnSure:SetActive(false)
this.btnSureText.text = Language[10214]
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))
this.itemName.text = GetStringByEquipQua(itemConfigData.Quantity, itemConfigData.Name)
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
this.armorType.text = this.getType()--道具类型显示
this.armorLanTuNum:SetActive(true)
this.armorLanTuNum:GetComponent("Text").text = Language[11595] .. BagManager.GetItemCountById(itemSid)
this.armorInfo.text = string.gsub(itemConfigData.ItemDescribe, "\\n", "")
this.frameMask:SetActive(false)
if itemConfigData.ItemType == 2 then
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
LogGreen("itemConfigData.Jump[i] "..itemConfigData.Jump[i])
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
if this.isRewardItemPop == true or itemConfigData.Id == 61 or itemConfigData.Id == 19 then--24暂时关闭
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,false)
else
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id,true)
end
end
end
end
end
end
--获取道具种类
function this.getType()
local type = itemConfig[itemSid].ItemBaseType
if type == 1 then
return Language[11093]..Language[12266]
elseif type == 2 then
return Language[11093]..Language[10219]
elseif type == 4 then
return Language[11093]..Language[12267]
elseif type == 5 then
return Language[11093]..Language[12268]
elseif type == 6 then
return Language[11093]..Language[12269]
elseif type == 7 then
return Language[11093]..Language[12270]
end
end
--为关卡跳转做的排序
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
return RewardItemSingleShowPopup