允许玩家取消准备
This commit is contained in:
@@ -199,9 +199,9 @@ end
|
|||||||
function NET.checkPlayDisconn()
|
function NET.checkPlayDisconn()
|
||||||
return WS.status("play")~="running"
|
return WS.status("play")~="running"
|
||||||
end
|
end
|
||||||
function NET.signal_ready()
|
function NET.signal_ready(ready)
|
||||||
if _lock("ready")then
|
if _lock("ready")then
|
||||||
WS.send("play",'{"action":6,"data":{"ready":true}}')
|
WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.signal_quit()
|
function NET.signal_quit()
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ function scene.keyDown(key)
|
|||||||
end
|
end
|
||||||
elseif key=="space"then
|
elseif key=="space"then
|
||||||
if not NET.getLock("ready")then
|
if not NET.getLock("ready")then
|
||||||
NET.signal_ready()
|
NET.signal_ready(not PLAYERS[1].ready)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -175,13 +175,17 @@ function scene.socketRead(cmd,data)
|
|||||||
end
|
end
|
||||||
elseif cmd=="Ready"then
|
elseif cmd=="Ready"then
|
||||||
if data.uid==USER.uid then
|
if data.uid==USER.uid then
|
||||||
PLAYERS[1].ready=true
|
if PLAYERS[1].ready~=data.ready then
|
||||||
SFX.play("reach",.6)
|
PLAYERS[1].ready=data.ready
|
||||||
|
SFX.play("reach",.6)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
for i=1,#PLAYERS do
|
for i=1,#PLAYERS do
|
||||||
if PLAYERS[i].userID==data.uid then
|
if PLAYERS[i].userID==data.uid then
|
||||||
PLAYERS[i].ready=true
|
if PLAYERS[i].ready~=data.ready then
|
||||||
SFX.play("reach",.6)
|
PLAYERS[i].ready=data.ready
|
||||||
|
SFX.play("reach",.6)
|
||||||
|
end
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -289,7 +293,12 @@ function scene.draw()
|
|||||||
end
|
end
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
textBox,
|
textBox,
|
||||||
WIDGET.newKey{name="ready",x=640,y=440,w=200,h=80,color="yellow",font=40,code=pressKey"space",hide=function()return playing or not hideChatBox or PLAYERS[1].ready end},
|
WIDGET.newKey{name="ready",x=640,y=440,w=200,h=80,color="yellow",font=40,code=pressKey"space",hide=function()
|
||||||
|
return
|
||||||
|
playing or
|
||||||
|
not hideChatBox or
|
||||||
|
NET.getLock("ready")
|
||||||
|
end},
|
||||||
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"\\"},
|
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"\\"},
|
||||||
WIDGET.newKey{name="quit",fText="X",x=900,y=35,w=60,font=40,code=pressKey"escape"},
|
WIDGET.newKey{name="quit",fText="X",x=900,y=35,w=60,font=40,code=pressKey"escape"},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user