2020-08-25 15:46:38 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local TreasureOfHeavenPanel = Inherit(BasePanel)
|
|
|
|
|
local this = TreasureOfHeavenPanel
|
2020-08-27 22:10:08 +08:00
|
|
|
|
-- local curScore = 0--当前分数
|
|
|
|
|
-- local rewardStateData = {}
|
2020-07-24 18:30:26 +08:00
|
|
|
|
local treasureState = nil
|
2020-08-27 22:10:08 +08:00
|
|
|
|
local rewardData--后端活动数据
|
|
|
|
|
local ConfigData = ConfigManager.GetConfig(ConfigName.WorldBossTreasureConfig)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:InitComponent()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--topBar/btnBack
|
|
|
|
|
this.btnBack = Util.GetGameObject(this.transform, "bg/btnBack")
|
|
|
|
|
this.buyBtn = Util.GetGameObject(this.transform, "bg/topBar/buyBtn")
|
|
|
|
|
this.Text1 = Util.GetGameObject(this.buyBtn, "buy")
|
|
|
|
|
this.Text2 = Util.GetGameObject(this.buyBtn, "hadbuy")
|
2020-06-18 20:39:29 +08:00
|
|
|
|
this.tips = Util.GetGameObject(this.transform, "bg/topBar/tips"):GetComponent("Text")
|
2020-06-30 18:59:44 +08:00
|
|
|
|
this.time = Util.GetGameObject(this.transform, "bg/topBar/tips/actTime"):GetComponent("Text")
|
|
|
|
|
this.quesBtn = Util.GetGameObject(this.transform, "bg/quesBtn")
|
|
|
|
|
this.helpPosition=this.quesBtn:GetComponent("RectTransform").localPosition
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--Content
|
|
|
|
|
this.scoreText = Util.GetGameObject(this.transform, "bg/pageContent/bg/score/number"):GetComponent("Text")
|
|
|
|
|
this.treasureList = Util.GetGameObject(this.transform, "bg/pageContent/treasureList")
|
|
|
|
|
this.itemPre = Util.GetGameObject(this.treasureList, "itemPro")
|
|
|
|
|
|
|
|
|
|
--设置滚动条
|
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.treasureList.transform,this.itemPre,nil,Vector2.New(950, 1000),1,1,Vector2.New(100, 25))
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 2
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:BindEvent()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.AddClick(this.btnBack,function()
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.quesBtn,function()
|
2021-04-21 16:36:12 +08:00
|
|
|
|
--LogGreen(this.helpPosition.x.."+"..this.helpPosition.y)
|
2020-06-30 18:59:44 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TreasureOfHeaven,this.helpPosition.x,this.helpPosition.y)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TreasureOfHeavenPanel:OnSortingOrderChange()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:AddListener()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.TreasureOfHeaven.RechargeSuccess, self.refresh,self)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:RemoveListener()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.TreasureOfHeaven.RechargeSuccess, self.refresh,self)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:OnOpen(...)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--初始化数据
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function TreasureOfHeavenPanel:OnShow()
|
2021-04-09 12:26:35 +08:00
|
|
|
|
this.tips.text = Language[11924]
|
2020-08-27 22:10:08 +08:00
|
|
|
|
this.time.text=TimeToDHMS(TreasureOfHeavenManger.resetTime - GetTimeStamp())
|
2020-06-30 18:59:44 +08:00
|
|
|
|
TreasureOfHeavenPanel:ShowTime()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
TreasureOfHeavenPanel:refresh()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function TreasureOfHeavenPanel:refresh()
|
2020-08-27 22:10:08 +08:00
|
|
|
|
treasureState = TreasureOfHeavenManger.TreasrueState
|
|
|
|
|
rewardData = TreasureOfHeavenManger.rewardStateData
|
2021-04-21 16:36:12 +08:00
|
|
|
|
-- --LogGreen("#rewardData长度:"..#rewardData)
|
2020-08-27 22:10:08 +08:00
|
|
|
|
if #TreasureOfHeavenManger.rewardStateData <= 0 then
|
2020-08-27 15:18:17 +08:00
|
|
|
|
TreasureOfHeavenPanel:topBar()
|
|
|
|
|
TreasureOfHeavenPanel:showTaskList()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
else
|
|
|
|
|
TreasureOfHeavenPanel:topBar()
|
|
|
|
|
TreasureOfHeavenPanel:showTaskList()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--topBar按钮状态
|
|
|
|
|
function TreasureOfHeavenPanel:topBar()
|
|
|
|
|
--设置礼包购买按钮状态
|
2020-07-24 18:30:26 +08:00
|
|
|
|
this.buyBtn:GetComponent("Button").interactable = treasureState == 0
|
|
|
|
|
this.Text1.gameObject:SetActive(treasureState == 0)
|
|
|
|
|
this.Text2.gameObject:SetActive(treasureState == 1)
|
|
|
|
|
|
|
|
|
|
if treasureState == 0 then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.AddOnceClick(this.buyBtn,function()
|
2020-08-24 20:37:41 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.HeavenUnlockExtraRewardPanel,1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
2020-08-27 22:10:08 +08:00
|
|
|
|
this.scoreText.text = TreasureOfHeavenManger.curScore
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--任务列表
|
|
|
|
|
function TreasureOfHeavenPanel:showTaskList()
|
|
|
|
|
this.ScrollView:SetData(rewardData,function(index, rewardItem)
|
|
|
|
|
TreasureOfHeavenPanel:SingleTask(rewardItem, rewardData[index])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--定位打开界面时位置
|
|
|
|
|
local t = 0
|
2020-08-27 22:10:08 +08:00
|
|
|
|
if TreasureOfHeavenManger.TreasrueState == 0 then
|
|
|
|
|
for i = 1, #rewardData do
|
|
|
|
|
if rewardData[i].state == 0 then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
t = i
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-08-27 22:10:08 +08:00
|
|
|
|
elseif TreasureOfHeavenManger.TreasrueState == 1 then
|
|
|
|
|
for i = 1, #rewardData do
|
|
|
|
|
if rewardData[i].state == 1 or rewardData[i].state == 0 then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
t = i
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.ScrollView:SetIndex(t-2)
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-30 18:59:44 +08:00
|
|
|
|
local itemsList={}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--单个任务
|
2020-08-27 22:10:08 +08:00
|
|
|
|
function TreasureOfHeavenPanel:SingleTask(rewardItem, singleData)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local scoreLevel = Util.GetGameObject(rewardItem, "scoreLevel"):GetComponent("Text")
|
|
|
|
|
local pos1 = Util.GetGameObject(rewardItem, "itemPos_1")
|
|
|
|
|
local pos3 = Util.GetGameObject(rewardItem, "itemPos_3")
|
|
|
|
|
local pos4 = Util.GetGameObject(rewardItem, "itemPos_4")
|
2020-06-30 18:59:44 +08:00
|
|
|
|
|
|
|
|
|
if not itemsList[rewardItem] then
|
|
|
|
|
local item1 = SubUIManager.Open(SubUIConfig.ItemView, pos1.transform)
|
|
|
|
|
local item3 = SubUIManager.Open(SubUIConfig.ItemView, pos3.transform)
|
|
|
|
|
local item4 = SubUIManager.Open(SubUIConfig.ItemView, pos4.transform)
|
|
|
|
|
itemsList[rewardItem] ={item1,item3,item4}
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
2020-08-27 22:10:08 +08:00
|
|
|
|
scoreLevel.text = ConfigData[singleData.id].Integral
|
|
|
|
|
itemsList[rewardItem][1]:OnOpen(false, {ConfigData[singleData.id].Reward[1][1], ConfigData[singleData.id].Reward[1][2]}, 0.8, false)
|
|
|
|
|
itemsList[rewardItem][2]:OnOpen(false, {ConfigData[singleData.id].TreasureReward[1][1], ConfigData[singleData.id].TreasureReward[1][2]}, 0.8, false)
|
|
|
|
|
itemsList[rewardItem][3]:OnOpen(false, {ConfigData[singleData.id].TreasureReward[2][1], ConfigData[singleData.id].TreasureReward[2][2]}, 0.8, false)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
--初始化按钮状态
|
2020-08-27 22:10:08 +08:00
|
|
|
|
TreasureOfHeavenPanel:InitButtonState(rewardItem, singleData)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
--初始化按钮状态
|
2020-08-27 22:10:08 +08:00
|
|
|
|
function TreasureOfHeavenPanel:InitButtonState(rewardItem, singleData)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
local btnDeal = Util.GetGameObject(rewardItem, "btnDeal")
|
|
|
|
|
local get = Util.GetGameObject(rewardItem, "btnDeal/get")
|
|
|
|
|
local getAgain = Util.GetGameObject(rewardItem, "btnDeal/getAgain")
|
|
|
|
|
local unfinished = Util.GetGameObject(rewardItem, "btnDeal/unfinished")
|
|
|
|
|
local finished = Util.GetGameObject(rewardItem, "finished")
|
|
|
|
|
local redPoint = Util.GetGameObject(rewardItem, "btnDeal/redPoint")
|
|
|
|
|
--当前任务领取情况
|
2020-08-27 22:10:08 +08:00
|
|
|
|
local state = singleData.state
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--判断
|
2020-08-27 22:10:08 +08:00
|
|
|
|
if TreasureOfHeavenManger.curScore >= ConfigData[singleData.id].Integral then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if (state == -1) then
|
|
|
|
|
btnDeal.gameObject:SetActive(false)
|
|
|
|
|
get.gameObject:SetActive(false)
|
|
|
|
|
getAgain.gameObject:SetActive(false)
|
|
|
|
|
unfinished.gameObject:SetActive(false)
|
|
|
|
|
finished.gameObject:SetActive(true)
|
|
|
|
|
elseif (state == 1) then
|
|
|
|
|
btnDeal.gameObject:SetActive(true)
|
|
|
|
|
get.gameObject:SetActive(false)
|
|
|
|
|
getAgain.gameObject:SetActive(true)
|
|
|
|
|
unfinished.gameObject:SetActive(false)
|
|
|
|
|
finished.gameObject:SetActive(false)
|
|
|
|
|
else --rewardSingleData.state == 0
|
|
|
|
|
btnDeal.gameObject:SetActive(true)
|
|
|
|
|
get.gameObject:SetActive(true)
|
|
|
|
|
getAgain.gameObject:SetActive(false)
|
|
|
|
|
unfinished.gameObject:SetActive(false)
|
|
|
|
|
finished.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
btnDeal.gameObject:SetActive(true)
|
|
|
|
|
get.gameObject:SetActive(false)
|
|
|
|
|
getAgain.gameObject:SetActive(false)
|
|
|
|
|
unfinished.gameObject:SetActive(true)
|
|
|
|
|
finished.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
--添加点击事件
|
|
|
|
|
Util.AddOnceClick(btnDeal,function()
|
2020-08-27 22:10:08 +08:00
|
|
|
|
TreasureOfHeavenPanel:OnBtnDealClicked(rewardItem,singleData)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--红点状态
|
2020-08-27 22:10:08 +08:00
|
|
|
|
redPoint:SetActive(TreasureOfHeavenManger.RedPointState(singleData,treasureState))
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--按钮事件
|
2020-08-27 22:10:08 +08:00
|
|
|
|
function TreasureOfHeavenPanel:OnBtnDealClicked(rewardItem,singleData)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
local btnDeal = Util.GetGameObject(rewardItem, "btnDeal")
|
|
|
|
|
local get = Util.GetGameObject(rewardItem, "btnDeal/get")
|
|
|
|
|
local getAgain = Util.GetGameObject(rewardItem, "btnDeal/getAgain")
|
|
|
|
|
local unfinished = Util.GetGameObject(rewardItem, "btnDeal/unfinished")
|
|
|
|
|
local finished = Util.GetGameObject(rewardItem, "btnDeal/finished")
|
|
|
|
|
|
2020-08-27 22:10:08 +08:00
|
|
|
|
if TreasureOfHeavenManger.curScore >= ConfigData[singleData.id].Integral then--分数达到要求
|
|
|
|
|
if (singleData.state == 0 and treasureState == 0) or--任务未领取+礼包未购买
|
|
|
|
|
(singleData.state == 1 and treasureState == 1) or--任务已领取+礼包已购买
|
|
|
|
|
(singleData.state == 0 and treasureState == 1)then--任务未领取+礼包已购买
|
|
|
|
|
NetManager.GetTreasureOfHeavenRewardRequest(singleData.id,function(msg)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
|
|
|
|
--需要刷新界面
|
|
|
|
|
if treasureState == 0 then--判断是否已经购买了礼包
|
2020-08-27 22:10:08 +08:00
|
|
|
|
TreasureOfHeavenManger.SetSingleRewardState(singleData.id,1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
else
|
2020-08-27 22:10:08 +08:00
|
|
|
|
TreasureOfHeavenManger.SetSingleRewardState(singleData.id,-1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
TreasureOfHeavenPanel:refresh()--刷新界面
|
|
|
|
|
end)
|
2020-08-27 22:10:08 +08:00
|
|
|
|
elseif singleData.state == 1 and treasureState == 0 then----任务已领取+礼包未购买(弹出购买界面)
|
2020-08-24 20:37:41 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.HeavenUnlockExtraRewardPanel,1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
else--分数未达到要求
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11330])
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
2020-06-30 18:59:44 +08:00
|
|
|
|
function TreasureOfHeavenPanel:ShowTime()
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-08-27 22:10:08 +08:00
|
|
|
|
local t = TreasureOfHeavenManger.resetTime
|
2020-07-24 12:11:00 +08:00
|
|
|
|
local time
|
2020-06-30 18:59:44 +08:00
|
|
|
|
self.localTimer = Timer.New(function()
|
2020-08-27 22:10:08 +08:00
|
|
|
|
time = t - GetTimeStamp()
|
|
|
|
|
if t - GetTimeStamp() <= 0 then
|
2020-07-24 12:11:00 +08:00
|
|
|
|
time = 0
|
2020-08-27 22:10:08 +08:00
|
|
|
|
t = TreasureOfHeavenManger.resetTime
|
2020-07-24 18:30:26 +08:00
|
|
|
|
treasureState = nil
|
2020-09-27 18:27:20 +08:00
|
|
|
|
this.ScrollView:SetIndex(1)
|
|
|
|
|
--TreasureOfHeavenPanel:refresh()--不刷新了,直接踢出去
|
|
|
|
|
ExpeditionManager.RefreshPanelShowByState()
|
2020-07-24 12:11:00 +08:00
|
|
|
|
end
|
|
|
|
|
this.time.text=TimeToDHMS(time)
|
2020-06-30 18:59:44 +08:00
|
|
|
|
end,1,-1,true)
|
|
|
|
|
self.localTimer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:OnClose()
|
2020-06-30 18:59:44 +08:00
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function TreasureOfHeavenPanel:OnDestroy()
|
2020-08-27 22:10:08 +08:00
|
|
|
|
rewardData = {}
|
2020-05-25 19:16:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return TreasureOfHeavenPanel
|