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
17c0f18e
Commit
17c0f18e
authored
Jul 17, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
룸대기화면에 대기중인 사람 그림으로 뜨게
parent
95b3b93e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
20 deletions
+99
-20
GameServer.js
GameServer.js
+24
-9
Background.js
js/Background.js
+7
-1
Client.js
js/Client.js
+41
-4
ScenesData.js
js/ScenesData.js
+16
-3
server.js
server.js
+11
-3
No files found.
GameServer.js
View file @
17c0f18e
...
...
@@ -77,7 +77,7 @@ class GameRoom
{
this
.
roomId
=
GameServer
.
getRoomNumber
();
this
.
roomIndex
=
-
1
;
this
.
startCount
=
2
;
this
.
startCount
=
4
;
this
.
maxPlayer
=
100
;
this
.
nextRank
=
100
;
...
...
@@ -114,32 +114,47 @@ class GameRoom
enterRoom
(
playerSocket
)
{
let
playerInst
=
new
Player
(
this
,
playerSocket
.
playerData
);
this
.
currentPlayer
.
push
(
playerInst
);
this
.
currentSocket
.
push
(
playerSocket
);
playerSocket
.
playerData
.
playingData
=
playerInst
;
playerSocket
.
playerData
.
currentRoom
=
this
;
playerSocket
.
playerData
.
isReceivable
=
true
;
console
.
log
(
'
[
'
+
playerInst
.
id
+
'
] entered to room #
'
+
this
.
roomId
);
playerSocket
.
emit
(
'
enterRoom
'
);
this
.
currentSocket
.
push
(
playerSocket
);
this
.
announceToTarget
(
playerInst
.
id
,
'
syncRoomScene
'
,
this
.
currentPlayer
);
this
.
currentPlayer
.
push
(
playerInst
);
console
.
log
(
'
[
'
+
playerInst
.
id
+
'
] entered to room #
'
+
this
.
roomId
);
this
.
aliveCount
++
;
if
(
this
.
currentPlayer
.
length
>=
this
.
startCount
)
{
if
(
this
.
currentPhase
===
GameServer
.
Phase
.
READY
)
{
this
.
endTime
=
Date
.
now
()
+
1000
;
// 테스트용 10초
this
.
announceToRoom
(
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
this
.
endTime
,
playerCount
:
this
.
currentPlayer
.
length
});
this
.
endTime
=
Date
.
now
()
+
5000
;
// 테스트용 10초
this
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
true
,
endTime
:
this
.
endTime
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
true
,
player
:
playerInst
// 나중에는 플레이어의 외양데이터도 보내야됨
});
this
.
currentPhase
=
GameServer
.
Phase
.
COUNT
;
}
else
if
(
this
.
currentPhase
===
GameServer
.
Phase
.
COUNT
)
{
this
.
announceToRoom
(
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
this
.
endTime
,
playerCount
:
this
.
currentPlayer
.
length
});
this
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
true
,
endTime
:
this
.
endTime
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
true
,
player
:
playerInst
});
}
}
else
{
this
.
announceToRoom
(
'
setCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
this
.
currentPlayer
.
length
});
this
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
this
.
currentPlayer
.
length
,
isEnter
:
true
,
player
:
playerInst
});
this
.
currentPhase
=
GameServer
.
Phase
.
READY
;
}
}
...
...
js/Background.js
View file @
17c0f18e
...
...
@@ -6,7 +6,8 @@ BackGround.myCharacter = null;
BackGround
.
loadImage
=
function
(
scene
)
{
scene
.
load
.
image
(
'
brainGround
'
,
'
assets/image/background/background_brain.png
'
);
scene
.
load
.
image
(
'
menuBackground
'
,
'
assets/placeholder/menuBackground.png
'
)
scene
.
load
.
image
(
'
menuBackground
'
,
'
assets/placeholder/menuBackground.png
'
);
scene
.
load
.
image
(
'
roomBackground
'
,
'
assets/placeholder/roomBackground.png
'
);
}
BackGround
.
drawCharacter
=
function
(
scene
)
...
...
@@ -22,4 +23,9 @@ BackGround.drawBrain = function(scene)
BackGround
.
drawMenu
=
function
(
scene
)
{
scene
.
add
.
sprite
(
640
,
360
,
'
menuBackground
'
).
setDisplaySize
(
1282
,
722
).
setDepth
(
1
);
}
BackGround
.
drawRoom
=
function
(
scene
)
{
scene
.
add
.
sprite
(
640
,
360
,
'
roomBackground
'
).
setDisplaySize
(
1282
,
722
).
setDepth
(
1
);
}
\ No newline at end of file
js/Client.js
View file @
17c0f18e
...
...
@@ -21,12 +21,49 @@ socket.on('enterRoom', function()
Audio
.
killSound
(
ScenesData
.
menuScene
,
'
login
'
);
game
.
scene
.
remove
(
'
menuScene
'
);
game
.
scene
.
start
(
'
roomScene
'
);
});
socket
.
on
(
'
s
etCount
'
,
function
(
msg
)
socket
.
on
(
'
s
yncRoomScene
'
,
function
(
msg
)
{
ScenesData
.
roomScene
.
isCounting
=
msg
.
isEnable
;
ScenesData
.
roomScene
.
endTime
=
msg
.
endTime
;
ScenesData
.
roomScene
.
peopleCount
=
msg
.
playerCount
;
setTimeout
(
function
()
{
for
(
let
i
=
0
;
i
<
msg
.
length
;
i
++
)
{
let
randX
=
Math
.
random
()
*
1120
+
80
;
let
randY
=
Math
.
random
()
*
380
+
100
;
var
playerSet
=
{
sprite
:
ScenesData
.
roomScene
.
add
.
sprite
(
randX
,
randY
,
'
playerStand
'
).
setOrigin
(
0.5
,
0.5
).
setScale
(
0.2
,
0.2
),
nickname
:
msg
[
i
].
nickname
}
ScenesData
.
roomScene
.
players
.
push
(
playerSet
);
}
},
100
);
});
socket
.
on
(
'
setRoomCount
'
,
function
(
msg
)
{
setTimeout
(
function
()
{
ScenesData
.
roomScene
.
isCounting
=
msg
.
isEnable
;
ScenesData
.
roomScene
.
endTime
=
msg
.
endTime
;
ScenesData
.
roomScene
.
peopleCount
=
msg
.
playerCount
;
if
(
msg
.
isEnter
)
// generate charactor
{
let
randX
=
Math
.
random
()
*
1120
+
80
;
let
randY
=
Math
.
random
()
*
380
+
100
;
var
playerSet
=
{
sprite
:
ScenesData
.
roomScene
.
add
.
sprite
(
randX
,
randY
,
'
playerStand
'
).
setOrigin
(
0.5
,
0.5
).
setScale
(
0.2
,
0.2
),
nickname
:
msg
.
player
.
nickname
}
ScenesData
.
roomScene
.
players
.
push
(
playerSet
);
}
else
// remove charactor
{
}
},
200
);
});
// init game
...
...
js/ScenesData.js
View file @
17c0f18e
...
...
@@ -42,30 +42,43 @@ var roomScene = new Phaser.Class(
preload
:
function
()
{
ScenesData
.
roomScene
=
this
;
BackGround
.
loadImage
(
this
);
this
.
load
.
image
(
'
playerStand
'
,
'
assets/image/character/pyeongmin/pyeong_stand.png
'
);
},
create
:
function
()
{
BackGround
.
drawRoom
(
this
);
this
.
players
=
[];
this
.
isCounting
=
false
;
this
.
isCountEnd
=
false
;
this
.
endTime
=
0
;
this
.
peopleCount
=
1
;
this
.
countText
=
this
.
add
.
text
(
640
,
360
,
'
사람들을 위해 대기중입니다...
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
this
.
peopleText
=
this
.
add
.
text
(
640
,
100
,
'
1 / 10
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
);
this
.
countText
=
this
.
add
.
text
(
640
,
360
,
'
사람들을 위해 대기중입니다...
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
)
.
setBackgroundColor
(
'
#ffffff
'
).
setDepth
(
10
).
setPadding
(
5
,
5
,
5
,
5
)
;
this
.
peopleText
=
this
.
add
.
text
(
640
,
80
,
'
1 / 10
'
).
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
).
setBackgroundColor
(
'
#ffffff
'
).
setDepth
(
10
);
},
update
:
function
()
{
this
.
peopleText
.
setText
(
this
.
peopleCount
+
'
/ 10
'
);
if
(
this
.
isCounting
)
{
this
.
countText
.
setText
(((
this
.
endTime
-
Date
.
now
())
/
1000
).
toFixed
(
1
));
if
(
this
.
endTime
-
Date
.
now
()
<
0
)
if
(
this
.
endTime
<
Date
.
now
()
)
{
//console.log('end Count');
socket
.
emit
(
'
endCount
'
);
this
.
isCounting
=
false
;
this
.
isCountEnd
=
true
;
}
}
else
if
(
this
.
isCountEnd
)
{
this
.
countText
.
setText
(
'
잠시만 기다려주세요...
'
);
}
else
{
this
.
countText
.
setText
(
'
사람들을 위해 대기중입니다...
'
);
...
...
server.js
View file @
17c0f18e
...
...
@@ -137,12 +137,20 @@ io.on('connection', function(socket)
if
(
data
.
currentRoom
.
currentPhase
===
GameServer
.
Phase
.
READY
||
data
.
currentRoom
.
currentPhase
===
GameServer
.
Phase
.
COUNT
)
{
data
.
currentRoom
.
exitRoom
(
data
.
id
);
if
(
data
.
currentRoom
.
aliveCount
<
GameServer
.
startCount
)
if
(
data
.
currentRoom
.
aliveCount
<
data
.
currentRoom
.
startCount
)
{
data
.
currentRoom
.
announceToRoom
(
'
setCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
data
.
currentRoom
.
currentPlayer
.
length
});
data
.
currentRoom
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
false
,
endTime
:
0
,
playerCount
:
data
.
currentRoom
.
currentPlayer
.
length
,
isEnter
:
false
,
player
:
data
.
playingData
});
data
.
currentRoom
.
currentPhase
=
GameServer
.
Phase
.
READY
;
}
else
data
.
currentRoom
.
announceToRoom
(
'
setCount
'
,
{
isEnable
:
true
,
endTime
:
data
.
currentRoom
.
endTime
,
playerCount
:
data
.
currentRoom
.
currentPlayer
.
length
});
else
data
.
currentRoom
.
announceToRoom
(
'
setRoomCount
'
,
{
isEnable
:
true
,
endTime
:
data
.
currentRoom
.
endTime
,
playerCount
:
data
.
currentRoom
.
currentPlayer
.
length
,
isEnter
:
false
,
player
:
data
.
playingData
});
}
else
if
(
data
.
playingData
.
isAlive
)
{
...
...
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