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
b4989da0
Commit
b4989da0
authored
Jul 05, 2019
by
18신대성
Committed by
18류지석
Jul 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
메뉴화면에서 닉네임 설정시 서버에 적용됨
parent
6150db4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
16 deletions
+26
-16
Input.js
js/Input.js
+12
-4
ScenesData.js
js/ScenesData.js
+0
-5
server.js
server.js
+14
-7
No files found.
js/Input.js
View file @
b4989da0
...
...
@@ -22,10 +22,18 @@ Input.gameSceneEnterReaction = function()
Input
.
menuSceneEnterReaction
=
function
()
{
Input
.
convInput
=
Input
.
removeConVow
(
Input
.
convInput
);
console
.
log
(
'
닉네임은
'
+
Input
.
convInput
);
Input
.
reset
();
game
.
scene
.
start
(
'
gameScene
'
);
game
.
scene
.
remove
(
'
menuScene
'
);
if
(
Input
.
convInput
.
length
>
0
)
{
socket
.
emit
(
'
setNickname
'
,
Input
.
convInput
);
Input
.
reset
();
game
.
scene
.
start
(
'
gameScene
'
);
game
.
scene
.
remove
(
'
menuScene
'
);
}
else
{
alert
(
'
정확한 가명을 입력해주세요.
'
);
Input
.
reset
();
}
}
Input
.
reset
=
function
()
...
...
js/ScenesData.js
View file @
b4989da0
...
...
@@ -19,11 +19,6 @@ var menuScene = new Phaser.Class(
{
Input
.
inputField
.
generate
(
this
,
Input
.
menuSceneEnterReaction
);
BackGround
.
drawMenu
(
this
);
},
update
:
function
()
{
}
});
...
...
server.js
View file @
b4989da0
...
...
@@ -13,7 +13,7 @@ app.get('/', function(req, res) {
// http 기본 포트(80)에 서버 열기
server
.
listen
(
80
,
function
()
{
console
.
log
(
'
Listening on port
'
+
server
.
address
().
port
);
console
.
log
(
'
[SERVER]
Listening on port
'
+
server
.
address
().
port
);
});
var
GameServer
=
GameServer
||
{};
...
...
@@ -52,13 +52,13 @@ GameServer.makeRoom = function()
currentPlayer
:
[]
}
this
.
playingRoom
.
push
(
roomOption
);
console
.
log
(
'
new room made, roomCount:
'
+
this
.
playingRoom
.
length
);
console
.
log
(
'
[SERVER]
new room made, roomCount:
'
+
this
.
playingRoom
.
length
);
return
this
.
playingRoom
.
length
-
1
;
}
GameServer
.
enterRoom
=
function
(
roomIdx
,
playerData
)
{
this
.
playingRoom
[
roomIdx
].
currentPlayer
.
push
(
playerData
);
console
.
log
(
playerData
.
id
+
'
entered to room#
'
+
this
.
playingRoom
[
roomIdx
].
roomNum
);
console
.
log
(
'
[
'
+
playerData
.
id
+
'
] entered to room #
'
+
this
.
playingRoom
[
roomIdx
].
roomNum
);
return
this
.
playingRoom
[
roomIdx
];
}
GameServer
.
enterEmptyRoom
=
function
(
playerData
)
...
...
@@ -89,26 +89,33 @@ io.on('connection', function(socket)
nickname
:
'
게스트
'
,
socketId
:
socket
}
socket
.
playerData
=
playerSocket
;
GameServer
.
currentPlayer
.
push
(
playerSocket
);
console
.
log
(
'
client request, id:
'
+
playerSocket
.
id
);
console
.
log
(
'
[
'
+
playerSocket
.
id
+
'
] client request
'
);
socket
.
emit
(
'
idSet
'
,
{
str
:
'
your number is
'
+
playerSocket
.
id
+
'
, your nickname is
'
+
playerSocket
.
nickname
,
str
:
'
your number is
'
+
playerSocket
.
id
,
num
:
playerSocket
.
id
});
GameServer
.
enterEmptyRoom
(
playerSocket
);
});
socket
.
on
(
'
setNickname
'
,
function
(
msg
)
// string new_nickname
{
socket
.
playerData
.
nickname
=
msg
;
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] nickname set to
'
+
msg
);
});
socket
.
on
(
'
disconnect
'
,
function
(
reason
)
{
var
idxToDel
=
GameServer
.
currentPlayer
.
findIndex
(
function
(
element
)
{
return
element
.
socketId
===
socket
;
return
element
.
id
===
socket
.
playerData
.
id
;
}
);
if
(
idxToDel
!=
-
1
)
{
console
.
log
(
'
client disconnected, id:
'
+
GameServer
.
currentPlayer
[
idxToDel
].
id
+
'
, reason:
'
+
reason
);
console
.
log
(
'
[
'
+
socket
.
playerData
.
id
+
'
] client disconnected
, reason:
'
+
reason
);
GameServer
.
currentPlayer
.
splice
(
idxToDel
,
1
);
// 룸에서도 제거
// 모두에게 삭제했다고 보내기
...
...
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