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
79aad6ec
Commit
79aad6ec
authored
Jul 18, 2019
by
18손재민
Committed by
18신대성
Jul 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
시즌 12호 머지
parents
5dcdc1b5
ecdfb99d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
139 additions
and
74 deletions
+139
-74
GameServer.js
GameServer.js
+37
-2
index.html
index.html
+1
-0
Client.js
js/Client.js
+12
-5
GameCycle.js
js/GameCycle.js
+68
-0
ScenesData.js
js/ScenesData.js
+1
-7
WordSpace.js
js/WordSpace.js
+6
-52
server.js
server.js
+14
-8
No files found.
GameServer.js
View file @
79aad6ec
...
...
@@ -77,15 +77,17 @@ class GameRoom
{
this
.
roomId
=
GameServer
.
getRoomNumber
();
this
.
roomIndex
=
-
1
;
this
.
startCount
=
3
;
this
.
startCount
=
2
;
this
.
maxPlayer
=
100
;
this
.
nextRank
=
100
;
this
.
startTime
=
0
;
this
.
currentPlayer
=
[];
this
.
aliveCount
=
0
;
this
.
currentSocket
=
[];
this
.
currentPhase
=
GameServer
.
Phase
.
READY
;
this
.
phaseChanger
=
-
1
;
this
.
countEndTime
=
0
;
this
.
rateArrangePoint
=
300
;
this
.
maxTypingPlayer
=
null
;
...
...
@@ -201,6 +203,37 @@ class GameRoom
console
.
log
(
'
[ROOM#
'
+
this
.
roomId
+
'
] Game Start with
'
+
this
.
currentPlayer
.
length
+
'
players
'
);
this
.
announceToRoom
(
'
changePhase
'
,
GameServer
.
Phase
.
START
);
this
.
announceToRoom
(
'
startGame
'
);
this
.
startTime
=
Date
.
now
();
}
checkPhase
(
checkTime
)
{
if
(
this
.
currentPhase
===
GameServer
.
Phase
.
START
)
{
if
(
this
.
phaseChanger
<
0
&&
checkTime
-
this
.
startTime
>
60000
)
{
this
.
currentPhase
=
GameServer
.
Phase
.
MAIN
;
this
.
announceToRoom
(
'
changePhase
'
,
GameServer
.
Phase
.
MAIN
);
}
else
if
(
this
.
phaseChanger
<
0
)
{
this
.
phaseChanger
=
setTimeout
(
function
(
room
)
{
room
.
currentPhase
=
GameServer
.
Phase
.
MAIN
;
room
.
announceToRoom
(
'
changePhase
'
,
GameServer
.
Phase
.
MAIN
);
room
.
phaseChanger
=
-
1
;
},
60000
-
(
checkTime
-
this
.
startTime
),
this
);
}
}
else
if
(
this
.
currentPhase
===
GameServer
.
Phase
.
MAIN
)
{
let
playerLimit
=
Math
.
max
(
this
.
currentPlayer
.
length
/
10
,
3
);
if
(
this
.
aliveCount
<=
playerLimit
)
{
this
.
currentPhase
=
GameServer
.
Phase
.
MUSIC
;
this
.
announceToRoom
(
'
changePhase
'
,
GameServer
.
Phase
.
MUSIC
);
}
}
}
endRoom
()
...
...
@@ -274,6 +307,8 @@ class Player
socket
.
playerData
.
isReceivable
=
false
;
room
.
aliveCount
--
;
room
.
checkPhase
(
Date
.
now
());
if
(
this
.
lastAttacks
.
length
>
0
)
{
this
.
lastAttack
=
this
.
lastAttacks
[
this
.
lastAttacks
.
length
-
1
];
...
...
@@ -288,7 +323,7 @@ class Player
}
room
.
announceToRoom
(
'
defeat
'
,
this
);
console
.
log
(
'
[
'
+
this
.
id
+
'
] defeated, rank:
'
+
this
.
rank
);
console
.
log
(
'
[
'
+
this
.
id
+
'
] defeated, rank:
'
+
this
.
rank
+
'
,
'
+
room
.
currentPlayer
.
length
+
'
player left
'
);
if
(
socket
.
playerData
.
currentRoom
.
aliveCount
===
1
)
{
...
...
index.html
View file @
79aad6ec
...
...
@@ -8,6 +8,7 @@
<script
src=
"js/Background.js"
></script>
<script
src=
"js/Input.js"
></script>
<script
src=
"js/WordSpace.js"
></script>
<script
src=
"js/GameCycle.js"
></script>
<script
src=
"js/WordObject.js"
></script>
<script
src=
"js/WordReader.js"
></script>
<script
src=
"js/CSVParsing.js"
></script>
...
...
js/Client.js
View file @
79aad6ec
...
...
@@ -5,10 +5,16 @@ socket.emit('idRequest');
socket
.
on
(
'
alert
'
,
function
(
msg
)
// string errorcode
{
let
toAlert
=
'
null alert
'
;
if
(
msg
===
'
errNicknameOverlaped
'
)
toAlert
=
'
이미 사용중인 닉네임입니다.
'
;
if
(
msg
===
'
gameWin
'
)
toAlert
=
'
승리!
'
;
alert
(
toAlert
);
//let toAlert = 'null alert';
if
(
msg
===
'
errNicknameOverlaped
'
)
alert
(
'
이미 사용중인 닉네임입니다.
'
);
if
(
msg
===
'
gameWin
'
)
{
//toAlert = '승리!';
ScenesData
.
gameScene
.
add
.
text
(
640
,
360
,
'
승리!!!!
'
,
{
fontSize
:
'
30pt
'
})
.
setPadding
(
5
,
5
,
5
,
5
).
setOrigin
(
0.5
,
0.5
).
setDepth
(
11
)
.
setColor
(
'
#000000
'
).
setBackgroundColor
(
'
#ffffff
'
);
}
//alert(toAlert);
});
socket
.
on
(
'
setId
'
,
function
(
msg
)
// {str, num playerNum}
...
...
@@ -113,10 +119,11 @@ socket.on('setPlayerTypingRate', function(msg) // number playerTypingRate
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
{
//console.log('attacked by ' + msg.attacker.nickname);
setTimeout
(
function
()
var
timeout
=
setTimeout
(
function
()
{
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
,
msg
.
isCountable
);
},
4000
);
console
.
log
(
timeout
);
});
socket
.
on
(
'
defeat
'
,
function
(
msg
)
// object player
{
...
...
js/GameCycle.js
0 → 100644
View file @
79aad6ec
WordSpace
.
startCycle
=
function
(
scene
)
{
WordSpace
.
wordCycle
.
resetCycle
(
scene
,
3000
,
0
,
true
);
WordSpace
.
nameCycle
.
resetCycle
(
scene
,
3000
,
0
,
true
);
WordSpace
.
varAdjustCycle
.
resetCycle
(
scene
,
100
,
0
,
true
);
WordSpace
.
playerTypingCycle
=
setInterval
(
function
()
{
socket
.
emit
(
'
setPlayerTyping
'
,
WordSpace
.
playerTyping
);
},
500
);
}
WordSpace
.
pauseCycle
=
function
(
isPause
)
{
WordSpace
.
wordCycle
.
currentCycle
.
paused
=
isPause
;
WordSpace
.
nameCycle
.
currentCycle
.
paused
=
isPause
;
WordSpace
.
varAdjustCycle
.
currentCycle
.
paused
=
isPause
;
WordSpace
.
attackGauge
.
pauseCycle
(
isPause
);
if
(
isPause
)
clearInterval
(
WordSpace
.
playerTypingCycle
);
else
WordSpace
.
playerTypingCycle
=
setInterval
(
function
()
{
socket
.
emit
(
'
setPlayerTyping
'
,
WordSpace
.
playerTyping
);
},
500
);
}
class
Cycle
//앞으로 cycle은 이 클래스를 사용해서 구현할 것
{
constructor
(
_callback
)
{
this
.
delay
=
0
;
this
.
currentCycle
=
null
;
this
.
callbackFunction
=
_callback
;
}
resetCycle
(
scene
,
_delay
,
_startAt
,
_loop
)
{
this
.
delay
=
_delay
;
var
option
=
{
startAt
:
_startAt
,
delay
:
_delay
,
callback
:
this
.
callbackFunction
,
callbackScope
:
scene
,
loop
:
_loop
};
if
(
this
.
currentCycle
!=
null
)
this
.
currentCycle
=
this
.
currentCycle
.
reset
(
option
);
else
this
.
currentCycle
=
scene
.
time
.
addEvent
(
option
);
}
}
//단어 생성 사이클
WordSpace
.
wordCycle
=
new
Cycle
(
function
()
{
WordSpace
.
genWordByProb
(
this
);
});
//게임 오버 사이클
WordSpace
.
gameOverCycle
=
new
Cycle
(
gameOver
);
//호패 생성 사이클
WordSpace
.
nameCycle
=
new
Cycle
(
function
()
{
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
});
//이건 뭐지
WordSpace
.
varAdjustCycle
=
new
Cycle
(
function
()
{
//나중에는 메세지 분석해서 Phase랑 playerTypingRate 받겠지만 일단 이렇게 해둠
//WordSpace.GetPhase();
//WordSpace.GetPlayerTypingRate();
WordSpace
.
AdjustVarByPhase
(
WordSpace
.
playerTypingRate
,
WordSpace
.
CurrentPhase
);
});
\ No newline at end of file
js/ScenesData.js
View file @
79aad6ec
...
...
@@ -144,13 +144,7 @@ var gameScene = new Phaser.Class(
WordSpace
.
spaceInitiate
(
this
);
WordSpace
.
attackGauge
.
resetCycle
(
this
);
WordSpace
.
wordCycle
.
resetCycle
(
this
,
3000
,
0
,
true
);
WordSpace
.
nameCycle
.
resetCycle
(
this
,
3000
,
0
,
true
);
WordSpace
.
varAdjustCycle
.
resetCycle
(
this
,
100
,
0
,
true
);
WordSpace
.
playerTypingCycle
=
setInterval
(
function
()
{
socket
.
emit
(
'
setPlayerTyping
'
,
WordSpace
.
playerTyping
);
},
500
);
WordSpace
.
startCycle
(
this
);
WordSpace
.
setPlayerTyping
.
initiate
(
this
);
...
...
js/WordSpace.js
View file @
79aad6ec
...
...
@@ -34,56 +34,10 @@ WordSpace.delay =
GameOver
:
5000
,
}
WordSpace
.
playerTypingCycle
=
null
;
WordSpace
.
NameSpawnReduce
=
1000
;
WordSpace
.
gravityPoint
=
{
x
:
640
,
y
:
280
};
class
Cycle
//앞으로 cycle은 이 클래스를 사용해서 구현할 것
{
constructor
(
_callback
)
{
this
.
delay
=
0
;
this
.
currentCycle
=
null
;
this
.
callbackFunction
=
_callback
;
}
resetCycle
(
scene
,
_delay
,
_startAt
,
_loop
)
{
this
.
delay
=
_delay
;
var
option
=
{
startAt
:
_startAt
,
delay
:
_delay
,
callback
:
this
.
callbackFunction
,
callbackScope
:
scene
,
loop
:
_loop
};
if
(
this
.
currentCycle
!=
null
)
this
.
currentCycle
=
this
.
currentCycle
.
reset
(
option
);
else
this
.
currentCycle
=
scene
.
time
.
addEvent
(
option
);
}
}
//단어 생성 사이클
WordSpace
.
wordCycle
=
new
Cycle
(
function
()
{
WordSpace
.
genWordByProb
(
this
);
});
//게임 오버 사이클
WordSpace
.
gameOverCycle
=
new
Cycle
(
gameOver
);
//호패 생성 사이클
WordSpace
.
nameCycle
=
new
Cycle
(
function
()
{
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
});
//이건 뭐지
WordSpace
.
varAdjustCycle
=
new
Cycle
(
function
()
{
//나중에는 메세지 분석해서 Phase랑 playerTypingRate 받겠지만 일단 이렇게 해둠
//WordSpace.GetPhase();
//WordSpace.GetPlayerTypingRate();
WordSpace
.
AdjustVarByPhase
(
WordSpace
.
playerTypingRate
,
WordSpace
.
CurrentPhase
);
});
WordSpace
.
getSpawnPoint
=
function
(
_lenRate
)
{
let
lenRate
=
1
;
...
...
@@ -319,14 +273,14 @@ WordSpace.pushWord = function(scene, word, lenRate)
function
gameOver
()
{
WordSpace
.
wordCycle
.
currentCycle
.
remove
();
WordSpace
.
nameCycle
.
currentCycle
.
remove
();
WordSpace
.
varAdjustCycle
.
currentCycle
.
remove
();
clearInterval
(
WordSpace
.
playerTypingCycle
);
//To Do
WordSpace
.
pauseCycle
(
true
);
socket
.
emit
(
'
defeated
'
);
console
.
log
(
'
defeat
'
);
alert
(
'
defeat
'
);
ScenesData
.
gameScene
.
add
.
text
(
640
,
360
,
'
패배
'
,
{
fontSize
:
'
30pt
'
})
.
setPadding
(
5
,
5
,
5
,
5
).
setOrigin
(
0.5
,
0.5
).
setDepth
(
10
)
.
setColor
(
'
#000000
'
).
setBackgroundColor
(
'
#ffffff
'
);
//alert('defeat');
}
//게임 오버 판정을 위한 타이머
...
...
server.js
View file @
79aad6ec
...
...
@@ -55,6 +55,8 @@ io.on('connection', function(socket)
});
socket
.
on
(
'
setPlayerTyping
'
,
function
(
msg
)
// number playerTyping
{
try
{
socket
.
playerData
.
playingData
.
playerTyping
=
msg
;
if
(
socket
.
playerData
.
currentRoom
.
maxTypingPlayer
.
playerTyping
<
msg
)
...
...
@@ -68,6 +70,10 @@ io.on('connection', function(socket)
let
playerTypingRate
=
(
msg
-
(
socket
.
playerData
.
currentRoom
.
minTypingPlayer
.
playerTyping
-
socket
.
playerData
.
currentRoom
.
rateArrangePoint
))
/
(
socket
.
playerData
.
currentRoom
.
maxTypingPlayer
.
playerTyping
-
socket
.
playerData
.
currentRoom
.
minTypingPlayer
.
playerTyping
+
socket
.
playerData
.
currentRoom
.
rateArrangePoint
*
2
);
socket
.
emit
(
'
setPlayerTypingRate
'
,
playerTypingRate
);
}
catch
(
e
)
{
}
});
socket
.
on
(
'
endCount
'
,
function
()
...
...
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