403 lines
15 KiB
Lua
403 lines
15 KiB
Lua
JumpServerManager = {}
|
||
local this = JumpServerManager
|
||
--天梯
|
||
local mServerArenaSetting = ConfigManager.GetConfig(ConfigName.MServerArenaSetting)
|
||
local mServerArenaReward = ConfigManager.GetConfig(ConfigName.MServerArenaReward)
|
||
local MServerLodeSetting = ConfigManager.GetConfig(ConfigName.MServerLodeSetting)
|
||
local stage = 0 --1 未开始 2 战斗阶段 3 膜拜阶段
|
||
local endTime = 0 --阶段结束时间戳
|
||
local arenaInfo --
|
||
local myRank = -1
|
||
local oldMyRank = -1
|
||
local enterable = -1 -- -1不可参加 是否可以参加 竞技场100名以内参加
|
||
--是否被分组 是1 否0
|
||
local isStart = 0
|
||
this.shopGoodId = 10035 --挑战价格
|
||
|
||
function this.Initialize()
|
||
this.isGroup = -1
|
||
this.arenaType = 1
|
||
this.stage = 0
|
||
this.showRankType = 0 --当前显示罗浮玩家列表的编队类型
|
||
end
|
||
|
||
---------------------------------------------
|
||
--跨服天梯数据
|
||
---------------------------------------------
|
||
------登录初始化
|
||
function this.LoginGetWorldArenaInfoRequest(fun)
|
||
if CheckFunctionOpen(FUNCTION_OPEN_TYPE.JumpServer_HightLadder) then
|
||
LogError("初始化登录-----------------------------------------------")
|
||
NetManager.GetWorldArenaInfoRequest(JumpServerManager.arenaType, function(_msg)
|
||
this.InithightLadderData(_msg)
|
||
if fun then
|
||
fun()
|
||
end
|
||
end)
|
||
else
|
||
if fun then
|
||
fun()
|
||
end
|
||
end
|
||
end
|
||
|
||
---初始化
|
||
function this.GetWorldArenaInfoRequest(type, fun)
|
||
NetManager.GetWorldArenaInfoRequest(type, function(_msg)
|
||
if _msg then
|
||
this.InithightLadderData(_msg)
|
||
end
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.JumpServerHeightLadder.UpdateHeightLadderPanel)
|
||
if fun then
|
||
fun()
|
||
end
|
||
--检测跨服天梯
|
||
JumpServerManager.CheckJumpServerhightLadderMainCityRedPoint()
|
||
end)
|
||
end
|
||
|
||
function this.InithightLadderData(_msg)
|
||
if _msg == nil then
|
||
return
|
||
end
|
||
-- LogPink("_msg.arenaInfo.arenaEnemys "..#_msg.arenaInfo.arenaEnemys)
|
||
for i = 1, #_msg.arenaInfo.arenaEnemys do
|
||
-- LogPink("_msg.arenaInfo.arenaEnemys[i].hadProud "..tostring(_msg.arenaInfo.arenaEnemys[i].hadProud) )
|
||
-- LogPink("_msg.arenaInfo.arenaEnemys[i].worshipTime ".._msg.arenaInfo.arenaEnemys[i].worshipTime)
|
||
-- LogYellow("_msg.arenaInfo.arenaEnemys[i].personInfo.practiceLevel ".._msg.arenaInfo.arenaEnemys[i].personInfo.practiceLevel)
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name = PracticeManager.SetNameColor(
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name, _msg.arenaInfo.arenaEnemys[i].personInfo.practiceLevel)
|
||
end
|
||
-- LogPink("_msg.stage ".._msg.stage)
|
||
-- LogPink("_msg.endTime ".._msg.endTime)
|
||
-- LogPink("_msg.arenaInfo.score ".._msg.arenaInfo.score)
|
||
-- LogPink("_msg.enterable ".._msg.enterable)
|
||
-- LogPink("_msg.isGroup ".._msg.isGroup)
|
||
-- LogPink("_msg.isStart ".._msg.isStart)
|
||
arenaInfo = _msg.arenaInfo
|
||
--stage = _msg.stage
|
||
endTime = _msg.endTime
|
||
myRank = _msg.arenaInfo.score
|
||
LogError("myrank==" .. myRank)
|
||
--enterable = _msg.enterable--是否可以参加 竞技场100名以内参加
|
||
--isGroup = _msg.isGroup--是否被分组 是1 否0
|
||
--isStart = _msg.isStart--是否在3周内,在为0 不在为1 开服三周后功能开始
|
||
LogError(string.format("获取到了当前为开服第%s周", tostring(isStart)))
|
||
--this.arenaType= _msg.type
|
||
end
|
||
|
||
--推送更新
|
||
function this.IndicationHightLadderData(_msg)
|
||
for i = 1, #_msg.arenaInfo.arenaEnemys do
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name = PracticeManager.SetNameColor(
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name, _msg.arenaInfo.arenaEnemys[i].personInfo.practiceLevel)
|
||
end
|
||
arenaInfo = _msg.arenaInfo
|
||
--stage = _msg.stage
|
||
endTime = _msg.endTime
|
||
myRank = _msg.arenaInfo.score
|
||
--this.arenaType=_msg.arenaInfo.type
|
||
LogError("myrank==" .. myRank)
|
||
-- LogPink("_msg.arenaInfo.arenaEnemys "..#_msg.arenaInfo.arenaEnemys)
|
||
-- LogPink("_msg.stage ".._msg.stage)
|
||
-- LogPink("_msg.endTime ".._msg.endTime)
|
||
-- LogPink("_msg.arenaInfo.score ".._msg.arenaInfo.score)
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.JumpServerHeightLadder.UpdateHeightLadderPanel)
|
||
end
|
||
|
||
--战斗更新
|
||
function this.BattleHightLadderData(_msg)
|
||
if _msg.arenaInfo and _msg.arenaInfo.arenaEnemys and #_msg.arenaInfo.arenaEnemys > 0 then
|
||
for i = 1, #_msg.arenaInfo.arenaEnemys do
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name = PracticeManager.SetNameColor(
|
||
_msg.arenaInfo.arenaEnemys[i].personInfo.name, _msg.arenaInfo.arenaEnemys[i].personInfo.practiceLevel)
|
||
end
|
||
arenaInfo = _msg.arenaInfo
|
||
myRank = _msg.arenaInfo.score
|
||
LogError("myrank==" .. myRank)
|
||
end
|
||
-- LogPink("_msg.arenaInfo.arenaEnemys "..#_msg.arenaInfo.arenaEnemys)
|
||
-- LogPink("_msg.arenaInfo.score ".._msg.arenaInfo.score)
|
||
end
|
||
|
||
--获得天梯阶段
|
||
function this.GetHightLadderDataArenaInfo()
|
||
return arenaInfo
|
||
end
|
||
|
||
function this.GetHightLadderDatastage()
|
||
return this.stage
|
||
end
|
||
|
||
function this.GetHightLadderDataEndTime()
|
||
return endTime
|
||
end
|
||
|
||
function this.GetHightLadderDataMyRank()
|
||
return myRank
|
||
end
|
||
|
||
function this.GetHightLadderDataOldMyRank()
|
||
return oldMyRank
|
||
end
|
||
|
||
function this.GetHightLadderDataEnterable()
|
||
return this.arenaType ~= 0
|
||
end
|
||
|
||
function this.GetHightLadderDataIsGroup()
|
||
return this.isGroup > 0
|
||
end
|
||
|
||
function this.GetHightLadderDataIsStart()
|
||
return PlayerManager.startWeek >= mServerArenaSetting[1].OpenWeek
|
||
end
|
||
|
||
function this.GetQiJieIsStart()
|
||
return PlayerManager.startWeek >= mServerArenaSetting[3].OpenWeek
|
||
end
|
||
|
||
function this.GetYuxuIsStart()
|
||
return PlayerManager.startWeek >= mServerArenaSetting[2].OpenWeek
|
||
end
|
||
|
||
function this.GetLingMaiIsStart()
|
||
return PlayerManager.startWeek >= MServerLodeSetting[1].OpenWeek
|
||
end
|
||
|
||
-- 获取剩余挑战次数 特权
|
||
function this.GetCanBattleCount()
|
||
return PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.JUMPSERVER_GIGHTLADDER_MIANFEINUM)
|
||
end
|
||
|
||
-- 获取剩余挑战购买次数 特权
|
||
function this.GetCanBuyBattleCount()
|
||
return PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.JUMPSERVER_GIGHTLADDER_BUYNUM)
|
||
end
|
||
|
||
--天梯开始战斗
|
||
this.curBattleDrop = {}
|
||
function this.StarFightHightLadder(personInfo, skipFight, callBack)
|
||
local formaType = FormationTypeDef.LuoFuZhengFeng1
|
||
if JumpServerManager.arenaType == 1 then
|
||
formaType = FormationTypeDef.LuoFuZhengFeng1
|
||
elseif JumpServerManager.arenaType == 2 then
|
||
formaType = FormationTypeDef.LuoFuZhengFeng2
|
||
elseif JumpServerManager.arenaType == 3 then
|
||
formaType = FormationTypeDef.LuoFuZhengFeng3
|
||
elseif JumpServerManager.arenaType == 4 then
|
||
formaType = FormationTypeDef.LuoFuZhengFeng4
|
||
end
|
||
NetManager.GetWorldArenaChallengeRequest(formaType, personInfo, skipFight, function(msg)
|
||
oldMyRank = myRank
|
||
-- if msg and msg.drop and msg.drop.itemlist and #msg.drop.itemlist > 0 then
|
||
-- LogPink(" #msg.drop.itemlist ".. #msg.drop.itemlist)
|
||
-- else
|
||
-- LogPink(" #msg.drop.itemlist nil ")
|
||
-- end
|
||
this.curBattleDrop = msg.drop
|
||
-- LogGreen("skipFight "..skipFight.." msg.err "..msg.err)
|
||
if skipFight == 0 then --挑战
|
||
if msg.err == -2 then
|
||
-- this.BattleHightLadderData(msg)--后端没给数据 前端自己请求
|
||
JumpServerManager.GetWorldArenaInfoRequest(JumpServerManager.arenaType)
|
||
PopupTipPanel.ShowTip(Language[11667])
|
||
if callBack then
|
||
callBack()
|
||
end
|
||
return
|
||
end
|
||
if msg.err == -3 then
|
||
-- this.BattleHightLadderData(msg)--后端没给数据 前端自己请求
|
||
JumpServerManager.GetWorldArenaInfoRequest(JumpServerManager.arenaType)
|
||
PopupTipPanel.ShowTip(Language[11668])
|
||
if callBack then
|
||
callBack()
|
||
end
|
||
return
|
||
end
|
||
this.BattleHightLadderData(msg)
|
||
local fightData = BattleManager.GetBattleServerData(msg, 1)
|
||
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.JumpServerhightLadder, function()
|
||
-- UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1,function()
|
||
if callBack then
|
||
callBack(msg)
|
||
end
|
||
-- end)
|
||
end
|
||
):SetResult(msg.fightResult)
|
||
else
|
||
this.BattleHightLadderData(msg)
|
||
local fightData = BattleManager.GetBattleServerData(msg)
|
||
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function()
|
||
if callBack then
|
||
callBack(msg)
|
||
end
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
|
||
function this.GetWorldArenaProudRequest(personInfo, callBack)
|
||
NetManager.GetWorldArenaProudRequest(personInfo, function(msg)
|
||
-- LogGreen("msg.err "..msg.err)
|
||
-- LogGreen("msg.worshipTime "..msg.worshipTime)
|
||
-- if msg.err== -2 then
|
||
-- this.BattleHightLadderData(msg)
|
||
-- PopupTipPanel.ShowTip("无法挑战,目标玩家排名出现变化,已重新匹配对手!")
|
||
-- return
|
||
-- end
|
||
-- if msg.err== -3 then
|
||
-- this.BattleHightLadderData(msg)
|
||
-- PopupTipPanel.ShowTip("无法挑战,玩家排名出现变化,已重新匹配对手!")
|
||
-- return
|
||
-- end
|
||
local itemId = 0
|
||
local itemNum = 0
|
||
if msg.drop.itemlist ~= nil and #msg.drop.itemlist > 0 then
|
||
for i = 1, #msg.drop.itemlist do
|
||
if msg.drop.itemlist[i].itemNum > 0 then
|
||
itemId = msg.drop.itemlist[i].itemId --
|
||
itemNum = msg.drop.itemlist[i].itemNum
|
||
end
|
||
end
|
||
end
|
||
PopupTipPanel.ShowTip(string.format(Language[11669],
|
||
GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig, itemId).Name), itemNum))
|
||
LogError("msg.worshipTime " .. msg.worshipTime)
|
||
for i = 1, #arenaInfo.arenaEnemys do
|
||
if arenaInfo.arenaEnemys[i] then
|
||
local curData = arenaInfo.arenaEnemys[i]
|
||
LogYellow("personInfo.uid " ..
|
||
personInfo.uid .. " curData.personInfo.uid " .. curData.personInfo.uid)
|
||
if personInfo.uid == curData.personInfo.uid then
|
||
LogYellow("curData.worshipTime " .. curData.worshipTime)
|
||
if curData.personInfo and curData.worshipTime then
|
||
LogPink("msg.worshipTime " .. msg.worshipTime)
|
||
curData.worshipTime = msg.worshipTime
|
||
curData.hadProud = true
|
||
end
|
||
end
|
||
end
|
||
end
|
||
if callBack then
|
||
callBack(msg)
|
||
end
|
||
end)
|
||
end
|
||
|
||
function this.GetWorldArenaRecordInfoRequest(callBack)
|
||
NetManager.GetWorldArenaRecordInfoRequest(function(msg)
|
||
if callBack then
|
||
callBack(msg)
|
||
end
|
||
end)
|
||
end
|
||
|
||
function this.CheckJumpServerhightLadderMainCityRedPoint()
|
||
CheckRedPointStatus(RedPointType.JumpServer_HightLadder_Worship)
|
||
CheckRedPointStatus(RedPointType.JumpServer_HightLadder_HaveMianFeiPanel)
|
||
-- 检测七界试炼红点
|
||
CheckRedPointStatus(RedPointType.QiJieShiLian)
|
||
end
|
||
|
||
--剩余免费挑战次数红点
|
||
function this.JumpServerHightLadderMianFeiNumRedPoint()
|
||
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_HightLadder)
|
||
if not isOpen then
|
||
return false
|
||
end
|
||
local conFigWorldLevel = ConfigManager.GetConfigData(ConfigName.MServerArenaSetting, 1).WorldLevel
|
||
if PlayerManager.worldLeve < conFigWorldLevel then
|
||
return false
|
||
end
|
||
if not this.GetHightLadderDataEnterable() then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
if not this.GetHightLadderDataIsGroup() then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
if not this.GetHightLadderDataIsStart() then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
if stage == 3 then
|
||
if this.GetCanBattleCount() > 0 then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点true")
|
||
return true
|
||
end
|
||
end
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
|
||
--跨服天梯可以膜拜红点
|
||
function this.JumpServerHightLadderWorshipRedPoint()
|
||
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_HightLadder)
|
||
if not isOpen then
|
||
return false
|
||
end
|
||
local isOpen = CheckFunctionOpen(FUNCTION_OPEN_TYPE.JumpServer_HightLadder)
|
||
if isOpen == false then
|
||
return false
|
||
end
|
||
-- local conFigWorldLevel = ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,1).WorldLevel
|
||
-- if PlayerManager.worldLeve < conFigWorldLevel then
|
||
-- return false
|
||
-- end
|
||
if this.stage == 1 and this.arenaType == 0 then
|
||
return true
|
||
end
|
||
if not this.GetHightLadderDataIsGroup() then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
if not this.GetHightLadderDataIsStart() then
|
||
-- LogPink("跨服天梯剩余免费挑战次数红点false")
|
||
return false
|
||
end
|
||
if stage == 1 then
|
||
local datas = this.GetHightLadderDataArenaInfo()
|
||
for i = 1, #datas.arenaEnemys do
|
||
if datas.arenaEnemys[i] and not datas.arenaEnemys[i].hadProud then
|
||
-- LogPink("跨服天梯可以膜拜红点true")
|
||
return true
|
||
end
|
||
end
|
||
end
|
||
-- LogPink("跨服天梯可以膜拜红点false")
|
||
return false
|
||
end
|
||
|
||
function this.ZeroRefreshPanel()
|
||
-- LogPink("跨天 跨服天梯膜拜状态刷新")
|
||
Timer.New(function()
|
||
this.GetWorldArenaInfoRequest(function()
|
||
--一分钟间隔阶段 踢回主城
|
||
-- if UIManager.IsOpen(UIName.JumpServerHightLadderPanel) or UIManager.IsOpen(UIName.JumpServerPanel) then
|
||
-- if false then
|
||
-- UIManager.OpenPanel(UIName.MainPanel);
|
||
-- end
|
||
-- end
|
||
end)
|
||
end, 3):Start()
|
||
end
|
||
|
||
local curPersonInfo = {}
|
||
function this.SetCurPersonInfo(_curPersonInfo)
|
||
curPersonInfo = _curPersonInfo
|
||
end
|
||
|
||
function this.GetCurPersonInfo(_curPersonInfo)
|
||
return curPersonInfo
|
||
end
|
||
|
||
---------------------------------------------
|
||
--跨服天梯结束
|
||
---------------------------------------------
|
||
----
|
||
---------------------------------------------跨服界面逻辑----------------------------
|
||
return this
|