443 lines
18 KiB
Lua
443 lines
18 KiB
Lua
require("Base/BasePanel")
|
|
SeasonalActivity = Inherit(BasePanel)
|
|
local this = SeasonalActivity
|
|
local SeasonTaskConfig = ConfigManager.GetConfig(ConfigName.SeasonTaskConfig)
|
|
local PassiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
|
local PassiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local TabData = {
|
|
[1] = {
|
|
default = "X1_tongyong_fenlan_weixuanzhong_02",
|
|
select = "X1_tongyong_fenlan_yixuanzhong_02",
|
|
lock = "",
|
|
title = "X1_yjingjichang_jiangliyeqian",
|
|
redpoint = RedPointType.SeasonalActivity_Reward,
|
|
name = GetLanguageStrById(50455)},
|
|
[2] = {
|
|
default = "X1_tongyong_fenlan_weixuanzhong_02",
|
|
select = "X1_tongyong_fenlan_yixuanzhong_02",
|
|
lock = "",
|
|
title = "X1_jingjichang_tiaozhanyeqian",
|
|
redpoint = RedPointType.SeasonalActivity_Task,
|
|
name = GetLanguageStrById(50456)},
|
|
}
|
|
|
|
local curIndex = 1
|
|
local taskIndex = 1
|
|
local taskBtn = {}--任务类型按钮
|
|
local taskItems = {}--任务奖励
|
|
local rewardItems = {}--奖励
|
|
local heroLive
|
|
local heroData
|
|
|
|
function this:InitComponent()
|
|
this.tabBox = Util.GetGameObject(this.gameObject, "Panel/TabBox")
|
|
this.btnHelp = Util.GetGameObject(this.gameObject, "Panel/btnHelp")
|
|
this.btnSkillPreview = Util.GetGameObject(this.gameObject, "btnSkillPreview")
|
|
this.helpPosition = this.btnHelp:GetComponent("RectTransform").localPosition
|
|
this.btnBack = Util.GetGameObject(this.gameObject, "Panel/btnBack")
|
|
this.btnUnlock = Util.GetGameObject(this.gameObject, "Panel/btnUnlock")
|
|
this.time = Util.GetGameObject(this.gameObject, "Panel/time/Text"):GetComponent("Text")
|
|
this.name = Util.GetGameObject(this.gameObject, "Panel/name/name"):GetComponent("Text")
|
|
this.pro = Util.GetGameObject(this.gameObject, "Panel/name/pro"):GetComponent("Image")
|
|
this.star = Util.GetGameObject(this.gameObject, "Panel/name/star")
|
|
this.integral = Util.GetGameObject(this.gameObject, "Panel/integral/Text"):GetComponent("Text")
|
|
this.heroPos = Util.GetGameObject(this.gameObject, "Panel/pos")
|
|
this.taskTime = Util.GetGameObject(this.gameObject, "Panel/title_task/time")
|
|
this.taskTimeTxt = Util.GetGameObject(this.gameObject, "Panel/title_task/time/Text"):GetComponent("Text")
|
|
this.title_reward = Util.GetGameObject(this.gameObject, "Panel/title_reward")
|
|
this.title_lock = Util.GetGameObject(this.gameObject, "Panel/title_reward/lock")
|
|
this.title_task = Util.GetGameObject(this.gameObject, "Panel/title_task")
|
|
for i = 1, 3 do
|
|
taskBtn[i] = Util.GetGameObject(this.title_task, "box/tab"..i)
|
|
end
|
|
|
|
this.tabCtrl = TabBox.New()
|
|
this.tabCtrl:SetTabAdapter(this.OnTabAdapter)
|
|
this.tabCtrl:SetTabIsLockCheck(this.OnTabIsLockCheck)
|
|
this.tabCtrl:SetChangeTabCallBack(this.OnChangeTab)
|
|
|
|
local scroll = Util.GetGameObject(this.gameObject, "scroll").transform
|
|
local pre_reward = Util.GetGameObject(this.gameObject, "scroll/pre_reward")
|
|
local pre_task = Util.GetGameObject(this.gameObject, "scroll/pre_task")
|
|
local v = scroll:GetComponent("RectTransform").rect
|
|
this.scrollView_reward = SubUIManager.Open(SubUIConfig.ScrollCycleView, scroll,
|
|
pre_reward, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0, 7))
|
|
this.scrollView_reward.moveTween.MomentumAmount = 1
|
|
this.scrollView_reward.moveTween.Strength = 1
|
|
|
|
this.scrollView_task = SubUIManager.Open(SubUIConfig.ScrollCycleView, scroll,
|
|
pre_task, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0, 5))
|
|
this.scrollView_task.moveTween.MomentumAmount = 1
|
|
this.scrollView_task.moveTween.Strength = 1
|
|
|
|
this.PlayerHeadFrameView = SubUIManager.Open(SubUIConfig.PlayerHeadFrameView, this.gameObject.transform)
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, this.transform)
|
|
|
|
this.btnStore = Util.GetGameObject(this.gameObject, "Panel/btnStore")
|
|
end
|
|
|
|
function this:BindEvent()
|
|
for i = 1, #taskBtn do
|
|
Util.AddClick(taskBtn[i], function ()
|
|
taskIndex = i
|
|
this.ChangeTaskTab()
|
|
this.OnChangeTask()
|
|
end)
|
|
end
|
|
Util.AddClick(this.btnHelp,function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.SeasonalActivity, this.helpPosition.x, this.helpPosition.y)
|
|
end)
|
|
Util.AddClick(this.btnSkillPreview,function()
|
|
UIManager.OpenPanel(UIName.SeasonalSkillPreviewPanel)
|
|
end)
|
|
Util.AddClick(this.btnBack, function()
|
|
this:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnUnlock, function()
|
|
if PlayerManager.hadBuySeason then
|
|
return
|
|
end
|
|
UIManager.OpenPanel(UIName.UnLockWarOrderPanel, ActivityTypeDef.SeasonalActivity)
|
|
end)
|
|
Util.AddClick(this.btnStore, function()
|
|
local data = ConfigManager.GetConfigData(ConfigName.GlobalActivity, this.activityInfo.activityId)
|
|
local shopData = ConfigManager.GetConfigData(ConfigName.StoreTypeConfig, data.ShopId[1])
|
|
UIManager.OpenPanel(UIName.MapShopPanel, shopData.StoreType)
|
|
end)
|
|
end
|
|
|
|
function this:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnHadBuySeasonChange, this.SetInfo)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityProgressStateChange, this.SetInfo)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Task.SeasonalActivity, this.SetInfo)
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnHadBuySeasonChange, this.SetInfo)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityProgressStateChange, this.SetInfo)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Task.SeasonalActivity, this.SetInfo)
|
|
end
|
|
|
|
function this:OnOpen(index)
|
|
curIndex = index and index or 1
|
|
this.tabCtrl:Init(this.tabBox, TabData, curIndex)
|
|
end
|
|
|
|
function this:OnShow()
|
|
this.SetInfo()
|
|
if not heroLive then
|
|
local acitvityShow = ConfigManager.GetConfigDataByKey(ConfigName.AcitvityShow, "ActivityId", this.activityInfo.activityId)
|
|
this.heroPos:GetComponent("RectTransform").anchoredPosition = Vector2.New(acitvityShow.HeroimgTransform[1][2], acitvityShow.HeroimgTransform[1][3])
|
|
heroData = ConfigManager.GetConfigData(ConfigName.HeroConfig, acitvityShow.Hero[1])
|
|
heroLive = LoadHerolive(heroData, this.heroPos.transform)
|
|
heroLive.gameObject.transform.localScale = Vector3.New(acitvityShow.HeroimgTransform[1][1],acitvityShow.HeroimgTransform[1][1],acitvityShow.HeroimgTransform[1][1])
|
|
this.name.text = GetLanguageStrById(heroData.ReadingName)
|
|
this.pro.sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
SetHeroStars(this.star, heroData.Star)
|
|
end
|
|
end
|
|
|
|
function this:OnSortingOrderChange()
|
|
end
|
|
|
|
function this:OnClose()
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
curIndex = 1
|
|
taskIndex = 1
|
|
taskBtn = {}
|
|
taskItems = {}
|
|
rewardItems = {}
|
|
SubUIManager.Close(this.UpView)
|
|
SubUIManager.Close(this.PlayerHeadFrameView)
|
|
if heroLive then
|
|
UnLoadHerolive(heroData, heroLive)
|
|
Util.ClearChild(this.heroPos.transform)
|
|
heroLive = nil
|
|
heroData = {}
|
|
end
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
end
|
|
|
|
function this.OnTabAdapter(tab, index, status)
|
|
local default = Util.GetGameObject(tab, "default"):GetComponent("Text")
|
|
local select = Util.GetGameObject(tab, "select"):GetComponent("Image")
|
|
local selectTxt = Util.GetGameObject(tab, "select/Text"):GetComponent("Text")
|
|
local redpoint = Util.GetGameObject(tab, "redpoint")
|
|
tab:GetComponent("Image").sprite = Util.LoadSprite(TabData[index][status])
|
|
default.text = TabData[index].name
|
|
select.sprite = Util.LoadSprite(TabData[index].title)
|
|
selectTxt.text = TabData[index].name
|
|
BindRedPointObject(TabData[index].redpoint, redpoint)
|
|
default.gameObject:SetActive(status == "default")
|
|
select.gameObject:SetActive(status == "select")
|
|
end
|
|
|
|
function this.OnTabIsLockCheck(index)
|
|
return false
|
|
end
|
|
|
|
function this.SetInfo()
|
|
CheckRedPointStatus(RedPointType.SeasonalActivity_Reward)
|
|
CheckRedPointStatus(RedPointType.SeasonalActivity_Task)
|
|
this.PlayerHeadFrameView:OnShow(true)
|
|
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.SeasonalActivity)
|
|
local allData = ConfigManager.GetConfigDataByKey(ConfigName.SeasonConfig, "ActivityId", activityId)
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = {16, allData.Integral[1][1]} })
|
|
|
|
local allIntegral = 0
|
|
this.activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SeasonalActivity)
|
|
if this.activityInfo.value > 0 then
|
|
local lvData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SeasonConfig, "Level", this.activityInfo.value-1, "ActivityId", activityId)
|
|
allIntegral = lvData.Integral[1][2] + BagManager.GetItemCountById(lvData.Integral[1][1])
|
|
else
|
|
local lvData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SeasonConfig, "Level", this.activityInfo.value, "ActivityId", activityId)
|
|
allIntegral = BagManager.GetItemCountById(lvData.Integral[1][1])
|
|
end
|
|
this.integral.text = allIntegral
|
|
|
|
if PlayerManager.hadBuySeason then
|
|
this.btnUnlock:GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont("X1_chengzhangshouce_yijiesuo"))
|
|
else
|
|
this.btnUnlock:GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont("X1_chengzhangshouce_jiesuo"))
|
|
end
|
|
|
|
this.time.text = GetLanguageStrById(10525)..TimeToYMDHMS(this.activityInfo.startTime).." - "..TimeToYMDHMS(this.activityInfo.endTime)
|
|
this.title_lock:SetActive(not PlayerManager.hadBuySeason)
|
|
|
|
this.OnChangeTab(curIndex)
|
|
end
|
|
|
|
function this.OnChangeTab(index, lastIndex)
|
|
curIndex = index
|
|
this.scrollView_reward.gameObject:SetActive(curIndex == 1)
|
|
this.scrollView_task.gameObject:SetActive(curIndex == 2)
|
|
this.title_reward:SetActive(curIndex == 1)
|
|
this.title_task:SetActive(curIndex == 2)
|
|
if curIndex == 1 then
|
|
this.OnChangeReward()
|
|
else
|
|
this.ChangeTaskTab()
|
|
this.OnChangeTask()
|
|
this.TaskTimeDown()
|
|
end
|
|
end
|
|
|
|
local firstData
|
|
function this.OnChangeReward()
|
|
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.SeasonalActivity)
|
|
local allData = ConfigManager.GetAllConfigsDataByKey(ConfigName.SeasonConfig, "ActivityId", activityId)
|
|
firstData = allData[1]
|
|
table.remove(allData, 1)
|
|
this.scrollView_reward:SetData(allData, function (index, go)
|
|
this.SetRewardPre(go, allData[index], index, allData)
|
|
end)
|
|
end
|
|
|
|
function this.SetRewardPre(go, configData, index, allConfigData)
|
|
local bg_up = Util.GetGameObject(go, "bg_up")
|
|
local bg_down = Util.GetGameObject(go, "bg_down")
|
|
local up = Util.GetGameObject(go, "up")
|
|
-- local down = Util.GetGameObject(go, "down")
|
|
-- local now = Util.GetGameObject(go, "now")
|
|
local lock = Util.GetGameObject(go, "lock")
|
|
local mask = Util.GetGameObject(go, "mask")
|
|
local integral = Util.GetGameObject(go, "integral"):GetComponent("Text")
|
|
|
|
lock:SetActive(not PlayerManager.hadBuySeason)
|
|
local curIntegral
|
|
if index == 1 then
|
|
-- bg_up:SetActive(false)
|
|
curIntegral = firstData.Integral[1][2]
|
|
elseif index == #allConfigData then
|
|
bg_down:SetActive(false)
|
|
curIntegral = allConfigData[index-1].Integral[1][2]
|
|
else
|
|
bg_up:SetActive(true)
|
|
bg_down:SetActive(true)
|
|
curIntegral = allConfigData[index-1].Integral[1][2]
|
|
end
|
|
if not rewardItems[go] then
|
|
rewardItems[go] = {free = {}, pay = {}}
|
|
end
|
|
for i = 1, #rewardItems[go].free do
|
|
rewardItems[go].free[i].gameObject:SetActive(false)
|
|
end
|
|
for i = 1, #rewardItems[go].pay do
|
|
rewardItems[go].pay[i].gameObject:SetActive(false)
|
|
end
|
|
if not this.activityInfo then
|
|
this.activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SeasonalActivity)
|
|
end
|
|
local severData = ActivityGiftManager.GetActivityInfo(this.activityInfo.activityId, configData.Level)
|
|
|
|
local freeSkill = Util.GetGameObject(go, "ordinary/pre_reward_skill")
|
|
freeSkill:SetActive(configData.FreeSkill ~= 0)
|
|
if configData.FreeSkill ~= 0 then
|
|
local skillData = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig,configData.FreeSkill)
|
|
freeSkill:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(skillData.Icon))
|
|
Util.GetGameObject(freeSkill, "skillName").gameObject:GetComponent("Text").text = GetLanguageStrById(skillData.Name)
|
|
Util.GetGameObject(freeSkill,"Received").gameObject:SetActive(severData.state ~= 0)
|
|
end
|
|
|
|
if configData.Reward then
|
|
for i = 1, #configData.Reward do
|
|
if not rewardItems[go].free[i] then
|
|
rewardItems[go].free[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(go, "ordinary").transform)
|
|
end
|
|
rewardItems[go].free[i]:OnOpen(false, configData.Reward[i], 0.7)
|
|
rewardItems[go].free[i]:SetCorner(2, false)
|
|
rewardItems[go].free[i]:SetCorner(4, severData.state ~= 0)
|
|
rewardItems[go].free[i].gameObject:SetActive(true)
|
|
end
|
|
end
|
|
Util.AddOnceClick(freeSkill, function ()
|
|
local skillData = {skillConfig = PassiveSkillConfig[configData.FreeSkill]}
|
|
UIManager.OpenPanel(UIName.SkillInfoPopup, skillData, 1, 10, 1, 1, PassiveSkillConfig.Level)
|
|
end)
|
|
|
|
local paySkill = Util.GetGameObject(go, "elite/pre_reward_skill")
|
|
paySkill:SetActive(configData.PaySkill ~= 0)
|
|
if configData.PaySkill ~= 0 then
|
|
local skillData = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig,configData.PaySkill)
|
|
paySkill:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(skillData.Icon))
|
|
Util.GetGameObject(paySkill, "skillName").gameObject:GetComponent("Text").text = GetLanguageStrById(skillData.Name)
|
|
Util.GetGameObject(paySkill,"Received").gameObject:SetActive(severData.state == -1)
|
|
end
|
|
|
|
if configData.TreasureReward then
|
|
for i = 1, #configData.TreasureReward do
|
|
if not rewardItems[go].pay[i] then
|
|
rewardItems[go].pay[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(go, "elite").transform)
|
|
end
|
|
rewardItems[go].pay[i]:OnOpen(false, configData.TreasureReward[i], 0.7)
|
|
rewardItems[go].pay[i]:SetCorner(2, not PlayerManager.hadBuySeason)
|
|
rewardItems[go].pay[i]:SetCorner(4, severData.state == -1)
|
|
rewardItems[go].pay[i].gameObject:SetActive(true)
|
|
end
|
|
end
|
|
|
|
Util.AddOnceClick(paySkill, function ()
|
|
local skillData = {skillConfig = PassiveSkillConfig[configData.PaySkill]}
|
|
UIManager.OpenPanel(UIName.SkillInfoPopup, skillData, 1, 10, 1, 1, PassiveSkillConfig.Level)
|
|
end)
|
|
|
|
integral.text = curIntegral
|
|
up:SetActive(this.activityInfo.value >= configData.Level)
|
|
mask:SetActive(this.activityInfo.value < configData.Level)
|
|
local unReceived = Util.GetGameObject(go, "integral/redpoint")
|
|
if this.activityInfo.value >= configData.Level then
|
|
integral.color = Color.New(0/255,0/255,0/255,1)
|
|
unReceived:SetActive(severData.state == 0)
|
|
else
|
|
unReceived:SetActive(false)
|
|
integral.color = Color.New(1,1,1,1)
|
|
end
|
|
Util.AddOnceClick(go, function ()
|
|
NetManager.GetActivityRewardRequest(configData.Level, this.activityInfo.activityId, function(drop)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function ()
|
|
this:OnShow()
|
|
end)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
function this.ChangeTaskTab()
|
|
for i = 1, #taskBtn do
|
|
Util.GetGameObject(taskBtn[i], "select"):SetActive(i == taskIndex)
|
|
end
|
|
this.SetTime()
|
|
this.taskTime:SetActive(taskIndex ~= 3)
|
|
end
|
|
|
|
local State = {
|
|
[1] = 0,
|
|
[0] = 1,
|
|
[2] = 2,
|
|
}
|
|
function this.OnChangeTask()
|
|
local allData = {}
|
|
local allServerData = TaskManager.GetTypeTaskList(TaskTypeDef.SeasonalActivity)
|
|
for i = 1, #allServerData do
|
|
local id = allServerData[i].missionId
|
|
local state = allServerData[i].state
|
|
local progress = allServerData[i].progress
|
|
local configData = SeasonTaskConfig[id]
|
|
if configData.Type == taskIndex then
|
|
table.insert(allData, {id = id, state = state, configData = configData, progress = progress})
|
|
end
|
|
end
|
|
table.sort(allData, function (a, b)
|
|
return State[a.state] < State[b.state]
|
|
end)
|
|
this.scrollView_task:SetData(allData, function (index, go)
|
|
this.SetTaskPre(go, allData[index])
|
|
end)
|
|
end
|
|
|
|
function this.SetTaskPre(go, data)
|
|
local title = Util.GetGameObject(go, "title/Text"):GetComponent("Text")
|
|
local content = Util.GetGameObject(go, "content")
|
|
local btn = Util.GetGameObject(go, "btn")
|
|
local btnTxt = Util.GetGameObject(go, "btn/Text"):GetComponent("Text")
|
|
local finished = Util.GetGameObject(go, "finished")
|
|
local num = data.configData.TaskValue[2][1]
|
|
local progressText = " ("..data.progress.."/"..num..")"
|
|
title.text = GetLanguageStrById(data.configData.Show).."<color=#FFD12B>"..progressText.."</color>"
|
|
if not taskItems[go] then
|
|
taskItems[go] = {}
|
|
end
|
|
for i = 1, #taskItems[go] do
|
|
taskItems[go][i].gameObject:SetActive(false)
|
|
end
|
|
for i = 1, #data.configData.Integral do
|
|
if not taskItems[go][i] then
|
|
taskItems[go][i] = {}
|
|
end
|
|
taskItems[go][i] = SubUIManager.Open(SubUIConfig.ItemView, content.transform)
|
|
taskItems[go][i]:OnOpen(false, data.configData.Integral[i], 0.65)
|
|
taskItems[go][i].gameObject:SetActive(true)
|
|
end
|
|
SetBtnReceiveState(data.state, btn, btnTxt)
|
|
finished:SetActive(data.state == 2)
|
|
btn:SetActive(data.state ~= 2)
|
|
Util.AddOnceClick(btn, function ()
|
|
if data.state == 1 then
|
|
NetManager.TakeMissionRewardRequest(TaskTypeDef.SeasonalActivity, data.id, function(msg)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function ()
|
|
this:OnShow()
|
|
end)
|
|
end)
|
|
else
|
|
JumpManager.GoJump(data.configData.Jump[1])
|
|
end
|
|
end)
|
|
end
|
|
|
|
function this.TaskTimeDown()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
this.timer = Timer.New(function()
|
|
this.SetTime()
|
|
end, 1, -1, true)
|
|
this.timer:Start()
|
|
end
|
|
|
|
function this.SetTime()
|
|
if taskIndex == 1 then
|
|
this.taskTimeTxt.text = TimeToHMS(CalculateSecondsNowTo_N_OClock(0))
|
|
elseif taskIndex == 2 then
|
|
local weekTime = math.floor((GetTimeStamp() - this.activityInfo.startTime)/(7*60*60*24))
|
|
local useTime = (GetTimeStamp() - this.activityInfo.startTime) - weekTime*7*60*60*24
|
|
this.taskTimeTxt.text = TimeToDHMS(7*60*60*24 - useTime)
|
|
end
|
|
end
|
|
|
|
return SeasonalActivity |