217 lines
7.9 KiB
Lua
217 lines
7.9 KiB
Lua
JumpServerManager = {}
|
||
local this = JumpServerManager
|
||
--天梯
|
||
local mServerArenaSetting = ConfigManager.GetConfig(ConfigName.MServerArenaSetting)
|
||
local mServerArenaReward = ConfigManager.GetConfig(ConfigName.MServerArenaReward)
|
||
local stage = 0 --1 未开始 2 战斗阶段 3 膜拜阶段
|
||
local endTime = 0 --阶段结束时间戳
|
||
local arenaInfo--
|
||
local myRank = -1
|
||
local oldMyRank = -1
|
||
local enterable = -1-- -1不可参加 是否可以参加 竞技场100名以内参加
|
||
this.shopGoodId = 10035--挑战价格
|
||
|
||
function this.Initialize()
|
||
|
||
end
|
||
---------------------------------------------
|
||
--跨服天梯数据
|
||
---------------------------------------------
|
||
---初始化
|
||
function this.GetWorldArenaInfoRequest(fun)
|
||
NetManager.GetWorldArenaInfoRequest(function(_msg)
|
||
this.InithightLadderData(_msg)
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.JumpServerHeightLadder.UpdateHeightLadderPanel)
|
||
if fun then
|
||
fun()
|
||
end
|
||
end)
|
||
end
|
||
function this.InithightLadderData(_msg)
|
||
LogPink("_msg.arenaInfo.arenaEnemys "..#_msg.arenaInfo.arenaEnemys)
|
||
LogPink("_msg.stage ".._msg.stage)
|
||
LogPink("_msg.endTime ".._msg.endTime)
|
||
LogPink("_msg.arenaInfo.score ".._msg.arenaInfo.score)
|
||
LogPink("_msg.enterable ".._msg.enterable)
|
||
arenaInfo = _msg.arenaInfo
|
||
stage = _msg.stage
|
||
endTime = _msg.endTime
|
||
myRank = _msg.arenaInfo.score
|
||
enterable = _msg.enterable--是否可以参加 竞技场100名以内参加
|
||
end
|
||
--推送更新
|
||
function this.IndicationHightLadderData(_msg)
|
||
arenaInfo = _msg.arenaInfo
|
||
stage = _msg.stage
|
||
endTime = _msg.endTime
|
||
myRank = _msg.arenaInfo.score
|
||
LogPink("_msg.arenaInfo.arenaEnemys "..#_msg.arenaInfo.arenaEnemys)
|
||
LogPink("_msg.stage ".._msg.stage)
|
||
LogPink("_msg.endTime ".._msg.endTime)
|
||
LogPink("_msg.arenaInfo.score ".._msg.arenaInfo.score)
|
||
end
|
||
--战斗更新
|
||
function this.BattleHightLadderData(_msg)
|
||
if _msg.arenaInfo and _msg.arenaInfo.arenaEnemys and #_msg.arenaInfo.arenaEnemys > 0 then
|
||
arenaInfo = _msg.arenaInfo
|
||
myRank =_msg.arenaInfo.score
|
||
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 stage
|
||
end
|
||
function this.GetHightLadderDataEndTime()
|
||
return endTime
|
||
end
|
||
function this.GetHightLadderDataMyRank()
|
||
return myRank
|
||
end
|
||
function this.GetHightLadderDataOldMyRank()
|
||
return oldMyRank
|
||
end
|
||
function this.GetHightLadderDataEnterable()
|
||
return enterable ~= -1
|
||
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
|
||
--天梯开始战斗
|
||
function this.StarFightHightLadder(personInfo,skipFight,callBack)
|
||
NetManager.GetWorldArenaChallengeRequest(FormationTypeDef.FORMATION_NORMAL,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
|
||
if skipFight == 0 then--挑战
|
||
if msg.err== -1 then
|
||
this.BattleHightLadderData(msg)
|
||
PopupTipPanel.ShowTip("无法挑战,目标玩家排名出现变化,已重新匹配对手!")
|
||
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
|
||
)
|
||
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)
|
||
if msg.err== -1 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("膜拜成功,获得%sX%s!"),ConfigManager.GetConfigData(ConfigName.ItemConfig,itemId).Name, itemNum)
|
||
LogPink("msg.worshipTime "..msg.worshipTime)
|
||
for i = 1, #arenaInfo.arenaEnemys do
|
||
if arenaInfo.arenaEnemys[i] then
|
||
local curData = arenaInfo.arenaEnemys[i]
|
||
if personInfo.uid == curData.personInfo.uid then
|
||
if curData.personInfo and curData.personInfo.worshipTime then
|
||
LogPink("msg.worshipTime "..msg.worshipTime)
|
||
curData.personInfo.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)
|
||
end
|
||
--剩余免费挑战次数红点
|
||
function this.JumpServerHightLadderMianFeiNumRedPoint()
|
||
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_HightLadder)
|
||
if not isOpen then
|
||
return false
|
||
end
|
||
if not this.GetHightLadderDataEnterable() then
|
||
return false
|
||
end
|
||
if stage == 2 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
|
||
-- if not this.GetHightLadderDataEnterable() then
|
||
-- return false
|
||
-- end
|
||
if stage == 3 then
|
||
|
||
local datas = this.GetHightLadderDataArenaInfo()
|
||
for i = 1, #datas.arenaEnemys do
|
||
if datas.arenaEnemys[i] and datas.arenaEnemys[i].worshipTime and datas.arenaEnemys[i].worshipTime <= 0 then
|
||
LogPink("跨服天梯可以膜拜红点true")
|
||
return true
|
||
end
|
||
end
|
||
|
||
end
|
||
LogPink("跨服天梯可以膜拜红点false")
|
||
return false
|
||
end
|
||
---------------------------------------------
|
||
--跨服天梯结束
|
||
---------------------------------------------
|
||
return this |