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