miduo_client/Assets/ManagedResources/~Lua/Modules/Mission/MissionDailyPanel_SecretTre...

320 lines
12 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 日常任务弹窗 -----
2020-08-19 10:05:01 +08:00
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local curType = 1
local treasureState
local isPlayAnim = true
2020-08-19 10:05:01 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
function this:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-08-19 10:05:01 +08:00
this.gameObject = gameObject
this.jiesuoBtn = Util.GetGameObject(this.gameObject, "topBar/jiesuoBtn")
this.jiesuoBtnText = Util.GetGameObject(this.jiesuoBtn, "Text"):GetComponent("Text")
2020-08-27 14:53:27 +08:00
this.select = Util.GetGameObject(this.gameObject, "topBar/select")
2020-08-19 10:05:01 +08:00
this.weekTrailBtn = Util.GetGameObject(this.gameObject, "topBar/button/weekTrail")
this.finalTrailBtn = Util.GetGameObject(this.gameObject, "topBar/button/finalTrail")
2020-08-27 14:53:27 +08:00
this.weekTrailBtnRed = Util.GetGameObject(this.weekTrailBtn , "redPoint")
this.finalTrailBtnRed = Util.GetGameObject(this.finalTrailBtn, "redPoint")
2020-08-19 10:05:01 +08:00
this.remainTime = Util.GetGameObject(this.gameObject, "topBar/remainTime/Text"):GetComponent("Text")
this.treasureList = Util.GetGameObject(this.gameObject, "itemList")
local v2 = this.treasureList:GetComponent("RectTransform").sizeDelta
this.itemPre = Util.GetGameObject(this.gameObject, "rewardPre")
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.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.treasureList.transform,
this.itemPre,nil,Vector2.New(v2.x, v2.y),1,1,Vector2.New(100,0))
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
curType = 1
2021-01-26 17:08:39 +08:00
2020-08-19 10:05:01 +08:00
end
function this:BindEvent()
Util.AddClick(this.weekTrailBtn,function()
curType = 1
2021-02-25 12:04:31 +08:00
this.refresh(true,true)
2020-08-19 10:05:01 +08:00
end)
Util.AddClick(this.finalTrailBtn,function()
curType = 2
2021-02-25 12:04:31 +08:00
this.refresh(true,true)
2020-08-19 10:05:01 +08:00
end)
end
function this:SetSelect()
local temp
if curType == 1 then
temp = this.weekTrailBtn.transform
else
temp = this.finalTrailBtn.transform
end
this.select.transform:SetParent(temp)
this.select:GetComponent("RectTransform").anchoredPosition = Vector3.zero
this.select.transform:SetAsFirstSibling()
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess, this.refresh)
Game.GlobalEvent:AddEvent(GameEvent.TreasureOfHeaven.TaskRefresh, this.RefreshTime)
2020-08-19 10:05:01 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose,this.CloseFunction)
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.refresh)
2020-08-19 10:05:01 +08:00
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess, this.refresh)
2020-08-26 20:30:52 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.TreasureOfHeaven.TaskRefresh, this.RefreshTime)
2020-10-12 20:44:15 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose,this.CloseFunction)
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess, this.refresh)
2020-08-19 10:05:01 +08:00
end
function this.RefreshTime()
NetManager.RefreshTimeSLRequest(function (msg)
2021-02-25 12:04:31 +08:00
this.refresh(false,false)
end)
end
this.CloseFunction = function()
2020-08-19 10:05:01 +08:00
Timer.New(function()
2020-09-23 17:41:48 +08:00
if not ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.TreasureOfSomeBody) then
LogBlue("22222222222")
2024-05-21 15:06:54 +08:00
--PopupTipPanel.ShowTip(Language[10471])
if parent then
parent:ClosePanel()
end
2020-08-19 10:05:01 +08:00
return
else
this.RefreshTime()
2020-08-19 10:05:01 +08:00
end
end,1):Start()
end
function this:OnShow(_parent,...)
isPlayAnim = true
2020-08-19 10:05:01 +08:00
parent=_parent
sortingOrder = _parent.sortingOrder
if not ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.TreasureOfSomeBody) then
2020-08-26 18:29:27 +08:00
parent:ClosePanel()
return
end
2021-02-25 12:04:31 +08:00
this.refresh(true,true)
2020-08-19 10:05:01 +08:00
end
--topBar按钮状态
function this:SetTopBar()
treasureState = QinglongSerectTreasureManager.GetTreasureState()--秘宝礼包状态 0:可购买 1:已购买
this.jiesuoBtn:GetComponent("Button").enabled = (not treasureState)
2021-03-02 16:53:12 +08:00
this.jiesuoBtnText.text = ((not treasureState) and Language[11326] or Language[11327])
2020-08-19 10:05:01 +08:00
Util.AddOnceClick(this.jiesuoBtn,function()
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.HeavenUnlockExtraRewardPanel,2)
end)
local times = PrivilegeManager.GetPrivilegeRemainValue(1007)
this.box:GetComponent("Image").enabled = (not treasureState)
this.extra:GetComponent("Button").enabled = (treasureState and (times > 0))
this.canOpenExtra.gameObject:SetActive(treasureState and (times > 0))
2020-08-19 10:05:01 +08:00
this.openExtra:GetComponent("Animator").enabled = false
this.openExtra.gameObject:SetActive(treasureState and (times <= 0))
2020-08-19 10:05:01 +08:00
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 16:36:08 +08:00
local id = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
2020-08-19 10:05:01 +08:00
NetManager.GetActivityRewardRequest(-2,id,function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(1007, 1)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11328])
2021-02-25 12:04:31 +08:00
this.refresh(false,false)
2020-08-19 10:05:01 +08:00
end)
end,1.5):Start()
end)
end
function this:OnSortingOrderChange(sortingOrder)
Util.SetParticleSortLayer(this.canOpenExtra, sortingOrder)
Util.SetParticleSortLayer(this.openExtra, sortingOrder)
end
function this:OnClose()
2020-09-28 05:01:06 +08:00
if self.timer then
self.timer:Stop()
self.timer = nil
end
2020-08-19 10:05:01 +08:00
end
function this:OnDestroy()
2020-08-22 16:55:27 +08:00
if self.timer then
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-08-22 16:55:27 +08:00
self.timer:Stop()
self.timer = nil
end
2020-08-19 10:05:01 +08:00
end
2020-08-26 18:29:27 +08:00
2021-02-25 12:04:31 +08:00
function this.refresh(isTop,isAni)
2020-08-26 18:29:27 +08:00
QinglongSerectTreasureManager.UpdateTreasureState2()
2020-08-19 10:05:01 +08:00
this:SetTopBar()
this:SetSelect()
this:ShowTime(curType)
2021-02-25 12:04:31 +08:00
this:showTaskList(curType,isTop,isAni)
2020-08-27 14:53:27 +08:00
this:SetRedPoint()
2020-08-19 14:12:42 +08:00
CheckRedPointStatus(RedPointType.QinglongSerectTreasureTrail)
CheckRedPointStatus(RedPointType.QinglongSerectTreasure)
2020-08-27 14:53:27 +08:00
2020-08-19 10:05:01 +08:00
end
2020-08-27 14:53:27 +08:00
function this:SetRedPoint()
this.weekTrailBtnRed:SetActive(QinglongSerectTreasureManager.GetSerectTreasureTrailSingleRedPot(1))
this.finalTrailBtnRed:SetActive(QinglongSerectTreasureManager.GetSerectTreasureTrailSingleRedPot(2))
end
2020-08-19 10:05:01 +08:00
2020-09-07 16:09:29 +08:00
local state = {
[1] = 0,
[0] = 1,
[2] = 2,
}
2020-08-19 10:05:01 +08:00
--任务列表
2021-02-25 12:04:31 +08:00
function this:showTaskList(type,isTop,isAni)
2020-08-19 10:05:01 +08:00
local rewardData = QinglongSerectTreasureManager.GetQinglongTaskData(type)
2020-09-07 16:09:29 +08:00
table.sort(rewardData,function(a,b)
if state[a.state] == state[b.state] then
return a.id > b.id
else
return a.state > b.state
end
end)
2020-08-19 10:05:01 +08:00
this.ScrollView:SetData(rewardData,function(index, rewardItem)
this:SingleTask(rewardItem, rewardData[index])
2021-02-25 12:04:31 +08:00
end,not isTop,not isAni)
-- this.ScrollView:SetIndex(1)
-- if isPlayAnim then
-- SecTorPlayAnimByScroll(this.ScrollView)
-- isPlayAnim = false
-- end
2020-08-19 10:05:01 +08:00
end
local type={
2024-03-04 18:49:36 +08:00
[0]={sprite = "Btn_hz_lan_01",text = Language[10019]},
2023-11-15 17:19:43 +08:00
[1]={sprite = "Btn_hz_cheng_01",text = Language[10018]},
[2]={sprite = "Btn_hz_lan_01",text = Language[10101]},
2020-08-19 10:05:01 +08:00
}
--单个任务
function this:SingleTask(go, rewardSingleData)
local activityRewardGo = go
-- if isPlayAnim then
-- activityRewardGo:SetActive(false)
-- else
-- activityRewardGo:SetActive(true)
-- end
2020-08-19 10:05:01 +08:00
local sConFigData = rewardSingleData
2021-01-26 17:08:39 +08:00
local strs = string.split(GetLanguageStrById(sConFigData.show))
2020-08-19 10:05:01 +08:00
local titleText = Util.GetGameObject(activityRewardGo, "content"):GetComponent("Text")
local value = sConFigData.taskValue[2][1]
2020-08-20 17:36:19 +08:00
titleText.text = strs[1].."("..(math.abs(sConFigData.progress) > math.abs(value) and math.abs(value) or math.abs(sConFigData.progress)) .."/"..math.abs(value)..")"
local rewardText = Util.GetGameObject(activityRewardGo, "reward"):GetComponent("Text")
2021-03-02 16:53:12 +08:00
rewardText.text = (strs[2] and strs[2] or "")..sConFigData.integral[1][2]..GetLanguageStrById(itemConfig[tonumber(sConFigData.integral[1][1])].Name) ..Language[11331]
2020-08-28 11:05:31 +08:00
local state = sConFigData.state
2020-08-19 10:05:01 +08:00
local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton")
local red = Util.GetGameObject(lingquButton.gameObject, "redPoint")
red:SetActive(state == 1)
local text = Util.GetGameObject(lingquButton.gameObject, "Text") :GetComponent("Text")
2021-04-21 13:12:04 +08:00
lingquButton:GetComponent("Image").sprite = this.spLoader:LoadSprite(type[state].sprite)
Util.SetGray(lingquButton,state == 2)
lingquButton:GetComponent("Button").enabled = state ~= 2
2020-08-19 10:05:01 +08:00
text.text = type[state].text
Util.AddOnceClick(lingquButton, function()
if state == 1 then
NetManager.TakeMissionRewardRequest(TaskTypeDef.TreasureOfSomeBody,sConFigData.id, function(msg)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11332]..sConFigData.integral[1][2]..GetLanguageStrById(itemConfig[tonumber(sConFigData.integral[1][1])].Name))
2020-08-19 10:05:01 +08:00
Timer.New(function()
2021-02-25 12:04:31 +08:00
this.refresh(false,false)
2020-08-19 10:05:01 +08:00
end,1):Start()
end)
elseif state == 0 then
if sConFigData.jump then
JumpManager.GoJump(sConFigData.jump[1])
end
end
end)
end
function this:ShowTime(curType)
if self.timer then
self.timer:Stop()
self.timer = nil
end
local endtime = curType == 1
and QinglongSerectTreasureManager.GetTrailWeekTime()
or ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.TreasureOfSomeBody)
2021-07-01 21:07:53 +08:00
-- LogBlue("endtime:"..endtime)
2020-08-19 10:05:01 +08:00
local timeDown = endtime - GetTimeStamp()
2021-03-02 16:53:12 +08:00
this.remainTime.text = Language[10470]..TimeToDHMS(timeDown)
2020-08-19 10:05:01 +08:00
self.timer = Timer.New(function()
if timeDown < 1 then
2021-03-02 16:53:12 +08:00
this.remainTime.text = Language[10470]..TimeToDHMS(0)
2020-08-19 10:05:01 +08:00
self.timer:Stop()
self.timer = nil
this.RefreshTime()
return
2020-08-19 10:05:01 +08:00
end
2020-08-19 10:05:01 +08:00
timeDown = timeDown - 1
2021-03-02 16:53:12 +08:00
this.remainTime.text = Language[10470]..TimeToDHMS(timeDown)
2020-08-19 10:05:01 +08:00
end, 1, -1, true)
self.timer:Start()
end
function this:NewItemView(config, gameObject, ...)
local view = reimport(config.script)
if gameObject then
this:playUIAnimsOnStart(gameObject)
end
local sub = view:New(gameObject)
sub.assetName = config.assetName
if sub.Awake then
sub:Awake()
end
if sub.InitComponent then
sub:InitComponent()
end
if sub.BindEvent then
sub:BindEvent()
end
if sub.AddListener then
sub:AddListener()
end
if sub.Update then
UpdateBeat:Add(sub.Update, sub)
end
if sub.OnOpen then
sub:OnOpen(...)
end
return sub
end
function this:playUIAnimsOnStart(gameObject)
local anims = gameObject:GetComponentsInChildren(typeof(PlayFlyAnim))
if anims.Length > 0 then
for i = 0, anims.Length - 1 do
local anim = anims[i]
if anim.isPlayOnOpen then
anim:PlayAnim(false)
end
end
end
end
return this