Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sejong25
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Tear of Sejong
sejong25
Commits
d7bf6857
Commit
d7bf6857
authored
Jul 12, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
대기실 카운터 WIP
parent
beeacbac
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
6 deletions
+79
-6
GameServer.js
GameServer.js
+20
-4
Client.js
js/Client.js
+8
-1
ScenesData.js
js/ScenesData.js
+41
-0
main.js
js/main.js
+1
-1
server.js
server.js
+9
-0
No files found.
GameServer.js
View file @
d7bf6857
var
GameServer
=
GameServer
||
{};
GameServer
.
Phase
=
{
READY
:
0
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
Phase
=
{
READY
:
0
,
COUNT
:
-
1
,
START
:
1
,
MAIN
:
2
,
MUSIC
:
3
};
GameServer
.
startCount
=
2
;
GameServer
.
currentPlayer
=
[];
...
...
@@ -35,9 +35,9 @@ GameServer.makeRoom = function()
{
roomNum
:
GameServer
.
nextRoomNumber
++
,
maxPlayer
:
5
,
nextRank
:
5
,
nextRank
:
0
,
currentPlayer
:
[],
aliveCount
:
-
1
,
aliveCount
:
0
,
currentSocket
:
[],
currentPhase
:
GameServer
.
Phase
.
READY
,
...
...
@@ -82,10 +82,26 @@ GameServer.enterRoom = function(roomIdx, playerData)
}
playerData
.
playingData
=
player
;
playerData
.
currentRoom
=
room
;
room
.
aliveCount
++
;
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
room
.
roomNum
);
playerData
.
socketId
.
emit
(
'
enterRoom
'
);
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
GameServer
.
startRoom
(
roomIdx
);
let
endTimeToAnnounce
=
Date
.
now
()
+
6000
;
if
(
room
.
currentPlayer
.
length
>=
this
.
startCount
)
{
if
(
room
.
currentPhase
===
this
.
Phase
.
READY
)
// start count
{
this
.
announceToRoom
(
room
.
roomNum
,
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
endTimeToAnnounce
});
}
else
if
(
room
.
currentPhase
===
this
.
Phase
.
COUNT
)
// countinue count
{
playerData
.
socketId
.
emit
(
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
endTimeToAnnounce
});
}
}
else
// stop count
{
this
.
announceToRoom
(
room
.
roomNum
,
'
setCount
'
,
{
isEnable
:
false
,
endTime
:
0
});
}
return
room
;
}
GameServer
.
enterEmptyRoom
=
function
(
playerData
)
...
...
js/Client.js
View file @
d7bf6857
...
...
@@ -19,6 +19,12 @@ socket.on('setId', function(msg) // {str, num playerNum}
socket
.
on
(
'
enterRoom
'
,
function
()
{
game
.
scene
.
remove
(
'
menuScene
'
);
game
.
scene
.
start
(
'
roomScene
'
);
});
socket
.
on
(
'
setCount
'
,
function
(
msg
)
{
ScenesData
.
roomScene
.
isCounting
=
msg
.
isEnable
;
ScenesData
.
roomScene
.
endTime
=
msg
.
endTime
;
});
// init game
...
...
@@ -31,6 +37,7 @@ socket.on('syncRoomData', function(msg) // {num roomNum, [] players}
});
socket
.
on
(
'
startGame
'
,
function
()
{
game
.
scene
.
remove
(
'
roomScene
'
);
game
.
scene
.
start
(
'
gameScene
'
);
});
...
...
js/ScenesData.js
View file @
d7bf6857
...
...
@@ -27,6 +27,47 @@ var menuScene = new Phaser.Class(
}
});
var
roomScene
=
new
Phaser
.
Class
(
{
Extends
:
Phaser
.
Scene
,
initialize
:
function
roomScene
()
{
Phaser
.
Scene
.
call
(
this
,
{
key
:
'
roomScene
'
});
},
preload
:
function
()
{
ScenesData
.
roomScene
=
this
;
},
create
:
function
()
{
this
.
isCounting
=
false
;
this
.
endTime
=
0
;
this
.
countText
=
this
.
add
.
text
(
640
,
360
,
'
사람들을 위해 대기중입니다...
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
},
update
:
function
()
{
if
(
this
.
isCounting
)
{
this
.
countText
.
setText
((
this
.
endTime
-
Date
.
now
())
/
1000
);
if
(
this
.
endTime
-
Date
.
now
()
<
0
)
{
socket
.
emit
(
'
endCount
'
);
this
.
isCounting
=
false
;
}
}
else
{
this
.
countText
.
setText
(
'
사람들을 위해 대기중입니다...
'
);
}
}
})
var
gameScene
=
new
Phaser
.
Class
(
{
Extends
:
Phaser
.
Scene
,
...
...
js/main.js
View file @
d7bf6857
...
...
@@ -9,7 +9,7 @@ var config = {
}
},
backgroundColor
:
Phaser
.
Display
.
Color
.
HexStringToColor
(
'
#F0CB85
'
).
color
,
//GetColor(245,208,138),
scene
:
[
menuScene
,
gameScene
]
scene
:
[
menuScene
,
roomScene
,
gameScene
]
};
var
game
=
new
Phaser
.
Game
(
config
)
...
...
server.js
View file @
d7bf6857
...
...
@@ -72,6 +72,15 @@ io.on('connection', function(socket)
socket
.
emit
(
'
setPlayerTypingRate
'
,
playerTypingRate
);
});
socket
.
on
(
'
endCount
'
)
{
socket
.
currentRoom
.
aliveCount
--
;
if
(
socket
.
currentRoom
.
aliveCount
===
0
)
{
GameServer
.
startRoom
(
GameServer
.
findRoomIndex
(
socket
.
currentRoom
.
roomNum
));
}
}
socket
.
on
(
'
attack
'
,
function
(
msg
)
{
GameServer
.
announceToTarget
(
GameServer
.
findRoomIndex
(
msg
.
roomNum
),
msg
.
target
,
'
attacked
'
,
msg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment