2020-11-02 18:05:24 +08:00
|
|
|
|
local YiJingBaoKu = quick_class("YiJingBaoKu")
|
|
|
|
|
local this = YiJingBaoKu
|
|
|
|
|
local _itemsList = {}
|
|
|
|
|
local _itemsPosList={}
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local itemViewList = {}
|
2020-11-04 10:53:02 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
local ActData = {}
|
2020-11-02 18:05:24 +08:00
|
|
|
|
local sortingOrder = 0
|
|
|
|
|
local parent
|
2020-11-05 19:10:20 +08:00
|
|
|
|
local finalReward = nil
|
2020-11-06 13:36:48 +08:00
|
|
|
|
local trigger = true
|
2020-11-05 19:10:20 +08:00
|
|
|
|
|
|
|
|
|
local BlessingConfig = ConfigManager.GetConfig(ConfigName.BlessingRewardPoolNew)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
|
|
|
|
|
function YiJingBaoKu:ctor(mainPanel, gameObject)
|
|
|
|
|
self.mainPanel = mainPanel
|
|
|
|
|
self.gameObject = gameObject
|
|
|
|
|
YiJingBaoKu:InitComponent(gameObject)
|
|
|
|
|
YiJingBaoKu:BindEvent()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function YiJingBaoKu:InitComponent(gameObject)
|
|
|
|
|
-- top
|
|
|
|
|
this.name = Util.GetGameObject(gameObject, "top/name/Text"):GetComponent("Text")
|
|
|
|
|
this.itemFinal = Util.GetGameObject(gameObject, "top/reward/icon")
|
|
|
|
|
this.addBtn = Util.GetGameObject(gameObject, "top/reward/add")
|
|
|
|
|
this.refrashBtn = Util.GetGameObject(gameObject, "top/reward/refrash")
|
2020-11-05 19:10:20 +08:00
|
|
|
|
this.tip = Util.GetGameObject(gameObject, "top/reward/tips/Text"):GetComponent("Text")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
--leftUp
|
|
|
|
|
this.leftTime = Util.GetGameObject(gameObject, "leftUp/time"):GetComponent("Text")
|
|
|
|
|
--rightUp
|
2020-11-06 15:11:19 +08:00
|
|
|
|
this.helpBtn = Util.GetGameObject(gameObject, "helpBtn")
|
2020-11-06 13:36:48 +08:00
|
|
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
2020-11-02 18:05:24 +08:00
|
|
|
|
this.rewardPre = Util.GetGameObject(gameObject, "rightUp/rewardPre")
|
|
|
|
|
--mid
|
|
|
|
|
this.grid = Util.GetGameObject(gameObject, "mid/content/grid")
|
|
|
|
|
for i = 1, this.grid.transform.childCount do
|
|
|
|
|
_itemsList[i] = this.grid.transform:GetChild(i - 1)
|
|
|
|
|
_itemsPosList[i] = _itemsList[i]:GetComponent("RectTransform").localPosition
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:BindEvent()
|
|
|
|
|
Util.AddClick(this.addBtn,function()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YiJingBaoKu,ActData,function()
|
|
|
|
|
YiJingBaoKu:SetFinalReward()
|
|
|
|
|
YiJingBaoKu:FrontToBack()
|
2020-11-06 15:11:19 +08:00
|
|
|
|
this.refrashBtn:SetActive(ActData.selectId ~= 0)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.refrashBtn,function()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YiJingBaoKu,ActData,function()
|
|
|
|
|
YiJingBaoKu:SetFinalReward()
|
|
|
|
|
end)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.helpBtn,function()
|
2020-11-06 13:36:48 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.YiJingBaoKu,this.helpPosition.x,this.helpPosition.y)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.rewardPre,function()
|
2020-11-06 13:36:48 +08:00
|
|
|
|
if ActData.selectId == 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("请先选择最终大奖~")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YiJingBaoKuRewardPreview,ActData)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:OnOpen()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:OnShow(_sortingOrder,_parent)
|
|
|
|
|
|
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
parent = _parent
|
2020-11-03 09:58:37 +08:00
|
|
|
|
|
2020-11-02 18:05:24 +08:00
|
|
|
|
YiJingBaoKu:Refresh()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
|
|
|
|
|
--刷新
|
2020-11-02 18:05:24 +08:00
|
|
|
|
function YiJingBaoKu:Refresh()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
ActData = DynamicActivityManager.GetBaoKuData()
|
2020-11-06 13:36:48 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
if ActData.selectId == 0 then--如果没有选择了最终奖励
|
2020-11-04 19:51:58 +08:00
|
|
|
|
YiJingBaoKu:ResetCardToFront()--把卡片全部翻到正面
|
2020-11-05 19:10:20 +08:00
|
|
|
|
YiJingBaoKu:InitSetAllCard()--显示所有奖励
|
2020-11-06 15:11:19 +08:00
|
|
|
|
this.tip.text = "选择本层珍稀有秘宝"
|
2020-11-04 19:51:58 +08:00
|
|
|
|
else--选择了最终奖励
|
|
|
|
|
YiJingBaoKu:ResetCardToBack()--把卡片全部翻到背面
|
2020-11-05 19:10:20 +08:00
|
|
|
|
YiJingBaoKu:SetFinalReward()--设置最终奖励
|
2020-11-04 19:51:58 +08:00
|
|
|
|
YiJingBaoKu:SetCardData()--把抽取过的卡翻过来
|
2020-11-06 15:11:19 +08:00
|
|
|
|
this.tip.text = "本层珍稀秘宝"
|
2020-11-04 19:51:58 +08:00
|
|
|
|
end
|
2020-11-06 15:11:19 +08:00
|
|
|
|
YiJingBaoKu:TimeCountDown()--时间
|
2020-11-05 19:10:20 +08:00
|
|
|
|
YiJingBaoKu:AddBackToFrontClick()--增加背面的带点击事件
|
2020-11-06 13:36:48 +08:00
|
|
|
|
trigger = true
|
2020-11-05 19:10:20 +08:00
|
|
|
|
this.refrashBtn:SetActive(ActData.selectId ~= 0)
|
|
|
|
|
this.name.text = "第"..NumToSimplenessFont[ActData.curLevel].."层"
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function YiJingBaoKu:SetCardData()
|
|
|
|
|
for i = 1, #ActData.finalCardDatas do
|
|
|
|
|
local v = ActData.finalCardDatas[i]
|
|
|
|
|
if v.rewardId ~= 0 then
|
|
|
|
|
local item = _itemsList[i]
|
|
|
|
|
local cFront = Util.GetGameObject(item, "front")
|
|
|
|
|
local cBack = Util.GetGameObject(item, "back")
|
|
|
|
|
if not itemViewList[i] then
|
|
|
|
|
itemViewList[i] = SubUIManager.Open(SubUIConfig.ItemView,cFront.transform)
|
|
|
|
|
end
|
|
|
|
|
itemViewList[i]:OnOpen(false, v.reward, 1.1, false, false, false, sortingOrder)
|
|
|
|
|
itemViewList[i].transform.localPosition = Vector2.New(-73.5,78.5)
|
|
|
|
|
cFront:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0))
|
|
|
|
|
cBack:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 90, 0))
|
2020-11-06 15:11:19 +08:00
|
|
|
|
itemViewList[i].gameObject:SetActive(true)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-11-04 19:51:58 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
function YiJingBaoKu:SetFinalReward()
|
|
|
|
|
ActData = DynamicActivityManager.GetBaoKuData()
|
|
|
|
|
if not finalReward then
|
|
|
|
|
finalReward = SubUIManager.Open(SubUIConfig.ItemView,this.addBtn.transform)
|
|
|
|
|
end
|
|
|
|
|
finalReward:OnOpen(false, BlessingConfig[ActData.selectId].Reward, 1.1, false, false, false, sortingOrder)
|
|
|
|
|
finalReward.transform.localPosition = Vector2.New(-73.5,78.5)
|
2020-11-06 13:36:48 +08:00
|
|
|
|
finalReward.gameObject:SetActive(true)
|
2020-11-04 19:51:58 +08:00
|
|
|
|
end
|
2020-11-05 19:10:20 +08:00
|
|
|
|
|
2020-11-04 19:51:58 +08:00
|
|
|
|
--初始化给所有坑赋值
|
|
|
|
|
function YiJingBaoKu:InitSetAllCard()
|
|
|
|
|
for i = 1, #_itemsList do
|
2020-11-05 19:10:20 +08:00
|
|
|
|
if ActData.initCardDatas[i].reward then
|
|
|
|
|
YiJingBaoKu:SetSingleCardData(i,_itemsList[i],ActData.initCardDatas[i].reward)
|
2020-11-04 19:51:58 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-11-02 18:05:24 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
----单个的卡增加点击
|
2020-11-02 18:05:24 +08:00
|
|
|
|
function YiJingBaoKu:AddBackToFrontClick()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local cFront = Util.GetGameObject(value, "front")
|
|
|
|
|
local cBack = Util.GetGameObject(value, "back")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
Util.AddOnceClick(cBack,function()
|
2020-11-04 19:51:58 +08:00
|
|
|
|
--请求奖励
|
2020-11-06 13:36:48 +08:00
|
|
|
|
if BagManager.GetTotalItemNum(1004) <= 0 then
|
|
|
|
|
PopupTipPanel.ShowTip(Language[11880])
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not trigger then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
trigger = false
|
|
|
|
|
-- LogYellow("请求的MissionId:"..ActData.finalCardDatas[index].Id)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
NetManager.GetActivityRewardRequest(ActData.finalCardDatas[index].Id,ActData.activityId,function (drop)
|
|
|
|
|
YiJingBaoKu:SetSingleCardData(index,value,{drop.itemlist[1].itemId,drop.itemlist[1].itemNum})
|
|
|
|
|
local thread=coroutine.start(function()
|
|
|
|
|
cBack.transform:DORotate(Vector3.New(0, 90, 0), 0.3)
|
|
|
|
|
coroutine.wait(0.3)
|
|
|
|
|
cFront.transform:DORotate(Vector3.New(0, 0, 0), 0.3)
|
|
|
|
|
coroutine.wait(0.2)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function ()
|
2020-11-06 13:36:48 +08:00
|
|
|
|
trigger = true
|
2020-11-05 19:10:20 +08:00
|
|
|
|
if drop.itemlist[1].itemId == BlessingConfig[ActData.selectId].Reward[1] then
|
2020-11-06 13:36:48 +08:00
|
|
|
|
finalReward.gameObject:SetActive(false)
|
2020-11-06 15:11:19 +08:00
|
|
|
|
itemViewList[18].gameObject:SetActive(false)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
YiJingBaoKu:Refresh()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--单个翻卡赋值
|
|
|
|
|
function YiJingBaoKu:SetSingleCardData(index,item,reward)
|
|
|
|
|
local root = Util.GetGameObject(item,"front")
|
|
|
|
|
if not itemViewList[index] then
|
|
|
|
|
itemViewList[index] = SubUIManager.Open(SubUIConfig.ItemView,root.transform)
|
|
|
|
|
end
|
|
|
|
|
itemViewList[index]:OnOpen(false, reward, 1.1, false, false, false, sortingOrder)
|
|
|
|
|
itemViewList[index].transform.localPosition = Vector2.New(-73.5,78.5)
|
2020-11-06 15:11:19 +08:00
|
|
|
|
itemViewList[index].gameObject:SetActive(true)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end
|
2020-11-02 18:05:24 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--所有奖励翻面
|
2020-11-02 18:05:24 +08:00
|
|
|
|
function YiJingBaoKu:FrontToBack()
|
|
|
|
|
local thread=coroutine.start(function()
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local cFront = Util.GetGameObject(value, "front")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
cFront.transform:DORotate(Vector3.New(0, 90, 0), 0.3)
|
|
|
|
|
end
|
|
|
|
|
coroutine.wait(0.3)
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local cBack = Util.GetGameObject(value, "back")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
cBack.transform:DORotate(Vector3.New(0, 0, 0), 0.3)
|
|
|
|
|
end
|
|
|
|
|
coroutine.wait(0.3)
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
value.transform:DOLocalMove(Vector3.New(0,0,0), 0.3)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end
|
|
|
|
|
coroutine.wait(0.3)
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
value.transform:DOLocalMove(Vector3.New(_itemsPosList[index].x,_itemsPosList[index].y,_itemsPosList[index].z), 0.3)
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--把所有卡置为正面
|
2020-11-04 19:51:58 +08:00
|
|
|
|
function YiJingBaoKu:ResetCardToFront()
|
2020-11-02 18:05:24 +08:00
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local cFront = Util.GetGameObject(value, "front")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
cFront:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0))
|
|
|
|
|
end
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
2020-11-04 19:51:58 +08:00
|
|
|
|
local cBack = Util.GetGameObject(value, "back")
|
2020-11-02 18:05:24 +08:00
|
|
|
|
cBack:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 90, 0))
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--把所有卡置为背面
|
2020-11-04 19:51:58 +08:00
|
|
|
|
function YiJingBaoKu:ResetCardToBack()
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
|
|
|
|
local cFront = Util.GetGameObject(value, "front")
|
|
|
|
|
cFront:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 90, 0))
|
|
|
|
|
end
|
|
|
|
|
for index, value in ipairs(_itemsList) do
|
|
|
|
|
local cBack = Util.GetGameObject(value, "back")
|
|
|
|
|
cBack:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--时间
|
|
|
|
|
function YiJingBaoKu:TimeCountDown()
|
|
|
|
|
local time = ActData.endTime - GetTimeStamp()
|
|
|
|
|
this.leftTime.text = Language[10028]..TimeToFelaxible(time)
|
|
|
|
|
if this.timer1 then
|
|
|
|
|
this.timer1:Stop()
|
|
|
|
|
this.timer1 = nil
|
|
|
|
|
end
|
|
|
|
|
this.timer1 = Timer.New(function()
|
|
|
|
|
this.leftTime.text = Language[10028]..TimeToFelaxible(time)
|
|
|
|
|
|
|
|
|
|
if time < 1 then
|
|
|
|
|
this.timer1:Stop()
|
|
|
|
|
this.timer1 = nil
|
|
|
|
|
YiJingBaoKu:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
time = time -1
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
this.timer1:Start()
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-02 18:05:24 +08:00
|
|
|
|
function YiJingBaoKu:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function YiJingBaoKu:OnDestroy()
|
2020-11-04 19:51:58 +08:00
|
|
|
|
_itemsList = {}
|
|
|
|
|
_itemsPosList={}
|
|
|
|
|
itemViewList = {}
|
2020-11-05 19:10:20 +08:00
|
|
|
|
finalReward = nil
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function YiJingBaoKu:OnHide()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
if this.timer1 then
|
|
|
|
|
this.timer1:Stop()
|
|
|
|
|
this.timer1 = nil
|
|
|
|
|
end
|
2020-11-02 18:05:24 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return YiJingBaoKu
|