主菜单点联网游戏按钮尝试连接时会有文字提示,房间内可以显示其他玩家的ws(stream)连接状态
This commit is contained in:
@@ -109,7 +109,7 @@ return{
|
|||||||
leaveRoom="has left the room.",
|
leaveRoom="has left the room.",
|
||||||
ready="READY",
|
ready="READY",
|
||||||
connStream="CONNECTING",
|
connStream="CONNECTING",
|
||||||
waitStream="CONNECTED",
|
waitStream="WAITING",
|
||||||
champion="$1 won",
|
champion="$1 won",
|
||||||
chatRemain="Online",
|
chatRemain="Online",
|
||||||
chatStart="------Beginning of log------",
|
chatStart="------Beginning of log------",
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ return{
|
|||||||
leaveRoom="a quitté le salon.",
|
leaveRoom="a quitté le salon.",
|
||||||
-- ready="READY",
|
-- ready="READY",
|
||||||
-- connStream="CONNECTING",
|
-- connStream="CONNECTING",
|
||||||
-- waitStream="CONNECTED",
|
-- waitStream="WAITING",
|
||||||
champion="$1 a gagné",
|
champion="$1 a gagné",
|
||||||
chatRemain="En ligne : ",
|
chatRemain="En ligne : ",
|
||||||
chatStart="--------Début des logs--------",
|
chatStart="--------Début des logs--------",
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ return{
|
|||||||
leaveRoom="Saiu da sala.",
|
leaveRoom="Saiu da sala.",
|
||||||
-- ready="READY",
|
-- ready="READY",
|
||||||
-- connStream="CONNECTING",
|
-- connStream="CONNECTING",
|
||||||
-- waitStream="CONNECTED",
|
-- waitStream="WAITING",
|
||||||
-- champion="$1 won",
|
-- champion="$1 won",
|
||||||
chatRemain="Online",
|
chatRemain="Online",
|
||||||
chatStart="------Começo do log------",
|
chatStart="------Começo do log------",
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ return{
|
|||||||
leaveRoom="salió de la sala.",
|
leaveRoom="salió de la sala.",
|
||||||
-- ready="READY",
|
-- ready="READY",
|
||||||
-- connStream="CONNECTING",
|
-- connStream="CONNECTING",
|
||||||
-- waitStream="CONNECTED",
|
-- waitStream="WAITING",
|
||||||
champion="$1 ganó!",
|
champion="$1 ganó!",
|
||||||
chatRemain="Usuarios en línea: ",
|
chatRemain="Usuarios en línea: ",
|
||||||
chatStart="------Comienzo del historial------",
|
chatStart="------Comienzo del historial------",
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ return{
|
|||||||
leaveRoom="离开房间",
|
leaveRoom="离开房间",
|
||||||
ready="各就各位!",
|
ready="各就各位!",
|
||||||
connStream="正在连接",
|
connStream="正在连接",
|
||||||
waitStream="等待他人连接",
|
waitStream="等待其他人连接",
|
||||||
champion="$1 获胜",
|
champion="$1 获胜",
|
||||||
chatRemain="人数:",
|
chatRemain="人数:",
|
||||||
chatStart="------消息的开头------",
|
chatStart="------消息的开头------",
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ local NET={
|
|||||||
},
|
},
|
||||||
allReady=false,
|
allReady=false,
|
||||||
connectingStream=false,
|
connectingStream=false,
|
||||||
streamRoomID=false,
|
waitingStream=false,
|
||||||
serverGaming=false,
|
serverGaming=false,
|
||||||
|
streamRoomID=false,
|
||||||
|
|
||||||
UserCount="_",
|
UserCount="_",
|
||||||
PlayCount="_",
|
PlayCount="_",
|
||||||
@@ -482,14 +483,18 @@ function NET.updateWS_stream()
|
|||||||
local d=res.data
|
local d=res.data
|
||||||
if res.type=='Connect'then
|
if res.type=='Connect'then
|
||||||
NET.unlock('wsc_stream')
|
NET.unlock('wsc_stream')
|
||||||
elseif res.action==0 then--Game start
|
|
||||||
NET.connectingStream=false
|
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
|
if SCN.socketRead then SCN.socketRead('go',d)end
|
||||||
NET.roomInfo.start=true
|
NET.roomInfo.start=true
|
||||||
elseif res.action==1 then--Game finished
|
elseif res.action==1 then--Game finished
|
||||||
--?
|
--?
|
||||||
elseif res.action==2 then--Player join
|
elseif res.action==2 then--Player join
|
||||||
--?
|
netPLY.setConnect(d.uid)
|
||||||
elseif res.action==3 then--Player leave
|
elseif res.action==3 then--Player leave
|
||||||
--?
|
--?
|
||||||
elseif res.action==4 then--Player died
|
elseif res.action==4 then--Player died
|
||||||
|
|||||||
@@ -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.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
|
||||||
p.x,p.y,p.w,p.h=640+2600*cos(a),360+2600*sin(a),47,47
|
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.getUsername(uid)return getPLY(uid).username end
|
||||||
function netPLY.getSID(uid)return getPLY(uid).sid end
|
function netPLY.getSID(uid)return getPLY(uid).sid end
|
||||||
function netPLY.getSelfReady()return PLY[1].ready end
|
function netPLY.getSelfReady()return PLY[1].ready end
|
||||||
|
|
||||||
function netPLY.setPlayerObj(ply,p)ply.p=p end
|
function netPLY.setPlayerObj(ply,p)ply.p=p end
|
||||||
function netPLY.setConf(uid,config)getPLY(uid).config=config end
|
function netPLY.setConf(uid,config)getPLY(uid).config=config end
|
||||||
function netPLY.setReady(uid,ready)
|
function netPLY.setReady(uid,ready)
|
||||||
@@ -126,9 +126,23 @@ function netPLY.setReady(uid,ready)
|
|||||||
end
|
end
|
||||||
end
|
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
|
for i=1,#PLY do
|
||||||
PLY[i].ready=false
|
PLY[i].ready=false
|
||||||
|
PLY[i].connected=false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -165,7 +179,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.ready and'G'or'Z'])
|
gc.setColor(COLOR[p.connected and"N"or p.ready and'A'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)
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ function scene.socketRead(cmd,d)
|
|||||||
if not playing then
|
if not playing then
|
||||||
playing=true
|
playing=true
|
||||||
love.keyboard.setKeyRepeat(false)
|
love.keyboard.setKeyRepeat(false)
|
||||||
netPLY.resetReady()
|
netPLY.resetState()
|
||||||
netPLY.mouseMove(0,0)
|
netPLY.mouseMove(0,0)
|
||||||
lastUpstreamTime=0
|
lastUpstreamTime=0
|
||||||
upstreamProgress=1
|
upstreamProgress=1
|
||||||
@@ -264,12 +264,16 @@ function scene.draw()
|
|||||||
netPLY.draw()
|
netPLY.draw()
|
||||||
|
|
||||||
--Ready & Set mark
|
--Ready & Set mark
|
||||||
gc.setColor(.1,1,0,.9)
|
setFont(50)
|
||||||
setFont(60)
|
if NET.allReady then
|
||||||
if NET.connectingStream then
|
gc.setColor(0,1,.5,.9)
|
||||||
mStr(text.set,640,10)
|
mStr(text.ready,640,15)
|
||||||
elseif NET.allReady then
|
elseif NET.connectingStream then
|
||||||
mStr(text.ready,640,10)
|
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
|
end
|
||||||
|
|
||||||
--Room info.
|
--Room info.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ function scene.sceneInit()
|
|||||||
BG.set()
|
BG.set()
|
||||||
NET.allReady=false
|
NET.allReady=false
|
||||||
NET.connectingStream=false
|
NET.connectingStream=false
|
||||||
|
NET.waitingStream=false
|
||||||
scrollPos=0
|
scrollPos=0
|
||||||
selected=1
|
selected=1
|
||||||
fetchRoom()
|
fetchRoom()
|
||||||
|
|||||||
Reference in New Issue
Block a user