2021-09-28 10:34:05 +08:00
|
|
|
require("Base/BasePanel")
|
|
|
|
local YuJianXingPanel = Inherit(BasePanel)
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
function YuJianXingPanel:InitComponent()
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
--Btns
|
|
|
|
self.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn")
|
|
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
self.btnBet = Util.GetGameObject(self.gameObject, "Bgs/Down/btns/btnBet")
|
|
|
|
self.btnRecord = Util.GetGameObject(self.gameObject, "Bgs/Down/btns/btnRecord")
|
|
|
|
self.btnRank = Util.GetGameObject(self.gameObject, "Bgs/Down/btns/btnRank")
|
|
|
|
self.btnStore = Util.GetGameObject(self.gameObject, "Bgs/Down/btns/btnStore")
|
|
|
|
--Text
|
|
|
|
self.curActTime = Util.GetGameObject(self.gameObject, "Bgs/Up/Board/time1"):GetComponent("Text")
|
|
|
|
self.nextRoundTime = Util.GetGameObject(self.gameObject, "Bgs/Up/Board/time2"):GetComponent("Text")
|
|
|
|
self.canBetTime = Util.GetGameObject(self.gameObject, "Bgs/Up/Board/time3"):GetComponent("Text")
|
|
|
|
--Bg
|
|
|
|
self.bg = Util.GetGameObject(self.gameObject, "Bgs/Bg")
|
2021-10-11 17:25:48 +08:00
|
|
|
--count
|
|
|
|
self.countFrame = Util.GetGameObject(self.gameObject, "StartAni")
|
|
|
|
self.countFrame:SetActive(false)
|
|
|
|
self.countmask = Util.GetGameObject(self.countFrame, "mask")
|
|
|
|
self.countbg = Util.GetGameObject(self.countFrame, "bg")
|
|
|
|
self.countText1 = Util.GetGameObject(self.countFrame, "Text1")
|
|
|
|
self.countText2 = Util.GetGameObject(self.countFrame, "Text2")
|
|
|
|
self.countText3 = Util.GetGameObject(self.countFrame, "Text3")
|
|
|
|
self.countText4 = Util.GetGameObject(self.countFrame, "Text4")
|
2021-10-12 11:26:48 +08:00
|
|
|
--waiting
|
|
|
|
self.waiting = Util.GetGameObject(self.gameObject, "Waiting")
|
|
|
|
self.waitTime = Util.GetGameObject(self.waiting, "time"):GetComponent("Text")
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
function YuJianXingPanel:BindEvent()
|
|
|
|
Util.AddOnceClick(self.backBtn,function ()
|
2021-10-12 11:26:48 +08:00
|
|
|
SwitchPanel.OpenPanel(nil,function ()
|
|
|
|
self:ClosePanel()
|
|
|
|
end)
|
2021-09-28 10:34:05 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.helpBtn,function ()
|
2021-10-12 17:21:46 +08:00
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.YuJianXing,self.helpPosition.x,self.helpPosition.y)
|
2021-09-28 10:34:05 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnBet,function ()
|
2021-10-12 17:21:46 +08:00
|
|
|
if YuJianXingManager.curState == 2 then
|
|
|
|
PopupTipPanel.ShowTip("比赛进行中,不可竞猜!")
|
|
|
|
return
|
|
|
|
end
|
2021-10-08 20:49:25 +08:00
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YuJianBet)
|
2021-09-28 10:34:05 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnRecord,function ()
|
2021-09-28 17:48:28 +08:00
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.YuJianXingRecord)
|
2021-09-28 10:34:05 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnRank,function ()
|
2021-10-08 20:49:25 +08:00
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YuJianLastResult)
|
2021-09-28 10:34:05 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnStore,function ()
|
2021-10-12 17:21:46 +08:00
|
|
|
if YuJianXingManager.curState == 2 then
|
|
|
|
PopupTipPanel.ShowTip("请比赛结束后前往~")
|
|
|
|
return
|
|
|
|
end
|
2021-09-28 17:48:28 +08:00
|
|
|
JumpManager.GoJump(20003)
|
|
|
|
end)
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
function YuJianXingPanel:AddListener()
|
2021-10-12 11:26:48 +08:00
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.YuJianXing.GameFinished, self.Refresh,self)
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
function YuJianXingPanel:RemoveListener()
|
2021-10-12 11:26:48 +08:00
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.YuJianXing.GameFinished, self.Refresh,self)
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function YuJianXingPanel:OnSortingOrderChange()
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
function YuJianXingPanel:OnOpen()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
function YuJianXingPanel:OnShow()
|
2021-10-12 17:21:46 +08:00
|
|
|
if YuJianXingManager.curState == 2 then
|
|
|
|
YuJianXingManager.InWaiting = true
|
|
|
|
end
|
2021-10-11 14:37:33 +08:00
|
|
|
--开启地图
|
2021-10-08 15:45:28 +08:00
|
|
|
YuJianXingManager.OpenMap()
|
2021-10-11 17:25:48 +08:00
|
|
|
self:Refresh()
|
|
|
|
end
|
|
|
|
|
|
|
|
function YuJianXingPanel:Refresh()
|
2021-10-12 17:21:46 +08:00
|
|
|
if YuJianXingManager.InWaiting then
|
|
|
|
YuJianXingManager.HideAllPlayers(false)
|
|
|
|
end
|
2021-10-12 11:26:48 +08:00
|
|
|
self.waiting:SetActive(YuJianXingManager.InWaiting)
|
2021-10-11 14:37:33 +08:00
|
|
|
--为小人在地图上下移动做处理
|
2021-10-09 16:24:34 +08:00
|
|
|
self.count = 0
|
2021-10-11 17:25:48 +08:00
|
|
|
self:SetTime()
|
|
|
|
end
|
|
|
|
|
|
|
|
--比赛开始动画
|
|
|
|
function YuJianXingPanel:StartAnimation()
|
|
|
|
local thread = coroutine.start(function()
|
|
|
|
self.countFrame:SetActive(true)
|
|
|
|
self.countmask:SetActive(true)
|
|
|
|
self.countbg:SetActive(true)
|
|
|
|
self.countText1:SetActive(true)
|
|
|
|
self.countText2:SetActive(false)
|
|
|
|
self.countText3:SetActive(false)
|
|
|
|
self.countText4:SetActive(false)
|
|
|
|
PlayUIAnim(self.countmask)
|
|
|
|
PlayUIAnim(self.countbg)
|
|
|
|
PlayUIAnim(self.countText1)
|
|
|
|
coroutine.wait(1)
|
|
|
|
self.countText1:SetActive(false)
|
|
|
|
self.countText2:SetActive(true)
|
|
|
|
PlayUIAnim(self.countText2)
|
|
|
|
coroutine.wait(1)
|
|
|
|
self.countText2:SetActive(false)
|
|
|
|
self.countText3:SetActive(true)
|
|
|
|
PlayUIAnim(self.countText3)
|
|
|
|
coroutine.wait(1)
|
|
|
|
self.countText3:SetActive(false)
|
|
|
|
self.countText4:SetActive(true)
|
|
|
|
PlayUIAnim(self.countText4)
|
|
|
|
coroutine.wait(1)
|
|
|
|
self.countbg:SetActive(false)
|
|
|
|
self.countText4:SetActive(false)
|
|
|
|
self.countFrame:SetActive(false)
|
2021-10-12 11:26:48 +08:00
|
|
|
--开始游戏
|
2021-10-11 17:25:48 +08:00
|
|
|
YuJianXingManager.SetGameState(true)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
function YuJianXingPanel:SetTime()
|
2021-10-09 16:24:34 +08:00
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
2021-10-11 17:25:48 +08:00
|
|
|
local activityEnd = YuJianXingManager.activityTimeCount - GetTimeStamp()
|
|
|
|
local roundEnd = YuJianXingManager.nextTimeCount - GetTimeStamp()
|
|
|
|
self.curActTime.text = string.format("本期活动倒计时:%s",TimeToDHM(activityEnd))
|
2021-10-12 11:26:48 +08:00
|
|
|
if YuJianXingManager.curState == 1 then
|
|
|
|
self.nextRoundTime.text = string.format("下一轮倒计时:%s",TimeToMS(roundEnd))
|
|
|
|
elseif YuJianXingManager.curState == 2 then
|
|
|
|
self.nextRoundTime.text = string.format("比赛进行中···")
|
|
|
|
end
|
2021-10-09 16:24:34 +08:00
|
|
|
self.timer = Timer.New(function ()
|
2021-10-11 17:25:48 +08:00
|
|
|
--设置人物上下飘动2s重置一次
|
2021-10-09 16:24:34 +08:00
|
|
|
if self.count % 2 == 0 then
|
|
|
|
YuJianXingManager.ResetPlayerPosVertical()
|
|
|
|
end
|
|
|
|
self.count = self.count + 1
|
2021-10-11 17:25:48 +08:00
|
|
|
--回合倒计时
|
|
|
|
roundEnd = roundEnd - 1
|
|
|
|
if YuJianXingManager.curState == 1 then
|
|
|
|
self.nextRoundTime.text = string.format("下一轮倒计时:%s",TimeToMS(roundEnd))
|
|
|
|
if roundEnd <= 0 then
|
2021-10-12 11:26:48 +08:00
|
|
|
YuJianXingManager.ReGetInfo(function ()
|
2021-10-12 15:53:57 +08:00
|
|
|
YuJianXingManager.ReloadPlayersData(YuJianXingManager.curResult.rankId)
|
2021-10-12 11:26:48 +08:00
|
|
|
self:StartAnimation()
|
|
|
|
end)
|
2021-10-11 17:25:48 +08:00
|
|
|
end
|
|
|
|
elseif YuJianXingManager.curState == 2 then
|
|
|
|
self.nextRoundTime.text = string.format("比赛进行中···")
|
2021-10-12 11:26:48 +08:00
|
|
|
self.waitTime.text = string.format("倒计时:%s",TimeToMS(roundEnd))
|
|
|
|
if roundEnd <= 0 then
|
|
|
|
YuJianXingManager.ReGetInfo(function ()
|
|
|
|
self:Refresh()
|
|
|
|
end)
|
|
|
|
end
|
2021-10-11 17:25:48 +08:00
|
|
|
end
|
|
|
|
--活动倒计时
|
|
|
|
activityEnd = activityEnd - 1
|
|
|
|
self.curActTime.text = string.format("本期活动倒计时:%s",TimeToDHM(activityEnd))
|
|
|
|
if activityEnd <= 0 then
|
|
|
|
self:ClosePanel()
|
|
|
|
end
|
2021-10-09 18:17:59 +08:00
|
|
|
end,1,-1)
|
|
|
|
self.timer:Start()
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
function YuJianXingPanel:OnClose()
|
2021-10-11 14:37:33 +08:00
|
|
|
--关闭地图--直接销毁
|
2021-10-08 15:45:28 +08:00
|
|
|
YuJianXingManager.CloseMap()
|
2021-10-09 16:24:34 +08:00
|
|
|
self.count = 0
|
|
|
|
if self.timer then
|
|
|
|
self.timer:Stop()
|
|
|
|
self.timer = nil
|
|
|
|
end
|
2021-09-28 10:34:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
function YuJianXingPanel:OnDestroy()
|
|
|
|
end
|
|
|
|
|
|
|
|
return YuJianXingPanel
|