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-19 11:45:53 +08:00
|
|
|
|
local veinName = {
|
|
|
|
|
[3] = "l_lmmj_huangjilingmai",
|
|
|
|
|
[4] = "l_lmmj_xuanjilingmai",
|
|
|
|
|
[5] = "l_lmmj_dijilingmai",
|
|
|
|
|
[6] = "l_lmmj_tianjilingmai",
|
|
|
|
|
}
|
2021-11-19 15:38:41 +08:00
|
|
|
|
local fakeName = {
|
|
|
|
|
[3] = "黄级",
|
|
|
|
|
[4] = "玄级",
|
|
|
|
|
[5] = "地级",
|
|
|
|
|
[6] = "天级",
|
|
|
|
|
}
|
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-18 18:43:22 +08:00
|
|
|
|
self.buyTime = Util.GetGameObject(self.jump,"Time2/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")
|
2021-11-18 18:43:22 +08:00
|
|
|
|
self.recordRed = Util.GetGameObject(self.recordBtn,"red")
|
2021-11-11 16:36:52 +08:00
|
|
|
|
--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-19 15:38:41 +08:00
|
|
|
|
NetManager.RequestRankInfo(RANK_TYPE.LINGMAIMIJING_RANK, function (msg)--请求数据
|
|
|
|
|
LogYellow("我的排名:"..tostring(msg.myRankInfo.rank))
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralRankRewardPanel,5,msg.myRankInfo.rank)--需要活动id,和我的排名
|
|
|
|
|
end,0,1,0)
|
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()
|
2021-11-19 11:45:53 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.LingMaiJump,#self.groupList/5)
|
2021-11-17 18:28:59 +08:00
|
|
|
|
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-19 15:38:41 +08:00
|
|
|
|
if LingMaiMiJingManager.state == 2 then
|
|
|
|
|
LingMaiMiJingManager.curPage = 1
|
|
|
|
|
end
|
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-19 15:38:41 +08:00
|
|
|
|
if LingMaiMiJingManager.state == 0 then
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-11-16 17:34:37 +08:00
|
|
|
|
self.data = LingMaiMiJingManager.GetData()
|
|
|
|
|
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-19 11:45:53 +08:00
|
|
|
|
self.inputField.text = LingMaiMiJingManager.curPage
|
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 18:43:22 +08:00
|
|
|
|
if self.data.state ~= 1 then
|
|
|
|
|
self.time:SetActive(false)
|
|
|
|
|
self.TextTip:SetActive(false)
|
|
|
|
|
self.rewardGrid:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
self.buyTime.text = string.format("剩余购买次数:%s",PrivilegeManager.GetPrivilegeRemainValue(2031))
|
2021-11-18 14:39:50 +08:00
|
|
|
|
self.battleTime.text = string.format("剩余挑战次数:%s",PrivilegeManager.GetPrivilegeRemainValue(2030))
|
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 num = Util.GetGameObject(go,"title/Num"):GetComponent("Text")
|
2021-11-19 11:45:53 +08:00
|
|
|
|
local nameImg = Util.GetGameObject(go,"title/NameImg"):GetComponent("Image")
|
2021-11-18 13:17:28 +08:00
|
|
|
|
local obtain = Util.GetGameObject(go,"obtain")
|
2021-11-19 11:45:53 +08:00
|
|
|
|
local obtainImg = Util.GetGameObject(go,"obtain"):GetComponent("Image")
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local name = Util.GetGameObject(go,"obtain/name"):GetComponent("Text")
|
2021-11-19 15:38:41 +08:00
|
|
|
|
local server = Util.GetGameObject(go,"obtain/server"):GetComponent("Text")
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local grid = Util.GetGameObject(go,"obtain/grid")
|
|
|
|
|
local rewardPre = Util.GetGameObject(grid,"rewardPre")
|
|
|
|
|
rewardPre:SetActive(false)
|
2021-11-18 15:14:39 +08:00
|
|
|
|
obtain:SetActive(LingMaiMiJingManager.state == 1)
|
2021-11-11 16:36:52 +08:00
|
|
|
|
|
2021-11-19 11:45:53 +08:00
|
|
|
|
local img = data.uid == PlayerManager.uid and "l_lmmj_lingmaixinxidi01" or "l_lmmj_lingmaixinxidi"
|
|
|
|
|
obtainImg.sprite = self.spLoader:LoadSprite(img)
|
|
|
|
|
nameImg.sprite = self.spLoader:LoadSprite(veinName[data.Quality])
|
2021-11-11 17:53:47 +08:00
|
|
|
|
num.text = data.No
|
2021-11-19 15:38:41 +08:00
|
|
|
|
server.text = data.servername == "" and fakeName[data.Quality] or data.servername
|
|
|
|
|
name.text = 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 15:14:39 +08:00
|
|
|
|
if LingMaiMiJingManager.state == 1 then
|
2021-11-18 13:17:28 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, data.uid,PLAYER_INFO_VIEW_TYPE.LINGMAIMIJING,data.serverName and data.serverName or nil,data)
|
2021-11-18 15:14:39 +08:00
|
|
|
|
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.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
|
2021-11-19 15:38:41 +08:00
|
|
|
|
--我已占领了多久
|
2021-11-15 09:56:02 +08:00
|
|
|
|
self.mytime.text = string.format("%s分",math.floor( timeStayAtHere/60 ))
|
2021-11-19 15:38:41 +08:00
|
|
|
|
--判断上方时间显示文字
|
2021-11-11 16:36:52 +08:00
|
|
|
|
local text = TEXTLIST[self.data.state]
|
2021-11-19 15:38:41 +08:00
|
|
|
|
if self.data.state == 2 and CalculateSecondsNowTo_N_OClock(24) <= 10800 then
|
|
|
|
|
text = TEXTLIST[3]
|
|
|
|
|
else
|
|
|
|
|
end
|
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-19 15:38:41 +08:00
|
|
|
|
self.recordRed:SetActive(LingMaiMiJingManager.CheckRecord())
|
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
|