2021-11-11 10:06:49 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local LingMaiMiJingPanel = Inherit(BasePanel)
|
2021-11-15 09:56:02 +08:00
|
|
|
|
local lodeConfig = ConfigManager.GetConfig(ConfigName.LodeConfig)
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local TEXTLIST = {
|
|
|
|
|
[1] = "距灵脉秘境结束:%s",
|
|
|
|
|
[2] = "距灵脉秘境开启:%s",
|
|
|
|
|
[3] = "距灵脉秘境关闭:%s",
|
2021-11-16 11:21:37 +08:00
|
|
|
|
[4] = "当前state为0",
|
2021-11-11 16:36:52 +08:00
|
|
|
|
}
|
2021-11-11 10:06:49 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
-- 屏幕适配修改
|
|
|
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
|
|
|
|
self.backBtn = Util.GetGameObject(self.gameObject,"backBtn")
|
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject,"HelpBtn")
|
|
|
|
|
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
|
2021-11-11 16:36:52 +08:00
|
|
|
|
--top
|
|
|
|
|
self.topBar = Util.GetGameObject(self.gameObject,"topBar")
|
|
|
|
|
self.leftTime = Util.GetGameObject(self.topBar,"Text"):GetComponent("Text")
|
2021-11-15 09:56:02 +08:00
|
|
|
|
--bottom
|
|
|
|
|
self.bottom = Util.GetGameObject(self.gameObject,"bottomBar")
|
2021-11-16 18:30:08 +08:00
|
|
|
|
self.time = Util.GetGameObject(self.bottom,"time")
|
|
|
|
|
self.TextTip = Util.GetGameObject(self.bottom,"Text")
|
2021-11-15 09:56:02 +08:00
|
|
|
|
self.mytime = Util.GetGameObject(self.bottom,"time/Text"):GetComponent("Text")
|
|
|
|
|
self.rewardGrid = Util.GetGameObject(self.bottom,"grid")
|
|
|
|
|
self.rewardPre = Util.GetGameObject(self.rewardGrid,"rewardPre")
|
|
|
|
|
self.rewardList = {}
|
2021-11-17 18:28:59 +08:00
|
|
|
|
self.jump = Util.GetGameObject(self.bottom,"Jump")
|
|
|
|
|
self.jumpBtn = Util.GetGameObject(self.jump,"btnJump")
|
2021-11-18 13:17:28 +08:00
|
|
|
|
self.battleTime = Util.GetGameObject(self.jump,"Time/Text"):GetComponent("Text")
|
2021-11-17 18:28:59 +08:00
|
|
|
|
self.inputField = Util.GetGameObject(self.jump, "Input/InputField"):GetComponent("InputField")
|
2021-11-15 09:56:02 +08:00
|
|
|
|
|
2021-11-11 16:36:52 +08:00
|
|
|
|
--rightBtns
|
|
|
|
|
self.rightBtns = Util.GetGameObject(self.gameObject,"rightBtns")
|
|
|
|
|
self.sortBtn = Util.GetGameObject(self.rightBtns,"sortBtn")
|
|
|
|
|
self.rewardBtn = Util.GetGameObject(self.rightBtns,"rewardBtn")
|
|
|
|
|
self.recordBtn = Util.GetGameObject(self.rightBtns,"recordBtn")
|
|
|
|
|
--contentgrid
|
|
|
|
|
self.contentGrid = Util.GetGameObject(self.gameObject,"ContentGrid")
|
|
|
|
|
self.veinList = {}
|
|
|
|
|
self.itemList = {}
|
|
|
|
|
for i = 1, 5 do
|
|
|
|
|
self.veinList[i] = Util.GetGameObject(self.contentGrid,"VeinPre ("..i..")")
|
|
|
|
|
end
|
2021-11-17 16:14:47 +08:00
|
|
|
|
--左右切换按钮
|
|
|
|
|
self.lastBtn = Util.GetGameObject(self.gameObject,"lastBtn")
|
|
|
|
|
self.nextBtn = Util.GetGameObject(self.gameObject,"nextBtn")
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:BindEvent()
|
|
|
|
|
Util.AddClick(self.backBtn,function()
|
2021-11-17 16:14:47 +08:00
|
|
|
|
LingMaiMiJingManager.curPage = 0
|
2021-11-11 10:06:49 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(self.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.LingMaiMiJing,self.helpPosition.x,self.helpPosition.y)
|
|
|
|
|
end)
|
2021-11-15 18:38:53 +08:00
|
|
|
|
Util.AddOnceClick(self.recordBtn, function()
|
|
|
|
|
LingMaiMiJingManager.OpenRecord()
|
|
|
|
|
end)
|
2021-11-16 11:21:37 +08:00
|
|
|
|
Util.AddOnceClick(self.rewardBtn, function()
|
2021-11-18 11:35:20 +08:00
|
|
|
|
table.sort(self.groupList, function (a,b)
|
|
|
|
|
return a.Id < b.Id
|
|
|
|
|
end )
|
|
|
|
|
local num = LingMaiMiJingManager.myPlaceId - self.groupList[1].Id + 1
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralRankRewardPanel,5,num)--需要活动id,和我的排名
|
2021-11-16 11:21:37 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(self.sortBtn, function()
|
2021-11-17 17:24:51 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[33])
|
2021-11-16 11:21:37 +08:00
|
|
|
|
end)
|
2021-11-17 16:14:47 +08:00
|
|
|
|
Util.AddClick(self.lastBtn,function()
|
|
|
|
|
LingMaiMiJingManager.curPage = LingMaiMiJingManager.curPage - 1
|
|
|
|
|
self:OnShow()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.nextBtn,function()
|
|
|
|
|
LingMaiMiJingManager.curPage = LingMaiMiJingManager.curPage + 1
|
|
|
|
|
self:OnShow()
|
|
|
|
|
end)
|
2021-11-17 18:28:59 +08:00
|
|
|
|
Util.AddClick(self.jumpBtn,function()
|
|
|
|
|
if self.inputField.text ~= "" then
|
|
|
|
|
local num = tonumber(self.inputField.text)
|
2021-11-18 11:35:20 +08:00
|
|
|
|
if num > #self.groupList/5 then
|
|
|
|
|
num = #self.groupList/5
|
2021-11-17 18:28:59 +08:00
|
|
|
|
elseif num < 0 then
|
|
|
|
|
num = 1
|
|
|
|
|
end
|
|
|
|
|
LingMaiMiJingManager.curPage = num
|
|
|
|
|
self:OnShow()
|
|
|
|
|
self.inputField.text = ""
|
|
|
|
|
else
|
|
|
|
|
PopupTipPanel.ShowTip("请输入要前往的位置")
|
|
|
|
|
end
|
|
|
|
|
end)
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:AddListener()
|
2021-11-11 16:36:52 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.LingMaiMiJing.RefreshPanel, self.OnShow,self)
|
2021-11-18 13:29:26 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.LingMaiMiJing.ClosePanel, self.OnClose,self)
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:RemoveListener()
|
2021-11-11 16:36:52 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.LingMaiMiJing.RefreshPanel, self.OnShow,self)
|
2021-11-18 13:29:26 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.LingMaiMiJing.ClosePanel, self.OnClose,self)
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--跨服
|
|
|
|
|
function LingMaiMiJingPanel:OnOpen()
|
2021-11-11 14:28:02 +08:00
|
|
|
|
self.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:OnShow()
|
2021-11-17 16:14:47 +08:00
|
|
|
|
NetManager.GetLingMaiInfoRequest(LingMaiMiJingManager.curPage,function ()
|
2021-11-16 17:34:37 +08:00
|
|
|
|
self.data = LingMaiMiJingManager.GetData()
|
2021-11-18 13:29:26 +08:00
|
|
|
|
if not self.data then
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-11-16 17:34:37 +08:00
|
|
|
|
self:SetTime()
|
|
|
|
|
self:SetMydata()
|
|
|
|
|
self:SetVeins()
|
2021-11-18 14:10:57 +08:00
|
|
|
|
self.groupList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.LodeConfig,"Group",lodeConfig[self.data.lingmaiData[1].Id].Group)
|
2021-11-17 16:14:47 +08:00
|
|
|
|
self.lastBtn:SetActive(LingMaiMiJingManager.curPage - 1 > 0)
|
|
|
|
|
self.nextBtn:SetActive(LingMaiMiJingManager.curPage + 1 <= 50)
|
2021-11-16 11:21:37 +08:00
|
|
|
|
end)
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-15 09:56:02 +08:00
|
|
|
|
function LingMaiMiJingPanel:SetMydata()
|
2021-11-16 18:30:08 +08:00
|
|
|
|
if self.data.myPlaceId > 0 then
|
|
|
|
|
self.time:SetActive(true)
|
|
|
|
|
self.TextTip:SetActive(false)
|
|
|
|
|
self.rewardGrid:SetActive(true)
|
|
|
|
|
local configData = lodeConfig[self.data.myPlaceId]
|
|
|
|
|
for i = 1, #self.rewardList do
|
|
|
|
|
self.rewardList[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for j = 1, #configData.RewardList do
|
|
|
|
|
local item = self.rewardList[j]
|
|
|
|
|
if not item then
|
|
|
|
|
item = newObjToParent(self.rewardPre,self.rewardGrid.transform)
|
|
|
|
|
self.rewardList[j] = item
|
|
|
|
|
end
|
|
|
|
|
item:SetActive(true)
|
|
|
|
|
Util.GetGameObject(item,"icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(configData.RewardList[j][1]))
|
|
|
|
|
Util.GetGameObject(item,"Text"):GetComponent("Text").text = string.format( "%s/分",configData.RewardList[j][2])
|
2021-11-15 09:56:02 +08:00
|
|
|
|
end
|
2021-11-16 18:30:08 +08:00
|
|
|
|
else
|
|
|
|
|
self.time:SetActive(false)
|
|
|
|
|
self.TextTip:SetActive(true)
|
|
|
|
|
self.rewardGrid:SetActive(false)
|
2021-11-15 09:56:02 +08:00
|
|
|
|
end
|
2021-11-18 13:17:28 +08:00
|
|
|
|
self.battleTime.text = string.format("剩余挑战次数:%s",5)
|
2021-11-15 09:56:02 +08:00
|
|
|
|
ForceRebuildLayout(self.bottom.transform)
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-11 16:36:52 +08:00
|
|
|
|
function LingMaiMiJingPanel:SetVeins()
|
|
|
|
|
for i = 1, 5 do
|
|
|
|
|
local go = self.veinList[i]
|
2021-11-17 16:14:47 +08:00
|
|
|
|
local data = self.data.lingmaiData[i]
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local title = Util.GetGameObject(go,"title/Name"):GetComponent("Text")
|
|
|
|
|
local num = Util.GetGameObject(go,"title/Num"):GetComponent("Text")
|
2021-11-18 13:17:28 +08:00
|
|
|
|
local obtain = Util.GetGameObject(go,"obtain")
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local name = Util.GetGameObject(go,"obtain/name"):GetComponent("Text")
|
|
|
|
|
local grid = Util.GetGameObject(go,"obtain/grid")
|
|
|
|
|
local rewardPre = Util.GetGameObject(grid,"rewardPre")
|
|
|
|
|
rewardPre:SetActive(false)
|
2021-11-18 13:17:28 +08:00
|
|
|
|
-- obtain:SetActive(LingMaiMiJingManager.state == 1)
|
|
|
|
|
obtain:SetActive(true)
|
2021-11-11 16:36:52 +08:00
|
|
|
|
|
2021-11-17 16:14:47 +08:00
|
|
|
|
title.text = data.veinName
|
2021-11-11 17:53:47 +08:00
|
|
|
|
num.text = data.No
|
2021-11-17 16:14:47 +08:00
|
|
|
|
name.text = string.format( "%s %s",data.servername,data.name)
|
2021-11-11 16:36:52 +08:00
|
|
|
|
if not self.itemList[i] then
|
|
|
|
|
self.itemList[i] = {}
|
|
|
|
|
end
|
|
|
|
|
for k = 1, #self.itemList[i] do
|
|
|
|
|
self.itemList[i][k]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for j = 1, #data.RewardList do
|
|
|
|
|
local item = self.itemList[i][j]
|
|
|
|
|
if not item then
|
|
|
|
|
item = newObjToParent(rewardPre,grid.transform)
|
|
|
|
|
self.itemList[i][j] = item
|
|
|
|
|
end
|
|
|
|
|
item:SetActive(true)
|
|
|
|
|
Util.GetGameObject(item,"icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(data.RewardList[j][1]))
|
|
|
|
|
Util.GetGameObject(item,"Text"):GetComponent("Text").text = string.format( "%s/分",data.RewardList[j][2])
|
|
|
|
|
end
|
2021-11-16 17:34:37 +08:00
|
|
|
|
Util.AddOnceClick(go,function ()
|
2021-11-18 13:17:28 +08:00
|
|
|
|
-- if LingMaiMiJingManager.state == 1 then
|
|
|
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, data.uid,PLAYER_INFO_VIEW_TYPE.LINGMAIMIJING,data.serverName and data.serverName or nil,data)
|
|
|
|
|
-- else
|
|
|
|
|
-- PopupTipPanel.ShowTip("<color=red>灵脉秘境未开启!</color>")
|
|
|
|
|
-- end
|
2021-11-16 17:34:37 +08:00
|
|
|
|
end)
|
2021-11-11 16:36:52 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function LingMaiMiJingPanel:SetTime()
|
|
|
|
|
if self.data.state == 0 then
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
|
|
|
|
local time = self.data.endTime - GetTimeStamp()
|
2021-11-15 09:56:02 +08:00
|
|
|
|
local timeStayAtHere = GetTimeStamp() - self.data.startTime
|
|
|
|
|
self.mytime.text = string.format("%s分",math.floor( timeStayAtHere/60 ))
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local text = TEXTLIST[self.data.state]
|
2021-11-18 13:17:28 +08:00
|
|
|
|
self.leftTime.text = string.format(text,TimeToHMS(time))
|
2021-11-11 16:36:52 +08:00
|
|
|
|
self.timer = Timer.New(function ()
|
|
|
|
|
time = time - 1
|
2021-11-15 09:56:02 +08:00
|
|
|
|
timeStayAtHere = timeStayAtHere + 1
|
2021-11-18 13:17:28 +08:00
|
|
|
|
self.leftTime.text = string.format(text,TimeToHMS(time))
|
2021-11-15 09:56:02 +08:00
|
|
|
|
self.mytime.text = string.format("%s分",math.floor( timeStayAtHere/60 ))
|
2021-11-11 16:36:52 +08:00
|
|
|
|
if time <= 0 then
|
|
|
|
|
self:OnShow()
|
|
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:OnClose()
|
2021-11-11 16:36:52 +08:00
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function LingMaiMiJingPanel:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
2021-11-11 16:36:52 +08:00
|
|
|
|
self.veinList = {}
|
2021-11-15 09:56:02 +08:00
|
|
|
|
self.rewardList = {}
|
|
|
|
|
self.itemList = {}
|
2021-11-11 10:06:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return LingMaiMiJingPanel
|