2020-08-19 10:05:01 +08:00
|
|
|
----- 日常任务弹窗 -----
|
|
|
|
local this = {}
|
|
|
|
--传入父脚本模块
|
|
|
|
local parent
|
|
|
|
--传入特效层级
|
|
|
|
local sortingOrder=0
|
|
|
|
|
|
|
|
local curScore = 0--当前分数
|
|
|
|
local treasureState = 0
|
|
|
|
local itemsList={}
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
--topBar/btnBack
|
|
|
|
this.gameObject = gameObject
|
|
|
|
this.quesBtn = Util.GetGameObject(this.gameObject, "bg/topBar/quesBtn")
|
|
|
|
this.helpPosition= this.quesBtn:GetComponent("RectTransform").localPosition
|
|
|
|
this.tips = Util.GetGameObject(this.gameObject, "bg/topBar/tips"):GetComponent("Text")
|
|
|
|
this.time = Util.GetGameObject(this.gameObject, "bg/topBar/time/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
this.buyBtn = Util.GetGameObject(this.gameObject, "bg/topBar/button/buyBtn")
|
|
|
|
this.buyBtnText = Util.GetGameObject(this.buyBtn, "Text"):GetComponent("Text")
|
|
|
|
this.jiesuoBtn = Util.GetGameObject(this.gameObject, "bg/topBar/button/jiesuoBtn")
|
|
|
|
this.jiesuoBtnText = Util.GetGameObject(this.jiesuoBtn, "Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
this.lv = Util.GetGameObject(this.gameObject, "bg/topBar/Image/lv"):GetComponent("Text")
|
|
|
|
|
|
|
|
--Content
|
|
|
|
this.progress = Util.GetGameObject(this.gameObject, "bg/topBar/progress/Image"):GetComponent("Image")
|
|
|
|
this.scoreText = Util.GetGameObject(this.gameObject, "bg/topBar/progress/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
this.remainTime = Util.GetGameObject(this.gameObject, "bg/topBar/remainTime/Text"):GetComponent("Text")
|
|
|
|
this.box = Util.GetGameObject(this.gameObject, "topBar/box")
|
|
|
|
this.extra = Util.GetGameObject(this.gameObject, "topBar/extraBox")
|
|
|
|
this.canOpenExtra = Util.GetGameObject(this.gameObject, "topBar/UI_Effect_BaoXiang_KeKaiQi")
|
|
|
|
this.canOpenExtra.gameObject:SetActive(false)
|
|
|
|
this.openExtra = Util.GetGameObject(this.gameObject, "topBar/UI_Effect_BaoXiang_KaiQi")
|
|
|
|
this.openExtra.gameObject:SetActive(false)
|
|
|
|
|
|
|
|
this.treasureList = Util.GetGameObject(this.gameObject, "bg/pageContent/treasureList")
|
|
|
|
local v2 = this.treasureList:GetComponent("RectTransform").sizeDelta
|
|
|
|
this.itemPre = Util.GetGameObject(this.treasureList, "itemPro")
|
|
|
|
|
|
|
|
--设置滚动条
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.treasureList.transform,
|
|
|
|
this.itemPre,nil,Vector2.New(v2.x, v2.y),1,1,Vector2.New(100,3.5))
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
Util.AddClick(this.quesBtn,function()
|
|
|
|
LogGreen(this.helpPosition.x.."+"..this.helpPosition.y)
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,99999,this.helpPosition.x,this.helpPosition.y)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
function this:AddListener()
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.TreasureOfHeaven.BuyQinglongSerectLevelSuccess, this.refresh)
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess, this.refresh)
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose,this.CloseFunction)
|
|
|
|
end
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.TreasureOfHeaven.BuyQinglongSerectLevelSuccess, this.refresh)
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess, this.refresh)
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose,this.Closefunction)
|
|
|
|
end
|
|
|
|
this.Closefunction = function()
|
|
|
|
Timer.New(function()
|
2020-08-22 16:43:39 +08:00
|
|
|
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
|
|
|
|
PopupTipPanel.ShowTip("活动已结束")
|
2020-08-22 15:48:01 +08:00
|
|
|
parent:ClosePanel()
|
2020-08-22 16:46:17 +08:00
|
|
|
|
2020-08-19 10:05:01 +08:00
|
|
|
return
|
|
|
|
else
|
|
|
|
this.refresh()
|
|
|
|
end
|
|
|
|
end,1):Start()
|
|
|
|
end
|
|
|
|
function this:OnShow(_parent,...)
|
|
|
|
parent=_parent
|
|
|
|
sortingOrder = _parent.sortingOrder
|
|
|
|
|
|
|
|
this.tips.text = "完成日常任务和秘宝试炼以提升秘宝等级,领取对应奖励,解锁秘宝可领取额外奖励"
|
|
|
|
local startTime,endTime,endTimeScale = QinglongSerectTreasureManager.GetTimeStartToEnd()
|
|
|
|
this.time.text = "活动时间:"..startTime.."-"..endTime
|
|
|
|
this.remainTime.text = "剩余时间:"..TimeToDHMS(tonumber(endTimeScale) - GetTimeStamp())
|
|
|
|
this:ShowTime(endTimeScale)
|
|
|
|
this.refresh()
|
|
|
|
|
|
|
|
end
|
|
|
|
function this:OnSortingOrderChange(sortingOrder)
|
|
|
|
Util.SetParticleSortLayer(this.canOpenExtra, sortingOrder)
|
|
|
|
Util.SetParticleSortLayer(this.openExtra, sortingOrder)
|
|
|
|
end
|
|
|
|
|
|
|
|
function this:OnClose()
|
2020-08-22 16:55:27 +08:00
|
|
|
|
2020-08-19 10:05:01 +08:00
|
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
|
|
itemsList={}
|
2020-08-22 16:55:27 +08:00
|
|
|
if self.timer then
|
|
|
|
self.timer :Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
2020-08-19 10:05:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
this.refresh = function()
|
|
|
|
this:topBar()
|
|
|
|
this:showTaskList()
|
2020-08-19 14:12:42 +08:00
|
|
|
CheckRedPointStatus(RedPointType.QinglongSerectTreasure)
|
2020-08-19 10:05:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--topBar按钮状态
|
|
|
|
function this:topBar()
|
|
|
|
--设置礼包购买按钮状态
|
|
|
|
treasureState = QinglongSerectTreasureManager.GetTreasureState()--秘宝礼包状态 0:可购买 1:已购买
|
|
|
|
curScore = QinglongSerectTreasureManager.GetScore()
|
|
|
|
local lv = QinglongSerectTreasureManager.GetLevel()
|
|
|
|
this.lv.text = lv
|
|
|
|
local rewardData = QinglongSerectTreasureManager.GetRewardData(lv)
|
|
|
|
local lastRewardData = QinglongSerectTreasureManager.GetRewardData(lv)
|
|
|
|
if lv ~= 0 then
|
|
|
|
lastRewardData = QinglongSerectTreasureManager.GetRewardData(lv - 1)
|
|
|
|
end
|
|
|
|
if rewardData.needScore ~= 0 then
|
|
|
|
this.scoreText.text = curScore .."/"..rewardData.needScore - lastRewardData.needScore
|
|
|
|
this.progress.fillAmount = curScore/(rewardData.needScore - lastRewardData.needScore)
|
|
|
|
else
|
|
|
|
this.scoreText.text = "最大等级"
|
|
|
|
this.progress.fillAmount = 1
|
|
|
|
end
|
|
|
|
this.jiesuoBtn:GetComponent("Button").enabled = (treasureState == 0)
|
|
|
|
this.jiesuoBtnText.text = ((treasureState == 0) and "解锁秘宝" or "已解锁")
|
|
|
|
Util.AddOnceClick(this.jiesuoBtn,function()
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.HeavenUnlockExtraRewardPanel,2)
|
|
|
|
end)
|
|
|
|
this.buyBtn:GetComponent("Button").enabled = (rewardData.needScore ~= 0)
|
|
|
|
this.buyBtnText.text = ((rewardData.needScore == 0) and "最大等级" or "购买等级")
|
|
|
|
Util.AddOnceClick(this.buyBtn,function()
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.QinglongSerectTreasureBuyLevel)
|
|
|
|
end)
|
|
|
|
local times = PrivilegeManager.GetPrivilegeRemainValue(1007)
|
|
|
|
this.box :GetComponent("Image").enabled = ((not (treasureState == 0)) and (times > 0))
|
|
|
|
this.extra:GetComponent("Button").enabled = ((not (treasureState == 0)) and (times > 0))
|
|
|
|
this.canOpenExtra.gameObject:SetActive((not (treasureState == 0)) and (times > 0))
|
|
|
|
this.openExtra:GetComponent("Animator").enabled = false
|
|
|
|
this.openExtra.gameObject:SetActive((not (treasureState == 0)) and (times <= 0))
|
|
|
|
Util.GetGameObject(this.openExtra,"MeiKaiQi"):SetActive(false)
|
|
|
|
Util.GetGameObject(this.openExtra,"KaiQi"):SetActive(true)
|
|
|
|
Util.AddOnceClick(this.extra,function()
|
|
|
|
this.extra:GetComponent("Button").enabled = false
|
|
|
|
this.canOpenExtra.gameObject:SetActive(false)
|
|
|
|
this.openExtra.gameObject:SetActive(true)
|
|
|
|
Util.GetGameObject(this.openExtra,"KaiQi"):SetActive(false)
|
|
|
|
Util.GetGameObject(this.openExtra,"MeiKaiQi"):SetActive(true)
|
|
|
|
this.openExtra:GetComponent("Animator").enabled = true
|
|
|
|
Timer.New(function()
|
2020-08-28 11:05:31 +08:00
|
|
|
NetManager.GetActivityRewardRequest(-2,QinglongSerectTreasureManager.activityId,function(msg)
|
2020-08-19 10:05:01 +08:00
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(1007, 1)
|
2020-08-28 11:05:31 +08:00
|
|
|
this.refresh()
|
2020-08-19 10:05:01 +08:00
|
|
|
end)
|
|
|
|
end,1.5):Start()
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
--任务列表
|
|
|
|
function this:showTaskList()
|
|
|
|
local rewardData = QinglongSerectTreasureManager.GetAllRewardData()
|
|
|
|
this.ScrollView:SetData(rewardData,function(index, rewardItem)
|
|
|
|
this:SingleTask(rewardItem, rewardData[index])
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- --定位打开界面时位置
|
|
|
|
-- local t = 0
|
|
|
|
-- if treasureState == 0 then
|
|
|
|
-- for i = 1, #rewardStateData do
|
|
|
|
-- if rewardStateData[i].state == 0 then
|
|
|
|
-- t = i
|
|
|
|
-- break
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- elseif treasureState == 1 then
|
|
|
|
-- for i = 1, #rewardStateData do
|
|
|
|
-- if rewardStateData[i].state == 1 or rewardStateData[i].state == 0 then
|
|
|
|
-- t = i
|
|
|
|
-- breakPopupTipPanel
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--this.ScrollView:SetIndex(t-2)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--单个任务
|
|
|
|
function this:SingleTask(rewardItem, rewardSingleData)
|
|
|
|
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")
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
scoreLevel.text = rewardSingleData.level
|
2020-08-28 11:05:31 +08:00
|
|
|
for i = 1, #itemsList[rewardItem] do
|
|
|
|
if i <= #rewardSingleData.Reward and rewardSingleData.Reward[i] then
|
|
|
|
itemsList[rewardItem][i].gameObject:SetActive(true)
|
|
|
|
itemsList[rewardItem][i]:OnOpen(false, rewardSingleData.Reward[i].item, 0.8, false)
|
|
|
|
else
|
|
|
|
itemsList[rewardItem][i].gameObject:SetActive(false)
|
|
|
|
end
|
2020-08-19 10:05:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--初始化按钮状态
|
|
|
|
this:InitButtonState(rewardItem, rewardSingleData)
|
|
|
|
end
|
|
|
|
local type={
|
|
|
|
[-2]={sprite = "s_slbz_1anniuhuise",text = "未达成"},
|
|
|
|
[-1]={sprite = "t_tequan_yidacheng",text = ""},
|
|
|
|
[0]={sprite = "s_slbz_1anniuongse",text = "领取"},
|
|
|
|
[1]={sprite = "s_slbz_1anniuhuangse",text = "再次领取"}
|
|
|
|
}
|
|
|
|
--初始化按钮状态
|
|
|
|
function this:InitButtonState(rewardItem, rewardSingleData)
|
|
|
|
|
|
|
|
local btnDeal = Util.GetGameObject(rewardItem, "btnDeal")
|
|
|
|
|
|
|
|
local get = Util.GetGameObject(rewardItem, "btnDeal/get"):GetComponent("Image")
|
|
|
|
local text = Util.GetGameObject(get.gameObject, "Text"):GetComponent("Text")
|
|
|
|
local redPoint = Util.GetGameObject(rewardItem, "btnDeal/redPoint")
|
|
|
|
--当前任务领取情况
|
|
|
|
local state = rewardSingleData.state
|
|
|
|
Util.GetGameObject(get.gameObject, "Image"):SetActive(state == -1)
|
|
|
|
redPoint:SetActive(state == 0 or (state == 1 and treasureState > 0))
|
|
|
|
get.sprite = Util.LoadSprite(type[state].sprite)
|
|
|
|
get.enabled = true
|
|
|
|
text.text = type[state].text
|
|
|
|
if state == -1 then
|
|
|
|
btnDeal:GetComponent("Button").enabled = false
|
|
|
|
get.enabled = false
|
|
|
|
else
|
|
|
|
btnDeal:GetComponent("Button").enabled = true
|
|
|
|
Util.AddOnceClick(btnDeal,function()
|
|
|
|
this:OnBtnDealClicked(rewardItem,rewardSingleData)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--按钮事件
|
|
|
|
function this:OnBtnDealClicked(rewardItem,rewardSingleData)
|
|
|
|
if rewardSingleData.state ~= -2 then--分数达到要求
|
|
|
|
if (rewardSingleData.state == 0) or--任务未领取
|
|
|
|
(rewardSingleData.state == 1 and treasureState > 0) then--任务未领取+礼包已购买
|
|
|
|
local id = ActivityGiftManager.GetActivityIdByType(8)
|
|
|
|
LogBlue("activityId:"..id)
|
|
|
|
NetManager.GetActivityRewardRequest(rewardSingleData.level,id,function(msg)
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg,1)
|
|
|
|
--需要刷新界面
|
|
|
|
if treasureState == 0 then--判断是否已经购买了礼包
|
|
|
|
QinglongSerectTreasureManager.SetSingleRewardState(rewardSingleData.level,1)
|
|
|
|
else
|
|
|
|
QinglongSerectTreasureManager.SetSingleRewardState(rewardSingleData.level,-1)
|
|
|
|
end
|
|
|
|
this.refresh()--刷新界面
|
|
|
|
end)
|
|
|
|
elseif rewardSingleData.state == 1 and treasureState == 0 then----任务已领取+礼包未购买(弹出购买界面)
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.HeavenUnlockExtraRewardPanel,2)
|
|
|
|
end
|
|
|
|
else--分数未达到要求
|
|
|
|
PopupTipPanel.ShowTip(Language[11989])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function this:ShowTime(endtime)
|
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
|
|
|
local timeDown= endtime - GetTimeStamp()
|
|
|
|
this.remainTime.text = "剩余时间:"..TimeToDHMS(timeDown)
|
|
|
|
self.timer = Timer.New(function()
|
|
|
|
if timeDown < 1 then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
timeDown = timeDown - 1
|
|
|
|
this.remainTime.text = "剩余时间:"..TimeToDHMS(timeDown)
|
|
|
|
end, 1, -1, true)
|
|
|
|
self.timer:Start()
|
|
|
|
end
|
|
|
|
return this
|