主菜单点联网游戏按钮尝试连接时会有文字提示,房间内可以显示其他玩家的ws(stream)连接状态

This commit is contained in:
MrZ626
2021-05-14 19:45:07 +08:00
parent 622b1a5e25
commit 95bc979da7
9 changed files with 42 additions and 18 deletions

View File

@@ -109,7 +109,7 @@ return{
leaveRoom="has left the room.",
ready="READY",
connStream="CONNECTING",
waitStream="CONNECTED",
waitStream="WAITING",
champion="$1 won",
chatRemain="Online",
chatStart="------Beginning of log------",

View File

@@ -109,7 +109,7 @@ return{
leaveRoom="a quitté le salon.",
-- ready="READY",
-- connStream="CONNECTING",
-- waitStream="CONNECTED",
-- waitStream="WAITING",
champion="$1 a gagné",
chatRemain="En ligne : ",
chatStart="--------Début des logs--------",

View File

@@ -109,7 +109,7 @@ return{
leaveRoom="Saiu da sala.",
-- ready="READY",
-- connStream="CONNECTING",
-- waitStream="CONNECTED",
-- waitStream="WAITING",
-- champion="$1 won",
chatRemain="Online",
chatStart="------Começo do log------",

View File

@@ -109,7 +109,7 @@ return{
leaveRoom="salió de la sala.",
-- ready="READY",
-- connStream="CONNECTING",
-- waitStream="CONNECTED",
-- waitStream="WAITING",
champion="$1 ganó!",
chatRemain="Usuarios en línea: ",
chatStart="------Comienzo del historial------",

View File

@@ -109,7 +109,7 @@ return{
leaveRoom="离开房间",
ready="各就各位!",
connStream="正在连接",
waitStream="等待他人连接",
waitStream="等待他人连接",
champion="$1 获胜",
chatRemain="人数:",
chatStart="------消息的开头------",

View File

@@ -20,8 +20,9 @@ local NET={
},
allReady=false,
connectingStream=false,
streamRoomID=false,
waitingStream=false,
serverGaming=false,
streamRoomID=false,
UserCount="_",
PlayCount="_",
@@ -482,14 +483,18 @@ function NET.updateWS_stream()
local d=res.data
if res.type=='Connect'then
NET.unlock('wsc_stream')
elseif res.action==0 then--Game start
NET.connectingStream=false
NET.waitingStream=true
netPLY.setConnect(USER.uid)
netPLY.freshStreamConn(res.data.connected)
elseif res.action==0 then--Game start
NET.waitingStream=false
if SCN.socketRead then SCN.socketRead('go',d)end
NET.roomInfo.start=true
elseif res.action==1 then--Game finished
--?
elseif res.action==2 then--Player join
--?
netPLY.setConnect(d.uid)
elseif res.action==3 then--Player leave
--?
elseif res.action==4 then--Player died

View File

@@ -87,6 +87,7 @@ end
function netPLY.clear()for _=1,netPLY.getCount()do rem(PLY)end end
function netPLY.add(p)
p.connected=false
ins(PLY,p.uid==USER.uid and 1 or #PLY+1,p)
local a=rnd()*6.2832
p.x,p.y,p.w,p.h=640+2600*cos(a),360+2600*sin(a),47,47
@@ -101,7 +102,6 @@ function netPLY.rawgetPLY(i)return PLY[i]end
function netPLY.getUsername(uid)return getPLY(uid).username end
function netPLY.getSID(uid)return getPLY(uid).sid end
function netPLY.getSelfReady()return PLY[1].ready end
function netPLY.setPlayerObj(ply,p)ply.p=p end
function netPLY.setConf(uid,config)getPLY(uid).config=config end
function netPLY.setReady(uid,ready)
@@ -126,9 +126,23 @@ function netPLY.setReady(uid,ready)
end
end
end
function netPLY.resetReady()
function netPLY.setConnect(uid)
for _,p in next,PLY do
if p.uid==uid then
p.connected=true
return
end
end
end
function netPLY.freshStreamConn(list)
for _,uid in next,list do
getPLY(uid).connected=true
end
end
function netPLY.resetState()
for i=1,#PLY do
PLY[i].ready=false
PLY[i].connected=false
end
end
@@ -165,7 +179,7 @@ function netPLY.draw()
local p=PLY[i]
gc.translate(p.x,p.y)
--Rectangle
gc.setColor(COLOR[p.ready and'G'or'Z'])
gc.setColor(COLOR[p.connected and"N"or p.ready and'A'or'Z'])
gc.setLineWidth(2)
gc.rectangle('line',0,0,p.w,p.h)

View File

@@ -174,7 +174,7 @@ function scene.socketRead(cmd,d)
if not playing then
playing=true
love.keyboard.setKeyRepeat(false)
netPLY.resetReady()
netPLY.resetState()
netPLY.mouseMove(0,0)
lastUpstreamTime=0
upstreamProgress=1
@@ -264,12 +264,16 @@ function scene.draw()
netPLY.draw()
--Ready & Set mark
gc.setColor(.1,1,0,.9)
setFont(60)
if NET.connectingStream then
mStr(text.set,640,10)
elseif NET.allReady then
mStr(text.ready,640,10)
setFont(50)
if NET.allReady then
gc.setColor(0,1,.5,.9)
mStr(text.ready,640,15)
elseif NET.connectingStream then
gc.setColor(.1,1,.8,.9)
mStr(text.connStream,640,15)
elseif NET.waitingStream then
gc.setColor(0,.8,1,.9)
mStr(text.waitStream,640,15)
end
--Room info.

View File

@@ -19,6 +19,7 @@ function scene.sceneInit()
BG.set()
NET.allReady=false
NET.connectingStream=false
NET.waitingStream=false
scrollPos=0
selected=1
fetchRoom()