miduo_client/Assets/ManagedResources/~Lua/Modules/YuJianXing/YuJianXingManager.lua

165 lines
4.8 KiB
Lua
Raw Normal View History

2021-09-29 18:34:54 +08:00
YuJianXingManager = {}
local this = YuJianXingManager
local riceCtrl = require("Modules/YuJianXing/RiceCtrlView")
2021-10-12 11:26:48 +08:00
local bgList = {"y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg"}
2021-10-14 15:30:46 +08:00
local configData = ConfigManager.GetConfigData(ConfigName.RidingSwardConfig,1)
2021-09-29 18:34:54 +08:00
function this.Initialize()
2021-10-13 17:38:32 +08:00
this.joinCount = 0--参与投注的轮数
2021-09-29 18:34:54 +08:00
this.curState = 0 --当前比赛状态
2021-10-11 17:25:48 +08:00
this.nextTimeCount = 0 --下轮开始时间
this.activityTimeCount = 0 --活动倒计时
2021-10-13 15:39:47 +08:00
this.curResultId = {} --当前剧本的Id
this.lastResult = {} --上一场剧本的时间和ID
this.curRecordList = {} --当前纪录数据
this.curBetList = {} --当前竞猜数据
2021-10-14 11:25:44 +08:00
this.modelList = {}--玩家名等数据
2021-10-12 11:26:48 +08:00
this.InWaiting = false
2021-10-13 15:39:47 +08:00
this.sendEvent = true
2021-10-08 20:49:25 +08:00
this.CloseMap()
2021-09-29 18:34:54 +08:00
end
2021-10-08 15:45:28 +08:00
--初始化地图
function this.OpenMap()
2021-10-12 15:53:57 +08:00
local playerData = ConfigManager.GetConfigDataByKey(ConfigName.RidingSwardResult,"Id",1)--1是初始化用
2021-10-08 15:45:28 +08:00
if not this.riceCtrl then
this.riceCtrl = riceCtrl:New()
2021-10-08 20:49:25 +08:00
this.riceCtrl:Awake(bgList,playerData)
2021-10-08 15:45:28 +08:00
end
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
--销毁地图--正常
function this.CloseMap()
if this.riceCtrl then
this.riceCtrl:Dispose()
this.riceCtrl = nil
end
2021-09-29 18:34:54 +08:00
end
2021-10-12 11:26:48 +08:00
--重新请求数据
function this.ReGetInfo(func)
local id = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.YuJianXing)
NetManager.RidingSwardActivityRequest(id.activityId,func)
end
2021-10-11 14:37:33 +08:00
--更新服务器界面信息
function this.UpdataServerPanelData(msg,func)
2021-10-13 19:15:39 +08:00
this.joinCount = msg.betCount--参与投注的轮数
2021-10-11 14:37:33 +08:00
this.curState = msg.state--当前状态
2021-10-12 11:26:48 +08:00
if msg.state == 1 then
this.InWaiting = false
end
this.nextTimeCount = msg.time/1000--下一场倒计时
2021-10-13 15:39:47 +08:00
LogYellow("当前state:"..tostring(msg.state).." 下一阶段倒计时:"..TimeToMS(this.nextTimeCount- GetTimeStamp() ))
2021-10-14 11:25:44 +08:00
this.modelList = {}
2021-10-11 14:37:33 +08:00
this.modelList = msg.modelInfo--玩家模板信息
2021-10-11 17:25:48 +08:00
this.activityTimeCount = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.YuJianXing).endTime
2021-10-14 11:25:44 +08:00
this.curResultId = {}
2021-10-13 15:39:47 +08:00
this.curResultId = msg.rankId
2021-10-14 18:02:30 +08:00
Log("界面剧本Id:"..tostring(msg.rankId))
2021-10-13 15:39:47 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.YuJianXing.UpdateRank)
2021-10-11 14:37:33 +08:00
if func then
func()
end
end
--更新服务器奖励投注上一轮信息
function this.UpdataServerData(msg,func)
2021-10-13 15:39:47 +08:00
this.lastResult = msg.lastRank
if msg.lastRank.rankId == 0 then
LogError("御剑行剧本id为0")
return
end
this.curRecordList = {}
2021-10-13 15:39:47 +08:00
this.curRecordList = msg.recordLsit
this.curBetList = {}
2021-10-13 15:39:47 +08:00
this.curBetList = msg.betList
2021-10-14 09:53:51 +08:00
table.sort( this.curRecordList, function (a,b)
if a.state == b.state then
return a.time > b.time
else
return a.state < b.state
end
end )
2021-10-13 19:15:39 +08:00
this.joinCount = msg.betCount--参与投注的轮数
2021-10-11 14:37:33 +08:00
if func then
func()
end
2021-09-29 18:34:54 +08:00
end
--重新加载玩家数据
2021-10-12 15:53:57 +08:00
function this.ReloadPlayersData(_id)
local data = _id > 0 and _id or 1
local playerData = ConfigManager.GetConfigDataByKey(ConfigName.RidingSwardResult,"Id",data)
2021-10-12 15:53:57 +08:00
this.riceCtrl:ReloadPlayersData(playerData)
end
--隐藏玩家
function this.HideAllPlayers(_state)
this.riceCtrl:HideAllPlayers(_state)
end
2021-10-08 15:45:28 +08:00
--修改游戏状态
2021-09-29 18:34:54 +08:00
function this.SetGameState(_state)
this.riceCtrl:SetGameState(_state)
end
2021-10-08 20:49:25 +08:00
--游戏结束 重置
function this.FinishResetGame()
Timer.New(function ()
2021-10-12 11:26:48 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.YuJianXing.GameFinished)
this.InWaiting = true
2021-10-08 20:49:25 +08:00
this.ResetGame()
end,0.3):Start()
end
2021-10-08 15:45:28 +08:00
--重置游戏
function this.ResetGame()
2021-10-13 15:39:47 +08:00
YuJianXingManager.sendEvent = true
2021-10-08 15:45:28 +08:00
this.riceCtrl:ResetGame()
2021-10-15 14:14:04 +08:00
if UIManager.IsOpen(UIName.GeneralBigPopup) then
UIManager.ClosePanel(UIName.GeneralBigPopup)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YuJianLastResult)
end
2021-09-29 18:34:54 +08:00
end
2021-10-09 16:24:34 +08:00
function this.ResetPlayerPosVertical()
this.riceCtrl:ResetPlayerPosVertical()
end
2021-10-08 15:45:28 +08:00
2021-10-14 17:10:40 +08:00
function this.CheckRedPoint()
local state1 = false
local state2 = false
if configData.JoinCount - this.joinCount > 0 then
state1 = true
end
for i = 1, #this.curRecordList do
if this.curRecordList[i].state == 0 then
state2 = true
end
end
return state1 or state2
2021-10-14 15:30:46 +08:00
end
2021-10-14 17:10:40 +08:00
function this.CheckRecordList()
for i = 1, #this.curRecordList do
if this.curRecordList[i].state == 0 then
return true
end
end
return false
end
2021-10-14 18:28:27 +08:00
function this.MakeRequest()
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.YuJianXing)
if id then
NetManager.RidingSwardActivityRequest(id)
NetManager.RidingSwardInfoRequest()
end
end
2021-09-29 18:34:54 +08:00
return YuJianXingManager