168 lines
5.2 KiB
Lua
168 lines
5.2 KiB
Lua
YuJianXingManager = {}
|
||
local this = YuJianXingManager
|
||
local riceCtrl = require("Modules/YuJianXing/RiceCtrlView")
|
||
local bgList = {"y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg","y_yujianxing_bg"}
|
||
local configData = ConfigManager.GetConfigData(ConfigName.RidingSwardConfig,1)
|
||
|
||
function this.Initialize()
|
||
this.joinCount = 0--参与投注的轮数
|
||
this.curState = 0 --当前比赛状态
|
||
this.nextTimeCount = 0 --下轮开始时间
|
||
this.activityTimeCount = 0 --活动倒计时
|
||
this.curResultId = {} --当前剧本的Id
|
||
this.lastResult = {} --上一场剧本的时间和ID
|
||
this.curRecordList = {} --当前纪录数据
|
||
this.curBetList = {} --当前竞猜数据
|
||
this.modelList = {}--玩家名等数据
|
||
this.InWaiting = false
|
||
this.sendEvent = true
|
||
this.CloseMap()
|
||
end
|
||
|
||
--初始化地图
|
||
function this.OpenMap()
|
||
local playerData = ConfigManager.GetConfigDataByKey(ConfigName.RidingSwardResult,"Id",1)--1是初始化用
|
||
if not this.riceCtrl then
|
||
this.riceCtrl = riceCtrl:New()
|
||
this.riceCtrl:Awake(bgList,playerData)
|
||
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
|
||
end
|
||
|
||
--重新请求数据
|
||
function this.ReGetInfo(func)
|
||
local id = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.YuJianXing)
|
||
NetManager.RidingSwardActivityRequest(id.activityId,func)
|
||
end
|
||
|
||
--更新服务器界面信息
|
||
function this.UpdataServerPanelData(msg,func)
|
||
this.joinCount = msg.betCount--参与投注的轮数
|
||
this.curState = msg.state--当前状态
|
||
if msg.state ~= 2 then
|
||
this.InWaiting = false
|
||
end
|
||
this.nextTimeCount = msg.time--下一场倒计时
|
||
Log("界面剧本Id:"..tostring(msg.rankId).." 当前state:"..tostring(msg.state).." 下一阶段倒计时:"..TimeToMS(this.nextTimeCount- GetTimeStamp() ).." 模板玩家数:"..tostring(#msg.modelInfo))
|
||
this.modelList = {}
|
||
this.modelList = msg.modelInfo--玩家模板信息
|
||
if #this.modelList < 4 or not this.modelList[1] then
|
||
this.modelList = {[1] = {userName = "端木大喵",sex = 0},[2] = {userName = "上官赋",sex = 0},[3] = {userName = "钟离昧",sex = 0},[4] = {userName = "欧阳凌雪",sex = 0}}
|
||
end
|
||
this.activityTimeCount = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.YuJianXing).endTime
|
||
this.curResultId = {}
|
||
this.curResultId = msg.rankId
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.YuJianXing.UpdateRank)
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
--更新服务器奖励投注上一轮信息
|
||
function this.UpdataServerData(msg,func)
|
||
this.lastResult = msg.lastRank
|
||
if msg.lastRank.rankId == 0 then
|
||
LogError("御剑行剧本id为0:")
|
||
end
|
||
this.curRecordList = {}
|
||
this.curRecordList = msg.recordLsit
|
||
this.curBetList = {}
|
||
this.curBetList = msg.betList
|
||
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 )
|
||
this.joinCount = msg.betCount--参与投注的轮数
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
--重新加载玩家数据
|
||
function this.ReloadPlayersData(_id)
|
||
local data = _id > 0 and _id or 1
|
||
local playerData = ConfigManager.GetConfigDataByKey(ConfigName.RidingSwardResult,"Id",data)
|
||
this.riceCtrl:ReloadPlayersData(playerData)
|
||
end
|
||
|
||
--隐藏玩家
|
||
function this.HideAllPlayers(_state)
|
||
this.riceCtrl:HideAllPlayers(_state)
|
||
end
|
||
|
||
--修改游戏状态
|
||
function this.SetGameState(_state)
|
||
this.riceCtrl:SetGameState(_state)
|
||
end
|
||
|
||
--游戏结束 重置
|
||
function this.FinishResetGame()
|
||
Timer.New(function ()
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.YuJianXing.GameFinished)
|
||
this.InWaiting = true
|
||
this.ResetGame()
|
||
end,0.3):Start()
|
||
end
|
||
|
||
--重置游戏
|
||
function this.ResetGame()
|
||
YuJianXingManager.sendEvent = true
|
||
this.riceCtrl:ResetGame()
|
||
if UIManager.IsOpen(UIName.GeneralBigPopup) then
|
||
UIManager.ClosePanel(UIName.GeneralBigPopup)
|
||
end
|
||
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.YuJianLastResult)
|
||
end
|
||
|
||
function this.ResetPlayerPosVertical()
|
||
this.riceCtrl:ResetPlayerPosVertical()
|
||
end
|
||
|
||
function this.CheckRedPoint()
|
||
local state1 = false
|
||
local state2 = false
|
||
if (configData.JoinCount - this.joinCount > 0) and (#this.curBetList < 2) and (YuJianXingManager.curState == 1) 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
|
||
end
|
||
|
||
function this.CheckRecordList()
|
||
for i = 1, #this.curRecordList do
|
||
if this.curRecordList[i].state == 0 then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
function this.MakeRequest()
|
||
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.YuJianXing)
|
||
if id then
|
||
NetManager.RidingSwardActivityRequest(id)
|
||
NetManager.RidingSwardInfoRequest(function ()
|
||
CheckRedPointStatus(RedPointType.YuJianXingMian)
|
||
end)
|
||
end
|
||
end
|
||
|
||
return YuJianXingManager |