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
f306f93f
Commit
f306f93f
authored
Aug 01, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'word'
parents
9b13860d
27e6b0fd
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
359 additions
and
165 deletions
+359
-165
GameServer.js
GameServer.js
+1
-0
Background.js
js/Background.js
+3
-3
Client.js
js/Client.js
+18
-7
Enums.js
js/Enums.js
+2
-1
Input.js
js/Input.js
+6
-1
ScenesData.js
js/ScenesData.js
+14
-2
WordObject.js
js/WordObject.js
+221
-97
WordSpace.js
js/WordSpace.js
+86
-50
main.js
js/main.js
+5
-1
server.js
server.js
+3
-3
No files found.
GameServer.js
View file @
f306f93f
...
...
@@ -288,6 +288,7 @@ class Player
this
.
gameRoomId
=
gameRoom
.
roomId
;
this
.
index
=
gameRoom
.
currentPlayer
.
length
;
this
.
nickname
=
playerData
.
nickname
;
this
.
playerImage
=
null
;
this
.
position
=
null
;
this
.
isAlive
=
true
;
...
...
js/Background.js
View file @
f306f93f
var
BackGround
=
BackGround
||
{}
BackGround
.
brainGroup
=
null
;
BackGround
.
myCharacter
=
null
;
BackGround
.
characterPos
=
[
new
Phaser
.
Math
.
Vector2
(
100
,
99
),
new
Phaser
.
Math
.
Vector2
(
248
,
198
),
new
Phaser
.
Math
.
Vector2
(
412
,
144
),
new
Phaser
.
Math
.
Vector2
(
124
,
393
),
new
Phaser
.
Math
.
Vector2
(
368
,
336
),
new
Phaser
.
Math
.
Vector2
(
272
,
453
),
new
Phaser
.
Math
.
Vector2
(
100
,
595
),
new
Phaser
.
Math
.
Vector2
(
284
,
678
),
...
...
@@ -21,13 +20,14 @@ BackGround.loadImage = function(scene)
BackGround
.
drawCharacter
=
function
(
scene
)
{
BackGround
.
myCharacter
=
scene
.
add
.
sprite
(
game
.
config
.
width
/
2
,
game
.
config
.
height
*
41
/
48
,
'
pyeongminWrite
'
).
setScale
(
0.45
).
setDepth
(
2
);
RoomData
.
myself
.
playerImage
=
scene
.
add
.
sprite
(
game
.
config
.
width
/
2
,
game
.
config
.
height
*
41
/
48
,
'
pyeongminWrite
'
).
setScale
(
0.45
).
setDepth
(
2
);
RoomData
.
myself
.
position
=
new
Phaser
.
Math
.
Vector2
(
RoomData
.
myself
.
playerImage
.
x
,
RoomData
.
myself
.
playerImage
.
y
);
BackGround
.
characterPos
=
BackGround
.
characterPos
.
sort
(
function
(){
return
0.5
-
Math
.
random
()});
RoomData
.
players
.
forEach
(
function
(
element
){
if
(
element
.
id
!=
RoomData
.
myself
.
id
)
{
element
.
position
=
BackGround
.
characterPos
.
pop
();
element
.
playerImage
=
scene
.
add
.
sprite
(
element
.
position
.
x
,
element
.
position
.
y
,
'
pyeongminWrite
'
).
setScale
(
0.
4
5
).
setDepth
(
1
);
element
.
playerImage
=
scene
.
add
.
sprite
(
element
.
position
.
x
,
element
.
position
.
y
,
'
pyeongminWrite
'
).
setScale
(
0.
31
5
).
setDepth
(
1
);
element
.
playerImage
.
flipX
=
element
.
position
.
x
<
game
.
config
.
width
/
2
?
true
:
false
;
element
.
nicknameText
=
scene
.
add
.
text
(
element
.
position
.
x
,
element
.
position
.
y
-
90
,
element
.
nickname
)
.
setOrigin
(
0.5
,
0.5
).
setColor
(
'
#000000
'
).
setPadding
(
0.5
,
0.5
,
0.5
,
0.5
).
setDepth
(
1
);
...
...
js/Client.js
View file @
f306f93f
...
...
@@ -59,7 +59,7 @@ socket.on('setRoomCount', function(msg)
ScenesData
.
roomScene
.
endTime
=
msg
.
endTime
;
ScenesData
.
roomScene
.
peopleCount
=
msg
.
playerCount
;
if
(
msg
.
isEnter
)
// generate charact
o
r
if
(
msg
.
isEnter
)
// generate charact
e
r
{
let
randX
=
Math
.
random
()
*
1120
+
80
;
let
randY
=
Math
.
random
()
*
380
+
100
;
...
...
@@ -71,7 +71,7 @@ socket.on('setRoomCount', function(msg)
}
ScenesData
.
roomScene
.
players
.
push
(
playerSet
);
}
else
// remove charact
o
r
else
// remove charact
e
r
{
let
idx
=
ScenesData
.
roomScene
.
players
.
findIndex
(
function
(
element
)
{
...
...
@@ -140,20 +140,23 @@ socket.on('attackMode', function(msg) // number playerId
console
.
log
(
msg
+
'
is on attack Mode
'
);
// msg의 id를 가진 사람이 attack Mode이다.
});
socket
.
on
(
'
attack
'
,
function
(
msg
)
// {number attackerId, number targetId
}
socket
.
on
(
'
someoneAttacked
'
,
function
(
msg
)
// {Player attacker, Player victim
}
{
// 이때 위의 attack Mode인 사람(msg.attackerId)을 해제해주자.
console
.
log
(
msg
.
attackerId
+
'
attack to
'
+
msg
.
targetId
);
console
.
log
(
msg
.
attacker
.
id
+
'
attacked
'
+
msg
.
victim
.
id
);
let
attackerPos
=
RoomData
.
findPlayer
(
msg
.
attacker
).
position
;
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
).
position
;
WordSpace
.
makeAttackPaper
(
ScenesData
.
gameScene
,
attackerPos
,
victimPos
,
msg
.
multiple
);
});
socket
.
on
(
'
attacked
'
,
function
(
msg
)
// object attackData
{
//console.log('attacked by ' + msg.attacker.nickname);
let
attackedEvent
=
new
Cycle
(
function
()
{
for
(
let
i
=
0
;
i
<
msg
.
multiple
;
i
++
)
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
isStrong
,
msg
.
isCountable
);
if
(
!
WordSpace
.
isInvincible
)
for
(
let
i
=
0
;
i
<
msg
.
multiple
;
i
++
)
WordSpace
.
generateWord
.
Attack
(
ScenesData
.
gameScene
,
msg
.
text
,
msg
.
grade
,
msg
.
attacker
,
msg
.
attackOption
);
attackedEvent
.
currentCycle
.
destroy
();
WordSpace
.
attackedEvents
.
splice
(
WordSpace
.
attackedEvents
.
findIndex
(
function
(
element
)
{
WordSpace
.
attackedEvents
.
splice
(
WordSpace
.
attackedEvents
.
findIndex
(
function
(
element
)
{
return
element
.
cert
===
(
msg
.
text
+
msg
.
attacker
);
}),
1
);
});
...
...
@@ -171,6 +174,11 @@ socket.on('defeat', function(msg) // object player
{
console
.
log
(
RoomData
.
players
[
msg
.
index
].
nickname
+
'
defeated by
'
+
msg
.
lastAttack
.
attacker
+
'
, with
'
+
msg
.
lastAttack
.
word
);
WordSpace
.
killLogForTest
+=
(
'
\n
'
+
msg
.
lastAttack
.
attacker
+
'
--
'
+
msg
.
lastAttack
.
word
+
'
->
'
+
RoomData
.
players
[
msg
.
index
].
nickname
);
if
(
msg
.
lastAttack
.
attackerId
==
RoomData
.
myself
.
id
)
{
var
keys
=
Object
.
keys
(
Enums
.
item
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
[
keys
[
keys
.
length
*
Math
.
random
()
<<
0
]]);
}
}
else
{
...
...
@@ -186,6 +194,9 @@ socket.on('attackSucceed', function(msg)
{
//console.log('client');
let
tempWord
=
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
true
,
msg
.
victim
);
let
victimPos
=
RoomData
.
findPlayer
(
msg
.
victim
).
position
;
tempWord
.
physicsObj
.
setPosition
(
victimPos
.
x
,
victimPos
.
y
);
tempWord
.
wordObj
.
setPosition
(
tempWord
.
physicsObj
.
x
,
tempWord
.
physicsObj
.
y
);
tempWord
.
destroy
();
});
...
...
js/Enums.js
View file @
f306f93f
var
Enums
=
Enums
||
{};
Enums
.
characterAnim
=
{
write
:
0
,
attackWrite
:
1
,
throw
:
2
,
hit
:
3
}
\ No newline at end of file
Enums
.
characterAnim
=
{
write
:
0
,
attackWrite
:
1
,
throw
:
2
,
hit
:
3
}
Enums
.
item
=
{
invincible
:
"
무적
"
,
nameList
:
"
명단
"
,
charge
:
"
충전
"
,
clean
:
"
청소
"
,
heavy
:
"
중량
"
,
dark
:
"
암흑
"
}
\ No newline at end of file
js/Input.js
View file @
f306f93f
...
...
@@ -12,7 +12,12 @@ Input.justPressed = '';
Input
.
maxInput
=
6
;
Input
.
attackMode
=
false
;
Input
.
attackOption
=
null
;
Input
.
attackOption
=
{
wordCount
:
0
,
wordGrade
:
0
,
isHeavy
:
false
,
isDark
:
false
};
Input
.
gameSceneEnterReaction
=
function
()
{
...
...
js/ScenesData.js
View file @
f306f93f
...
...
@@ -150,9 +150,22 @@ var gameScene = new Phaser.Class(
WordSpace
.
nameWordTextForTest
=
ScenesData
.
gameScene
.
add
.
text
(
50
,
400
,
'
현재 가진 호패들 : 없음
'
).
setDepth
(
10
).
setColor
(
'
#000000
'
);
WordSpace
.
nameQueue
.
initiate
();
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
nameList
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
nameList
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
invincible
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
invincible
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
charge
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
charge
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
clean
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
clean
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
heavy
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
heavy
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
dark
);
WordSpace
.
generateWord
.
Item
(
ScenesData
.
gameScene
,
Enums
.
item
.
dark
);
// for test
WordSpace
.
attackGauge
.
add
(
11
);
/*WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
...
...
@@ -162,8 +175,7 @@ var gameScene = new Phaser.Class(
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
WordSpace
.
generateWord
.
Name
(
ScenesData
.
gameScene
,
false
,
null
);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);*/
},
update
:
function
()
...
...
js/WordObject.js
View file @
f306f93f
This diff is collapsed.
Click to expand it.
js/WordSpace.js
View file @
f306f93f
...
...
@@ -12,6 +12,7 @@ WordSpace.totalWordNum = 0;
WordSpace
.
brainCapacity
=
200
;
//수용 가능한 단어 무게 최대치
WordSpace
.
gameTimer
=
null
;
//현재 게임 플레이 시간 타이머
WordSpace
.
isTimerOn
=
false
;
WordSpace
.
isInvincible
=
false
;
WordSpace
.
pyeongminAnims
=
[];
WordSpace
.
wordGroup
=
[];
...
...
@@ -43,8 +44,8 @@ WordSpace.getSpawnPoint = function(_lenRate)
{
let
lenRate
=
1
;
if
(
typeof
_lenRate
==
'
number
'
)
lenRate
=
_lenRate
;
let
xLen
=
5
50
*
lenRate
;
let
yLen
=
35
0
*
lenRate
;
let
xLen
=
6
50
*
lenRate
;
let
yLen
=
50
0
*
lenRate
;
const
angle
=
Math
.
random
()
*
Math
.
PI
*
2
;
let
_x
=
xLen
*
Math
.
cos
(
angle
)
+
this
.
gravityPoint
.
x
;
let
_y
=
yLen
*
Math
.
sin
(
angle
)
+
this
.
gravityPoint
.
y
;
...
...
@@ -180,6 +181,10 @@ WordSpace.loadImage = function(scene)
{
scene
.
load
.
image
(
'
attackAlert
'
+
i
,
'
assets/placeholder/attackalert
'
+
(
i
+
1
)
+
'
.png
'
);
}
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
scene
.
load
.
image
(
'
item
'
+
i
,
'
assets/placeholder/item
'
+
i
+
'
.png
'
);
}
for
(
let
i
=
2
;
i
<
7
;
i
++
)
{
scene
.
load
.
image
(
'
nameBgr
'
+
i
,
'
assets/placeholder/name
'
+
i
+
'
.png
'
);
...
...
@@ -234,17 +239,27 @@ WordSpace.generateWord =
WordSpace
.
pushWord
(
scene
,
word
,
lenRate
);
return
word
;
},
Attack
:
function
(
scene
,
wordText
,
grade
,
attacker
,
isStrong
,
isCountable
,
lenRate
)
Attack
:
function
(
scene
,
wordText
,
grade
,
attacker
,
attackOption
,
lenRate
)
{
word
=
new
AttackWord
(
wordText
,
grade
,
attacker
,
isStrong
,
isCountable
);
word
=
new
AttackWord
(
wordText
,
grade
,
attacker
,
attackOption
);
WordSpace
.
pushWord
(
scene
,
word
,
lenRate
);
return
word
;
},
Name
:
function
(
scene
,
isStrong
,
newPlayerData
,
lenRate
)
{
if
(
newPlayerData
==
null
)
word
=
new
NameWord
(
WordSpace
.
nameQueue
.
pop
(),
isStrong
);
if
(
newPlayerData
==
null
)
{
if
(
WordSpace
.
nameQueue
.
queue
.
length
==
1
)
return
null
;
let
temp
=
WordSpace
.
nameQueue
.
pop
();
word
=
new
NameWord
(
temp
,
isStrong
);
}
else
word
=
new
NameWord
(
newPlayerData
,
isStrong
);
//word = new NameWord(RoomData.myself, false);
WordSpace
.
pushWord
(
scene
,
word
,
lenRate
);
return
word
;
},
Item
:
function
(
scene
,
itemType
,
lenRate
)
{
word
=
new
ItemWord
(
itemType
);
WordSpace
.
pushWord
(
scene
,
word
,
lenRate
);
return
word
;
}
...
...
@@ -322,13 +337,15 @@ WordSpace.findWord = function(wordText)
else
if
(
wordText
===
'
공격
'
&&
WordSpace
.
attackGauge
.
value
>=
3
&&
WordSpace
.
nameGroup
.
length
>
0
)
// 공격모드 진입.
{
console
.
log
(
'
attack mode
'
);
Input
.
attackOption
=
this
.
attackGauge
.
getAttackOption
();
let
tempAttackOption
=
this
.
attackGauge
.
getAttackOption
();
Input
.
attackOption
.
wordCount
=
tempAttackOption
.
wordCount
;
Input
.
attackOption
.
wordGrade
=
tempAttackOption
.
wordGrade
;
Input
.
maxInput
=
Input
.
attackOption
.
wordCount
;
Input
.
attackMode
=
true
;
WordSpace
.
attackGauge
.
pauseCycle
(
true
);
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
BackGround
.
myCharacter
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
attackWrite
]);
BackGround
.
myCharacter
.
anims
.
msPerFrame
/=
(
4
-
WordSpace
.
attackGauge
.
getAttackOption
()
.
wordGrade
);
RoomData
.
myself
.
playerImage
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
attackWrite
]);
RoomData
.
myself
.
playerImage
.
anims
.
msPerFrame
/=
(
4
-
Input
.
attackOption
.
wordGrade
);
}
else
// 오타 체크
{
...
...
@@ -389,58 +406,36 @@ WordSpace.attack = function(wordText, grade)
let
toSend
=
[];
WordSpace
.
nameGroup
.
forEach
(
function
(
element
)
{
let
target
Id
=
element
.
ownerId
;
let
victim
Id
=
element
.
ownerId
;
let
sendIdx
=
toSend
.
findIndex
(
function
(
element
)
{
return
element
.
target
===
target
Id
;
return
element
.
victim
.
id
===
victim
Id
;
});
if
(
sendIdx
!==
-
1
)
{
toSend
[
sendIdx
].
multiple
++
;
}
if
(
sendIdx
!=
-
1
)
toSend
[
sendIdx
].
multiple
++
;
else
{
let
target
=
RoomData
.
players
.
find
(
function
(
_element
)
{
return
_element
.
id
==
element
.
ownerId
;
});
let
attackData
=
{
roomNum
:
RoomData
.
roomId
,
attacker
:
RoomData
.
myself
,
target
:
element
.
ownerId
,
victim
:
target
,
text
:
wordText
,
grade
:
grade
,
isStrong
:
element
.
isStrong
,
grade
:
grade
,
attackOption
:
{
isStrong
:
element
.
isStrong
,
isCountable
:
true
,
isHeavy
:
Input
.
attackOption
.
isHeavy
,
isDark
:
Input
.
attackOption
.
isDark
},
multiple
:
1
}
toSend
.
push
(
attackData
);
}
element
.
physicsObj
.
destroy
();
element
.
wordObj
.
destroy
();
var
attackPaper
=
ScenesData
.
gameScene
.
add
.
sprite
(
BackGround
.
myCharacter
.
x
,
BackGround
.
myCharacter
.
y
,
'
attackPapaer
'
).
setScale
(
0.5
).
setDepth
(
3
);
attackPaper
.
throwTarget
=
RoomData
.
players
.
find
(
function
(
_element
)
{
return
_element
.
id
==
element
.
ownerId
;
}).
playerImage
;
attackPaper
.
follower
=
{
t
:
0
,
vec
:
new
Phaser
.
Math
.
Vector2
()
};
attackPaper
.
path
=
new
Phaser
.
Curves
.
Spline
([
BackGround
.
myCharacter
.
x
,
BackGround
.
myCharacter
.
y
,
(
BackGround
.
myCharacter
.
x
+
attackPaper
.
throwTarget
.
x
)
/
2
,
Math
.
min
(
BackGround
.
myCharacter
.
y
,
attackPaper
.
throwTarget
.
y
)
-
100
,
attackPaper
.
throwTarget
.
x
,
attackPaper
.
throwTarget
.
y
-
10
]);
ScenesData
.
gameScene
.
tweens
.
add
({
targets
:
attackPaper
.
follower
,
t
:
1
,
ease
:
'
Linear
'
,
duration
:
4000
,
repeat
:
0
,
onComplete
:
function
()
{
attackPaper
.
destroy
();
WordSpace
.
attackPaperGroup
=
[];
}
});
attackPaper
.
moveObject
=
function
(
obj
)
{
obj
.
path
.
getPoint
(
obj
.
follower
.
t
,
obj
.
follower
.
vec
);
obj
.
setPosition
(
obj
.
follower
.
vec
.
x
,
obj
.
follower
.
vec
.
y
);
}
WordSpace
.
attackPaperGroup
.
push
(
attackPaper
);
});
toSend
.
forEach
(
function
(
element
)
{
...
...
@@ -453,7 +448,9 @@ WordSpace.attack = function(wordText, grade)
WordSpace
.
attackGauge
.
resetValue
();
WordSpace
.
setPlayerTyping
.
add
(
wordText
);
BackGround
.
myCharacter
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
throw
]);
RoomData
.
myself
.
playerImage
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
throw
]);
Input
.
attackOption
.
isHeavy
=
false
;
Input
.
attackOption
.
isDark
=
false
;
}
else
WordSpace
.
attackGauge
.
cutValue
(
0.3
);
Input
.
maxInput
=
6
;
...
...
@@ -461,6 +458,37 @@ WordSpace.attack = function(wordText, grade)
WordSpace
.
attackGauge
.
pauseCycle
(
false
);
}
WordSpace
.
makeAttackPaper
=
function
(
scene
,
attackFrom
,
attackTo
,
multiple
)
{
console
.
log
(
multiple
);
var
attackPaper
=
scene
.
add
.
sprite
(
attackFrom
.
x
,
attackFrom
.
y
,
'
attackPapaer
'
).
setScale
(
0.5
*
multiple
).
setDepth
(
3
);
attackPaper
.
throwTarget
=
attackTo
;
attackPaper
.
follower
=
{
t
:
0
,
vec
:
new
Phaser
.
Math
.
Vector2
()
};
attackPaper
.
path
=
new
Phaser
.
Curves
.
Spline
([
attackFrom
.
x
,
attackFrom
.
y
,
(
attackFrom
.
x
+
attackPaper
.
throwTarget
.
x
)
/
2
,
Math
.
min
(
attackFrom
.
y
,
attackPaper
.
throwTarget
.
y
)
-
100
,
attackPaper
.
throwTarget
.
x
,
attackPaper
.
throwTarget
.
y
-
10
]);
scene
.
tweens
.
add
({
targets
:
attackPaper
.
follower
,
t
:
1
,
ease
:
'
Linear
'
,
duration
:
4000
,
repeat
:
0
,
onComplete
:
function
()
{
attackPaper
.
destroy
();
WordSpace
.
attackPaperGroup
=
[];
}
});
attackPaper
.
moveObject
=
function
(
obj
)
{
obj
.
path
.
getPoint
(
obj
.
follower
.
t
,
obj
.
follower
.
vec
);
obj
.
setPosition
(
obj
.
follower
.
vec
.
x
,
obj
.
follower
.
vec
.
y
);
obj
.
angle
=
720
*
obj
.
follower
.
t
;
}
WordSpace
.
attackPaperGroup
.
push
(
attackPaper
);
}
WordSpace
.
nameQueue
=
{
queue
:
[],
...
...
@@ -468,12 +496,12 @@ WordSpace.nameQueue =
{
let
tempQueue
=
[];
RoomData
.
players
.
forEach
(
function
(
element
){
tempQueue
.
push
(
element
.
index
)
tempQueue
.
push
(
element
.
index
)
;
})
tempQueue
.
sort
(
function
(){
return
0.5
-
Math
.
random
()}
);
Phaser
.
Utils
.
Array
.
Shuffle
(
tempQueue
);
tempQueue
.
forEach
(
function
(
element
)
{
if
(
RoomData
.
players
[
element
].
id
!=
PlayerData
.
id
&&
RoomData
.
players
[
element
].
isAlive
)
if
(
RoomData
.
players
[
element
].
id
!=
PlayerData
.
id
&&
RoomData
.
players
[
element
].
isAlive
&&
WordSpace
.
nameQueue
.
getCount
(
element
)
<
3
)
WordSpace
.
nameQueue
.
queue
.
push
(
element
);
});
},
...
...
@@ -481,9 +509,17 @@ WordSpace.nameQueue =
{
let
tempElement
=
WordSpace
.
nameQueue
.
queue
.
shift
();
if
(
WordSpace
.
nameQueue
.
queue
.
length
<=
RoomData
.
aliveCount
)
this
.
shuffle
();
if
(
!
RoomData
.
players
[
tempElement
].
isAlive
)
return
WordSpace
.
nameQueue
.
pop
();
if
(
!
RoomData
.
players
[
tempElement
].
isAlive
&&
WordSpace
.
nameQueue
.
getCount
(
tempElement
)
<
3
)
return
WordSpace
.
nameQueue
.
pop
();
else
return
RoomData
.
players
[
tempElement
];
},
getCount
:
function
(
player
)
{
let
i
=
0
;
WordSpace
.
nameGroup
.
forEach
(
function
(
element
){
if
(
element
.
id
==
player
.
id
)
i
++
;
})
return
i
;
},
initiate
:
function
()
{
this
.
shuffle
();
...
...
js/main.js
View file @
f306f93f
...
...
@@ -32,4 +32,8 @@ var RoomData = RoomData || {};
RoomData
.
roomId
=
-
1
;
RoomData
.
myself
=
null
;
RoomData
.
players
=
null
;
RoomData
.
aliveCount
=
-
1
;
\ No newline at end of file
RoomData
.
aliveCount
=
-
1
;
RoomData
.
findPlayer
=
function
(
player
)
{
return
RoomData
.
players
.
find
(
function
(
element
){
return
element
.
id
==
player
.
id
;
});
}
\ No newline at end of file
server.js
View file @
f306f93f
...
...
@@ -94,12 +94,12 @@ io.on('connection', function(socket)
socket
.
on
(
'
attack
'
,
function
(
msg
)
{
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
target
,
'
attacked
'
,
msg
);
socket
.
playerData
.
currentRoom
.
announceToRoom
(
'
attack
'
,
{
attackerId
:
msg
.
attacker
.
id
,
targetId
:
msg
.
target
});
socket
.
playerData
.
currentRoom
.
announceToTarget
(
msg
.
victim
.
id
,
'
attacked
'
,
msg
);
socket
.
playerData
.
currentRoom
.
announceToRoom
(
'
someoneAttacked
'
,
{
attacker
:
msg
.
attacker
,
victim
:
msg
.
victim
,
multiple
:
msg
.
multiple
});
//console.log('attack ' + msg.target + ' by ' + msg.attacker.id + ' with ' + msg.text);
setTimeout
(
function
()
{
let
target
=
GameServer
.
findPlayerSocket
(
msg
.
target
);
let
target
=
GameServer
.
findPlayerSocket
(
msg
.
victim
.
id
);
if
(
target
!=
null
)
{
let
dataToPush
=
...
...
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