服务器认定全员准备三秒后取消准备按钮消失,整理代码
This commit is contained in:
@@ -4,6 +4,7 @@ local WS,TIME=WS,TIME
|
|||||||
local NET={
|
local NET={
|
||||||
connected=false,
|
connected=false,
|
||||||
allow_online=false,
|
allow_online=false,
|
||||||
|
serverGaming=false,
|
||||||
roomList={},
|
roomList={},
|
||||||
accessToken=false,
|
accessToken=false,
|
||||||
rid=false,
|
rid=false,
|
||||||
@@ -101,11 +102,13 @@ function NET.wsconn_play()
|
|||||||
end
|
end
|
||||||
function NET.wsconn_stream()
|
function NET.wsconn_stream()
|
||||||
if NET.lock("wsc_stream",5)then
|
if NET.lock("wsc_stream",5)then
|
||||||
|
NET.serverGaming=true
|
||||||
WS.connect("stream","/stream",JSON.encode{
|
WS.connect("stream","/stream",JSON.encode{
|
||||||
uid=USER.uid,
|
uid=USER.uid,
|
||||||
accessToken=NET.accessToken,
|
accessToken=NET.accessToken,
|
||||||
rid=NET.rsid,
|
rid=NET.rsid,
|
||||||
})
|
})
|
||||||
|
TASK.new(NET.updateWS_stream)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,7 +116,10 @@ end
|
|||||||
function NET.wsclose_app()WS.close("app")end
|
function NET.wsclose_app()WS.close("app")end
|
||||||
function NET.wsclose_user()WS.close("user")end
|
function NET.wsclose_user()WS.close("user")end
|
||||||
function NET.wsclose_play()WS.close("play")end
|
function NET.wsclose_play()WS.close("play")end
|
||||||
function NET.wsclose_stream()WS.close("stream")end
|
function NET.wsclose_stream()
|
||||||
|
NET.serverGaming=false
|
||||||
|
WS.close("stream")
|
||||||
|
end
|
||||||
|
|
||||||
--Account & User
|
--Account & User
|
||||||
function NET.register(username,email,password)
|
function NET.register(username,email,password)
|
||||||
@@ -192,7 +198,7 @@ function NET.checkPlayDisconn()
|
|||||||
return WS.status("play")~="running"
|
return WS.status("play")~="running"
|
||||||
end
|
end
|
||||||
function NET.signal_ready(ready)
|
function NET.signal_ready(ready)
|
||||||
if NET.lock("ready",3)then
|
if NET.lock("ready",3)and not NET.serverGaming then
|
||||||
WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}')
|
WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -421,12 +427,11 @@ function NET.updateWS_play()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif res.action==7 then--Ready
|
elseif res.action==7 then--All Ready
|
||||||
SFX.play("reach",.6)
|
SFX.play("reach",.6)
|
||||||
elseif res.action==8 then--Set
|
elseif res.action==8 then--Set
|
||||||
NET.rsid=d.rid
|
NET.rsid=d.rid
|
||||||
NET.wsconn_stream()
|
NET.wsconn_stream()
|
||||||
TASK.new(NET.updateWS_stream)
|
|
||||||
elseif res.action==9 then--Game finished
|
elseif res.action==9 then--Game finished
|
||||||
NET.wsclose_stream()
|
NET.wsclose_stream()
|
||||||
if SCN.socketRead then SCN.socketRead("Finish",d)end
|
if SCN.socketRead then SCN.socketRead("Finish",d)end
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
local gc=love.graphics
|
local gc,tc=love.graphics,love.touch
|
||||||
local tc=love.touch
|
|
||||||
|
|
||||||
local ins=table.insert
|
local ins=table.insert
|
||||||
|
local SCR,VK,NET=SCR,VK,NET
|
||||||
local SCR=SCR
|
|
||||||
local VK=VK
|
|
||||||
|
|
||||||
local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=false}
|
local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=false}
|
||||||
|
|
||||||
@@ -275,6 +271,7 @@ scene.widgetList={
|
|||||||
hide=function()
|
hide=function()
|
||||||
return
|
return
|
||||||
playing or
|
playing or
|
||||||
|
NET.serverGaming or
|
||||||
not textBox.hide or
|
not textBox.hide or
|
||||||
PLY_NET[1].ready or
|
PLY_NET[1].ready or
|
||||||
NET.getlock("ready")
|
NET.getlock("ready")
|
||||||
@@ -283,6 +280,7 @@ scene.widgetList={
|
|||||||
hide=function()
|
hide=function()
|
||||||
return
|
return
|
||||||
playing or
|
playing or
|
||||||
|
NET.serverGaming or
|
||||||
not textBox.hide or
|
not textBox.hide or
|
||||||
not PLY_NET[1].ready or
|
not PLY_NET[1].ready or
|
||||||
NET.getlock("ready")
|
NET.getlock("ready")
|
||||||
|
|||||||
Reference in New Issue
Block a user