miduo_client/Assets/ManagedResources/~Lua/Modules/FindFairy/View/FindFairy_GiftThreeView.lua

207 lines
7.9 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
----- 东海寻仙-进阶 -----
2020-05-09 13:31:21 +08:00
local this = {}
local sortingOrder = 0
local rewardGrid = {}
local rewardItemsGrid = {}
local activeData
function this:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.gameObject = gameObject
this.titleInfoText1 = Util.GetGameObject(gameObject, "Panel/Bg/Image/Text")
this.titleInfoText2 = Util.GetGameObject(gameObject, "Panel/Bg/Image/Text (1)")
2024-09-20 11:45:46 +08:00
this.live2dRoot = Util.GetGameObject(gameObject, "Panel/Live")
2020-05-09 13:31:21 +08:00
this.timeTextGo = Util.GetGameObject(gameObject, "Panel/timeText")
this.timeText = Util.GetGameObject(gameObject, "Panel/timeText"):GetComponent("Text")
for i = 1, 5 do
2024-09-20 11:45:46 +08:00
rewardGrid[i] = Util.GetGameObject(gameObject, "Panel/rect/rect (1)/grid/rewardPre (" .. i .. ")")
2020-05-09 13:31:21 +08:00
local curexpertRewardItemsGri = {}
for j = 1, 4 do
2024-09-20 11:45:46 +08:00
curexpertRewardItemsGri[j] = SubUIManager.Open(SubUIConfig.ItemView,
Util.GetGameObject(rewardGrid[i], "content").transform)
2020-05-09 13:31:21 +08:00
end
rewardItemsGrid[i] = curexpertRewardItemsGri
end
end
function this:BindEvent()
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_sortingOrder)
sortingOrder = _sortingOrder
self:OnShowPanelData()
end
function this:OnShowPanelData()
activeData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.FindFairyUpStar)
2024-09-20 11:45:46 +08:00
local globalActivity = ConfigManager.GetConfigData(ConfigName.GlobalActivity, activeData.activityId)
2020-05-09 13:31:21 +08:00
if globalActivity == nil or activeData == nil then return end
for i = 1, math.max(#activeData.mission, #rewardGrid) do
local go = rewardGrid[i]
if not go then
go = newObject(rewardGrid[1])
go.transform:SetParent(this.expertRewardGridGo.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
rewardGrid[i] = go
end
go.gameObject:SetActive(false)
end
2024-09-20 11:45:46 +08:00
if globalActivity then
2020-05-09 13:31:21 +08:00
local strDec = string.split(globalActivity.ExpertDec, "#")
if globalActivity.ExpertDec then
this.titleInfoText1:SetActive(true)
this.titleInfoText2:SetActive(true)
2024-09-20 11:45:46 +08:00
this.titleInfoText1:GetComponent("Text").text = GetLanguageStrById(strDec[1])
this.titleInfoText2:GetComponent("Text").text = GetLanguageStrById(strDec[2])
2020-05-09 13:31:21 +08:00
else
this.titleInfoText1:SetActive(false)
this.titleInfoText2:SetActive(false)
end
end
if not activeData.mission[1] then return end
2024-09-20 11:45:46 +08:00
local sConFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, activeData.mission[1].missionId)
local sConFigHeroData = ConfigManager.GetConfigData(ConfigName.HeroConfig, sConFigData.Values[1][1])
2020-05-09 13:31:21 +08:00
this.LiveName = GetResourcePath(sConFigHeroData.Live)
this.LiveGO = poolManager:LoadLive(this.LiveName, this.live2dRoot.transform,
2024-09-20 11:45:46 +08:00
Vector3.one * sConFigHeroData.Scale, Vector3.New(sConFigHeroData.Position[1], sConFigHeroData.Position[2], 0))
self:RemainTimeDown(this.timeTextGo, this.timeText, activeData.endTime - GetTimeStamp())
2020-05-09 13:31:21 +08:00
self:ActivityRewardSingleSort(activeData.mission)
for i = 1, #activeData.mission do
2024-09-20 11:45:46 +08:00
self:ActivityRewardSingleShow(i, activeData.mission[i])
2020-05-09 13:31:21 +08:00
end
end
2024-09-20 11:45:46 +08:00
2020-05-09 13:31:21 +08:00
--活动奖励2
2024-09-20 11:45:46 +08:00
function this:ActivityRewardSingleShow(index, rewardData)
2020-05-09 13:31:21 +08:00
local activityRewardGo = rewardGrid[index]
activityRewardGo:SetActive(true)
2024-09-20 11:45:46 +08:00
local sConFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, rewardData.missionId)
2020-05-09 13:31:21 +08:00
local titleText = Util.GetGameObject(activityRewardGo, "titleImage/titleText"):GetComponent("Text")
2021-01-26 17:08:39 +08:00
titleText.text = GetLanguageStrById(sConFigData.ContentsShow)
2020-05-09 13:31:21 +08:00
local content = Util.GetGameObject(activityRewardGo, "content")
for i = 1, math.max(#sConFigData.Reward, #rewardItemsGrid[index]) do
local go = rewardItemsGrid[index][i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, content.transform)
rewardItemsGrid[index][i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #sConFigData.Reward do
rewardItemsGrid[index][i].gameObject:SetActive(true)
2024-09-20 11:45:46 +08:00
rewardItemsGrid[index][i]:OnOpen(false, sConFigData.Reward[i], 0.9, false, false, false, sortingOrder)
2020-05-09 13:31:21 +08:00
end
local lingquButton = Util.GetGameObject(activityRewardGo.gameObject, "lingquButton")
Util.GetGameObject(lingquButton.gameObject, "redPoint"):SetActive(false)
local qianwangButton = Util.GetGameObject(activityRewardGo.gameObject, "qianwangButton")
local getFinishText = Util.GetGameObject(activityRewardGo.gameObject, "getFinishText")
local getRewardProgress = Util.GetGameObject(activityRewardGo.gameObject, "getRewardProgress")
getRewardProgress:SetActive(false)
local state = rewardData.state
local value = sConFigData.Values[2][1]
lingquButton:SetActive(state == 0 and rewardData.progress >= value)
qianwangButton:SetActive(state == 0 and rewardData.progress < value)
getFinishText:SetActive(state == 1)
--getRewardProgress:SetActive(state == 10)
--getRewardProgress:GetComponent("Text").text = rewardData.progress .."/"..value
Util.AddOnceClick(qianwangButton, function()
JumpManager.GoJump(sConFigData.Jump[1])
end)
Util.AddOnceClick(lingquButton, function()
2024-09-20 11:45:46 +08:00
Log("寻仙进阶领取奖励 " .. rewardData.missionId .. " " .. activeData.activityId)
2020-05-09 13:31:21 +08:00
NetManager.GetActivityRewardRequest(rewardData.missionId, activeData.activityId, function(drop)
2024-09-20 11:45:46 +08:00
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function()
2020-05-09 13:31:21 +08:00
self:OnShowPanelData()
end)
end)
end)
end
2024-09-20 11:45:46 +08:00
2020-05-09 13:31:21 +08:00
--排序
function this:ActivityRewardSingleSort(mission)
2024-09-20 11:45:46 +08:00
table.sort(mission, function(a, b)
2020-05-09 13:31:21 +08:00
if a.state == b.state then
return a.missionId < b.missionId
else
return self:SortFun(a) < self:SortFun(b)
end
end)
end
2024-09-20 11:45:46 +08:00
2020-05-09 13:31:21 +08:00
--state任务状态0未领奖1已领奖
function this:SortFun(mission)
if mission.state == 1 then
2024-09-20 11:45:46 +08:00
return 3 --已领奖
2020-05-09 13:31:21 +08:00
else
2024-09-20 11:45:46 +08:00
local sConFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, mission.missionId)
2020-05-09 13:31:21 +08:00
local value = sConFigData.Values[2][1]
if mission.state == 0 and mission.progress >= value then
2024-09-20 11:45:46 +08:00
return 1 --可领奖
2020-05-09 13:31:21 +08:00
else
2024-09-20 11:45:46 +08:00
return 2 --未达成
2020-05-09 13:31:21 +08:00
end
end
end
this.timer = Timer.New()
--刷新倒计时显示
2024-09-20 11:45:46 +08:00
function this:RemainTimeDown(_timeTextExpertgo, _timeTextExpert, timeDown)
2020-05-09 13:31:21 +08:00
if timeDown > 0 then
_timeTextExpertgo:SetActive(true)
2024-09-20 11:45:46 +08:00
_timeTextExpert.text = Language[10026] .. self:TimeStampToDateString(timeDown)
2020-05-09 13:31:21 +08:00
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
2024-09-20 11:45:46 +08:00
_timeTextExpert.text = Language[10026] .. self:TimeStampToDateString(timeDown)
2020-05-09 13:31:21 +08:00
if timeDown < 0 then
_timeTextExpertgo:SetActive(false)
this.timer:Stop()
this.timer = nil
-- PopupTipPanel.ShowTip("活动已结束!")
-- require("Modules/FindFairy/FindFairyPanel"):OnShow()
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
else
_timeTextExpertgo:SetActive(false)
end
end
function this:TimeStampToDateString(second)
local day = math.floor(second / (24 * 3600))
local minute = math.floor(second / 60) % 60
local sec = second % 60
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
2024-09-20 11:45:46 +08:00
return string.format(Language[10702], day, hour, minute, sec)
2020-05-09 13:31:21 +08:00
end
function this:OnClose()
if this.LiveName then
poolManager:UnLoadLive(this.LiveName, this.LiveGO)
this.LiveName = nil
end
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
function this:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2024-09-20 11:45:46 +08:00
return this