2021-04-21 13:12:04 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-10-19 20:37:53 +08:00
|
|
|
|
local XiaoYaoEventPanel = Inherit(BasePanel)
|
|
|
|
|
local this = XiaoYaoEventPanel
|
|
|
|
|
local triggertype=0 --0:游历成功 大于0:触发仙缘
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function this:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
|
|
|
|
|
this.btnBack = Util.GetGameObject(self.transform, "closeBtn")
|
|
|
|
|
this.title=Util.GetGameObject(self.transform, "bg/title"):GetComponent("Image")
|
|
|
|
|
this.grid=Util.GetGameObject(self.transform, "bg/grid")
|
2022-08-15 13:56:46 +08:00
|
|
|
|
this.grid2=Util.GetGameObject(self.transform, "bg/grid2")
|
|
|
|
|
-- this.eventName=Util.GetGameObject(self.transform, "bg/xianyuan/name"):GetComponent("Text")
|
|
|
|
|
--this.eventIcon=Util.GetGameObject(self.transform, "bg/xianyuan/icon"):GetComponent("Image")
|
|
|
|
|
this.preList={}
|
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
local item=Util.GetGameObject(self.transform, "bg/grid2/xianyuan"..i)
|
|
|
|
|
table.insert(this.preList,item)
|
|
|
|
|
end
|
2021-09-29 16:21:24 +08:00
|
|
|
|
this.rewardItemViewList = {}
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
Util.AddClick(this.btnBack, function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
if triggertype==0 then
|
|
|
|
|
XiaoYaoManager.OpenMapList()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2022-08-15 13:56:46 +08:00
|
|
|
|
function this:OnOpen(_type,_data,curindex,list,num)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
triggertype=_type
|
|
|
|
|
if _type>0 then
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.title.sprite=this.spLoader:LoadSprite("x_xiaoyaoyou_chufaxianyuan_zh")
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.grid:SetActive(false)
|
2022-08-15 13:56:46 +08:00
|
|
|
|
for i = 1, #this.preList do
|
|
|
|
|
this.preList[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
local index=0
|
|
|
|
|
for i = curindex-num+1, curindex do
|
|
|
|
|
-- LogError("list[i].eventData.Style=="..list[i].eventData.Style)
|
|
|
|
|
if list[i].eventData and (list[i].eventData.Style==24 or list[i].eventData.Style==25 or list[i].eventData.Style==26) then
|
|
|
|
|
index=index+1
|
|
|
|
|
if this.preList[index] then
|
|
|
|
|
this.preList[index]:SetActive(true)
|
|
|
|
|
Util.GetGameObject(this.preList[index], "name"):GetComponent("Text").text=string.format("★%s★",GetLanguageStrById(list[i].eventData.Desc))
|
|
|
|
|
--LogError("_data.Desc==".._data.Desc.." _data.EventPointBg==".._data.EventPointBg)
|
|
|
|
|
Util.GetGameObject(this.preList[index], "icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(list[i].eventData.EventPointBg)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- if _data~=nil then
|
|
|
|
|
-- this.eventName.text=string.format("★%s★",GetLanguageStrById(_data.Desc))
|
|
|
|
|
-- LogError("_data.Desc==".._data.Desc.." _data.EventPointBg==".._data.EventPointBg)
|
|
|
|
|
-- this.eventIcon.sprite=this.spLoader:LoadSprite(_data.EventPointBg)
|
|
|
|
|
-- end
|
|
|
|
|
|
2020-10-19 20:37:53 +08:00
|
|
|
|
else
|
2022-08-15 13:56:46 +08:00
|
|
|
|
this.grid2:SetActive(false)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.title.sprite=this.spLoader:LoadSprite("x_xiaoyaoyou_youlichenggong_zh")
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.grid:SetActive(true)
|
|
|
|
|
local showItemdata=this.GetDropReward(_data)
|
2021-07-23 10:58:13 +08:00
|
|
|
|
local starItemDataList=BagManager.GetItemListFromTempBag(_data)
|
|
|
|
|
for i = 1, #starItemDataList do
|
|
|
|
|
this.SetItemData2(starItemDataList[i])
|
|
|
|
|
end
|
|
|
|
|
-- Log("终极大奖:"..#_data.itemlist)
|
|
|
|
|
-- Log("终极大奖:"..#showItemdata)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
if showItemdata and #showItemdata>0 then
|
2021-09-29 16:21:24 +08:00
|
|
|
|
for i = 1, math.max(#showItemdata,#this.rewardItemViewList) do
|
|
|
|
|
if not showItemdata[i] then
|
|
|
|
|
this.rewardItemViewList[i].gameObject:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
if not this.rewardItemViewList[i] then
|
|
|
|
|
this.rewardItemViewList[i] = SubUIManager.Open(SubUIConfig.ItemView, this.grid.transform)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.rewardItemViewList[i]:OnOpen(false,showItemdata[i],1)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-23 10:58:13 +08:00
|
|
|
|
--存储本地
|
|
|
|
|
function this.SetItemData2(itemdata)
|
|
|
|
|
if itemdata.itemType==1 then
|
|
|
|
|
--后端更新
|
|
|
|
|
elseif itemdata.itemType==2 then
|
|
|
|
|
EquipManager.UpdateEquipData(itemdata.backData)
|
|
|
|
|
elseif itemdata.itemType==3 then
|
|
|
|
|
HeroManager.UpdateHeroDatas(itemdata.backData)
|
|
|
|
|
elseif itemdata.itemType==4 then
|
|
|
|
|
TalismanManager.InitUpdateSingleTalismanData(itemdata.backData)
|
|
|
|
|
elseif itemdata.itemType==5 then
|
|
|
|
|
EquipTreasureManager.InitSingleTreasureData(itemdata.backData)
|
|
|
|
|
elseif itemdata.itemType==6 then
|
|
|
|
|
PokemonManager.UpdatePokemonDatas(itemdata.backData,true)
|
2023-02-17 19:43:00 +08:00
|
|
|
|
elseif itemdata.itemType==51 then
|
|
|
|
|
FaXiangManager.InitSingleTreasureData(itemdata.backData)
|
2021-07-23 10:58:13 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-10-19 20:37:53 +08:00
|
|
|
|
function this.GetDropReward(_drop)
|
|
|
|
|
local _rewardList={}
|
|
|
|
|
if _drop.itemlist then
|
|
|
|
|
for i = 1, #_drop.itemlist do
|
|
|
|
|
Log("list有奖励")
|
|
|
|
|
local _rewardData={}
|
|
|
|
|
_rewardData[1]=_drop.itemlist[i].itemId
|
|
|
|
|
_rewardData[2]=_drop.itemlist[i].itemNum
|
|
|
|
|
table.insert(_rewardList,_rewardData)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-23 10:58:13 +08:00
|
|
|
|
if _drop.equipId then
|
2020-10-19 20:37:53 +08:00
|
|
|
|
for i = 1, #_drop.equipId do
|
|
|
|
|
local _rewardData={}
|
2021-07-23 10:58:13 +08:00
|
|
|
|
_rewardData[1]=_drop.equipId[i].equipId--id
|
2020-10-19 20:37:53 +08:00
|
|
|
|
_rewardData[2]=1
|
|
|
|
|
table.insert(_rewardList,_rewardData)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-23 10:58:13 +08:00
|
|
|
|
if _drop.Hero then
|
2020-10-19 20:37:53 +08:00
|
|
|
|
for i = 1, #_drop.Hero do
|
|
|
|
|
local _rewardData={}
|
2021-07-23 10:58:13 +08:00
|
|
|
|
_rewardData[1]=_drop.Hero[i].heroId--id
|
2020-10-19 20:37:53 +08:00
|
|
|
|
_rewardData[2]=1
|
|
|
|
|
table.insert(_rewardList,_rewardData)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-23 10:58:13 +08:00
|
|
|
|
if _drop.soulEquip then
|
2020-10-19 20:37:53 +08:00
|
|
|
|
for i = 1, #_drop.soulEquip do
|
|
|
|
|
local _rewardData={}
|
2021-07-23 10:58:13 +08:00
|
|
|
|
_rewardData[1]=_drop.soulEquip[i].equipId--id
|
2020-10-19 20:37:53 +08:00
|
|
|
|
_rewardData[2]=1
|
|
|
|
|
table.insert(_rewardList,_rewardData)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return _rewardList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function this:OnShow()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
2021-07-28 12:06:58 +08:00
|
|
|
|
function this:OnClose()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
if triggertype>0 then
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.XiaoYao.PlayEventEffect)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function this:OnDestroy()
|
2021-09-29 16:21:24 +08:00
|
|
|
|
for i = 1, #this.rewardItemViewList do
|
|
|
|
|
SubUIManager.Close(this.rewardItemViewList[i])
|
|
|
|
|
end
|
|
|
|
|
this.rewardItemViewList = {}
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return XiaoYaoEventPanel
|