联网推进(增加观战相关代码)
This commit is contained in:
@@ -21,6 +21,7 @@ local NET={
|
||||
private=false,
|
||||
start=false,
|
||||
},
|
||||
watch=false,
|
||||
allReady=false,
|
||||
waitingStream=false,
|
||||
streamRoomID=false,
|
||||
@@ -474,9 +475,10 @@ function NET.updateWS_play()
|
||||
NET.connectingStream=true
|
||||
NET.wsconn_stream()
|
||||
elseif res.action==9 then--Game finished
|
||||
NET.wsclose_stream()
|
||||
if SCN.socketRead then SCN.socketRead('finish',d)end
|
||||
NET.roomState.start=false
|
||||
NET.watch=false
|
||||
if SCN.socketRead then SCN.socketRead('finish',d)end
|
||||
NET.wsclose_stream()
|
||||
end
|
||||
else
|
||||
WS.alert('play')
|
||||
@@ -519,11 +521,14 @@ function NET.updateWS_stream()
|
||||
netPLY.setConnect(p.uid)
|
||||
end
|
||||
end
|
||||
end
|
||||
if d.watch then
|
||||
--TODO: Join in-game
|
||||
else
|
||||
netPLY.setConnect(d.uid)
|
||||
NET.watch=d.watch==true
|
||||
else
|
||||
if d.watch then
|
||||
netPLY.setWatch(d.uid)
|
||||
else
|
||||
netPLY.setConnect(d.uid)
|
||||
end
|
||||
end
|
||||
elseif res.action==3 then--Player leave
|
||||
--?
|
||||
|
||||
@@ -87,6 +87,7 @@ end
|
||||
|
||||
function netPLY.clear()for _=1,netPLY.getCount()do rem(PLY)end end
|
||||
function netPLY.add(p)
|
||||
p.watch=false
|
||||
p.connected=false
|
||||
ins(PLY,p.uid==USER.uid and 1 or #PLY+1,p)
|
||||
local a=rnd()*6.2832
|
||||
@@ -125,17 +126,12 @@ function netPLY.setReady(uid,ready)
|
||||
end
|
||||
end
|
||||
end
|
||||
function netPLY.setConnect(uid)
|
||||
for _,p in next,PLY do
|
||||
if p.uid==uid then
|
||||
p.connected=true
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
function netPLY.setConnect(uid)getPLY(uid).connected=true end
|
||||
function netPLY.setWatch(uid)getPLY(uid).watch=true end
|
||||
function netPLY.resetState()
|
||||
for i=1,#PLY do
|
||||
PLY[i].ready=false
|
||||
PLY[i].watch=false
|
||||
PLY[i].connected=false
|
||||
end
|
||||
end
|
||||
@@ -173,7 +169,7 @@ function netPLY.draw()
|
||||
local p=PLY[i]
|
||||
gc.translate(p.x,p.y)
|
||||
--Rectangle
|
||||
gc.setColor(COLOR[p.connected and"N"or p.ready and'G'or'Z'])
|
||||
gc.setColor(COLOR[p.watch and"L"or p.connected and"N"or p.ready and'G'or'Z'])
|
||||
gc.setLineWidth(2)
|
||||
gc.rectangle('line',0,0,p.w,p.h)
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ function scene.socketRead(cmd,d)
|
||||
upstreamProgress=1
|
||||
resetGameData('n',d.seed)
|
||||
netPLY.mouseMove(0,0)
|
||||
netPLY.resetState()
|
||||
else
|
||||
LOG.print("Redundant [Go]",'warn')
|
||||
end
|
||||
@@ -203,6 +202,7 @@ function scene.socketRead(cmd,d)
|
||||
if winnerUID then
|
||||
TEXT.show(text.champion:gsub("$1",USERS.getUsername(winnerUID)),640,260,80,'zoomout',.26)
|
||||
end
|
||||
netPLY.resetState()
|
||||
elseif cmd=='stream'then
|
||||
if d.uid~=USER.uid and playing then
|
||||
for _,P in next,PLAYERS do
|
||||
|
||||
@@ -29,6 +29,7 @@ local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set()
|
||||
NET.watch=false
|
||||
NET.allReady=false
|
||||
NET.connectingStream=false
|
||||
NET.waitingStream=false
|
||||
|
||||
Reference in New Issue
Block a user