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")
|
|
|
|
|
this.xianyuan=Util.GetGameObject(self.transform, "bg/xianyuan")
|
|
|
|
|
this.eventName=Util.GetGameObject(self.transform, "bg/xianyuan/name"):GetComponent("Text")
|
|
|
|
|
this.eventIcon=Util.GetGameObject(self.transform, "bg/xianyuan/icon"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
Util.AddClick(this.btnBack, function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
if triggertype==0 then
|
|
|
|
|
XiaoYaoManager.OpenMapList()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function this:OnOpen(_type,_data)
|
|
|
|
|
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)
|
|
|
|
|
this.xianyuan:SetActive(true)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
this.eventName.text=string.format("★%s★",GetLanguageStrById(_data.Desc))
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.eventIcon.sprite=this.spLoader:LoadSprite(_data.EventPointBg)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
else
|
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)
|
|
|
|
|
this.xianyuan:SetActive(false)
|
|
|
|
|
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
|
|
|
|
|
for i = 1, #showItemdata do
|
2021-07-23 10:58:13 +08:00
|
|
|
|
-- Log("终极大奖:"..showItemdata[i][1])
|
2020-10-19 20:37:53 +08:00
|
|
|
|
local _rewardObj= SubUIManager.Open(SubUIConfig.ItemView, this.grid.transform)
|
|
|
|
|
_rewardObj:OnOpen(false,showItemdata[i],1)
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
while(this.grid.transform.childCount>0)
|
|
|
|
|
do
|
|
|
|
|
destroy(this.grid.transform:GetChild(0).gameObject)
|
|
|
|
|
end
|
|
|
|
|
if triggertype>0 then
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.XiaoYao.PlayEventEffect)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function this:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return XiaoYaoEventPanel
|