优化联网游戏体验(统计数据结算、远程玩家死亡结算时机)
This commit is contained in:
@@ -684,6 +684,7 @@ end
|
||||
function NET.wsCallBack.player_finish(body)
|
||||
for _,P in next,PLY_ALIVE do
|
||||
if P.uid==body.data.playerId then
|
||||
P.loseTimer=26
|
||||
P:lose(true)
|
||||
break
|
||||
end
|
||||
@@ -712,6 +713,9 @@ function NET.wsCallBack.player_setReadyMode(body)
|
||||
NET.freshRoomAllReady()
|
||||
end
|
||||
function NET.wsCallBack.match_finish()
|
||||
for _,P in next,PLAYERS do
|
||||
NETPLY.setStat(P.uid,P.stat)
|
||||
end
|
||||
TASK.new(function()
|
||||
TEST.yieldT(2.6)
|
||||
TASK.unlock('netPlaying')
|
||||
|
||||
@@ -411,6 +411,7 @@ function PLY.newRemotePlayer(id,mini,p)
|
||||
P.sid=NET.uid_sid[p.uid] or p.uid
|
||||
P.group=p.group
|
||||
P.netAtk=0-- Sum of lines sent in stream, will be compared with P.stat.send for checking stream legal or not
|
||||
P.loseTimer=false-- Will be set to 26 when receive player_finish signal
|
||||
if not (P.group%1==0 and P.group>=1 and P.group<=6) then P.group=0 end
|
||||
|
||||
_loadRemoteEnv(P,p.config)
|
||||
|
||||
@@ -2608,7 +2608,7 @@ local function update_streaming(P)
|
||||
P.netAtk=P.netAtk+amount
|
||||
if P.netAtk~=P.stat.send then-- He cheated or just desynchronized to death
|
||||
MES.new('warn',"#"..P.uid.." desynchronized")
|
||||
NET.player_finish({foo=""})
|
||||
NET.player_finish({reason='desync'})
|
||||
P:lose(true)
|
||||
return
|
||||
end
|
||||
@@ -2691,8 +2691,15 @@ function Player:update(dt)
|
||||
end
|
||||
while self.trigFrame>=1 do
|
||||
if self.streamProgress then
|
||||
local frameDelta
|
||||
local frameDelta-- Time between now and end of stream
|
||||
if self.type=='remote' then
|
||||
if self.loseTimer then
|
||||
self.loseTimer=self.loseTimer-1
|
||||
if self.loseTimer==0 then
|
||||
self.loseTimer=false
|
||||
self:lose(true)
|
||||
end
|
||||
end
|
||||
frameDelta=(self.stream[#self.stream-1] or 0)-self.frameRun
|
||||
if frameDelta==0 then frameDelta=nil end
|
||||
else
|
||||
@@ -2700,6 +2707,7 @@ function Player:update(dt)
|
||||
end
|
||||
if frameDelta then
|
||||
for _=1,
|
||||
self.loseTimer and 6 or
|
||||
frameDelta<26 and 1 or
|
||||
frameDelta<50 and 2 or
|
||||
frameDelta<80 and 3 or
|
||||
@@ -2797,8 +2805,10 @@ function Player:lose(force)
|
||||
self:revive()
|
||||
return
|
||||
elseif self.type=='remote' then
|
||||
self.waiting=1e99
|
||||
return
|
||||
if not self.loseTimer then
|
||||
self.waiting=1e99
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
self:_die()
|
||||
@@ -2852,7 +2862,7 @@ function Player:lose(force)
|
||||
gameOver()
|
||||
self:newTask(#PLAYERS>1 and task_lose or task_finish)
|
||||
if GAME.net and not NET.spectate then
|
||||
NET.player_finish({foo=""})
|
||||
NET.player_finish({reason="lose"})
|
||||
else
|
||||
TASK.new(task_autoPause)
|
||||
end
|
||||
|
||||
@@ -214,6 +214,7 @@ function scene.update(dt)
|
||||
for i=1,#NETPLY.list do
|
||||
NETPLY.list[i].readyMode='Standby'
|
||||
end
|
||||
NETPLY.freshPos()
|
||||
NET.freshRoomAllReady()
|
||||
return
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user