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
c6744745
Commit
c6744745
authored
Jul 26, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
단어 생성 방식 수정 및 instantiate 함수 각 클래스 별로 따로 구분지어놓음
parent
71d38ba3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
169 additions
and
118 deletions
+169
-118
WordObject.js
js/WordObject.js
+165
-118
WordSpace.js
js/WordSpace.js
+4
-0
No files found.
js/WordObject.js
View file @
c6744745
...
@@ -12,31 +12,15 @@ class WordObject
...
@@ -12,31 +12,15 @@ class WordObject
this
.
isNameWord
=
isNameWord
;
this
.
isNameWord
=
isNameWord
;
}
}
instantiate
(
scene
,
lenRate
)
instantiate
(
scene
,
spriteName
,
textColor
,
lenRate
)
{
{
let
p
=
[{
x
:
3
,
y
:
1.05
},
{
x
:
20
,
y
:
1.85
}];
let
p
=
[{
x
:
3
,
y
:
1.05
},
{
x
:
20
,
y
:
1.85
}];
this
.
scale
=
((
p
[
1
].
y
-
p
[
0
].
y
)
/
(
p
[
1
].
x
-
p
[
0
].
x
))
*
(
this
.
wordWeight
-
p
[
0
].
x
)
+
p
[
0
].
y
;
this
.
scale
=
((
p
[
1
].
y
-
p
[
0
].
y
)
/
(
p
[
1
].
x
-
p
[
0
].
x
))
*
(
this
.
wordWeight
-
p
[
0
].
x
)
+
p
[
0
].
y
;
this
.
fontScale
=
25
;
this
.
fontScale
=
25
;
var
random
=
WordSpace
.
getSpawnPoint
(
lenRate
);
var
random
=
WordSpace
.
getSpawnPoint
(
lenRate
);
if
(
!
this
.
isNameWord
)
this
.
physicsObj
=
scene
.
physics
.
add
.
sprite
(
random
.
x
,
random
.
y
,
spriteName
).
setMass
(
this
.
wordWeight
*
10
).
setScale
(
this
.
scale
)
{
.
setFrictionX
(
0
).
setFrictionY
(
0
).
setBounce
(
0.5
);
this
.
physicsObj
=
scene
.
physics
.
add
.
sprite
(
random
.
x
,
random
.
y
,
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
))
.
setMass
(
this
.
wordWeight
*
10
)
.
setScale
(
this
.
scale
)
.
setFrictionX
(
0
)
.
setFrictionY
(
0
)
.
setBounce
(
0.5
);
}
else
{
this
.
physicsObj
=
scene
.
physics
.
add
.
sprite
(
random
.
x
,
random
.
y
,
(
this
.
isStrong
?
'
strongBgr
'
:
'
nameBgr
'
)
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
))
.
setMass
(
this
.
wordWeight
*
10
)
.
setScale
(
this
.
scale
)
.
setFrictionX
(
0
)
.
setFrictionY
(
0
)
.
setBounce
(
0.5
);
}
this
.
physicsObj
.
wordCollider
=
null
;
this
.
physicsObj
.
wordCollider
=
null
;
let
dist
=
Phaser
.
Math
.
Distance
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
let
dist
=
Phaser
.
Math
.
Distance
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
let
angle
=
Phaser
.
Math
.
Angle
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
let
angle
=
Phaser
.
Math
.
Angle
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
...
@@ -51,8 +35,7 @@ class WordObject
...
@@ -51,8 +35,7 @@ class WordObject
fontFamily
:
'
"궁서", 궁서체, serif
'
,
fontFamily
:
'
"궁서", 궁서체, serif
'
,
//fontStyle: (this.wordWeight > 5 ? 'bold' : '')
//fontStyle: (this.wordWeight > 5 ? 'bold' : '')
});
});
if
(
!
this
.
isNameWord
)
this
.
wordObj
.
setColor
(
'
#000000
'
).
setOrigin
(
0.5
,
0.5
);
this
.
wordObj
.
setColor
(
textColor
).
setOrigin
(
0.5
,
0.5
);
else
this
.
wordObj
.
setColor
(
'
#ffffff
'
).
setOrigin
(
0.45
,
0.5
);
this
.
createdTime
=
WordSpace
.
gameTimer
.
now
;
this
.
createdTime
=
WordSpace
.
gameTimer
.
now
;
WordSpace
.
totalWeight
+=
this
.
wordWeight
;
WordSpace
.
totalWeight
+=
this
.
wordWeight
;
WordSpace
.
totalWordNum
+=
1
;
WordSpace
.
totalWordNum
+=
1
;
...
@@ -75,11 +58,6 @@ class WordObject
...
@@ -75,11 +58,6 @@ class WordObject
setTimeout
(
function
()
{
setTimeout
(
function
()
{
breakAnim
.
destroy
();
breakAnim
.
destroy
();
},
200
);
},
200
);
if
(
!
this
.
isNameWord
)
{
this
.
wordObj
.
destroy
();
this
.
physicsObj
.
destroy
();
}
RoomData
.
myself
.
playerImage
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
write
]);
RoomData
.
myself
.
playerImage
.
play
(
WordSpace
.
pyeongminAnims
[
Enums
.
characterAnim
.
write
]);
}
}
...
@@ -121,7 +99,16 @@ class NormalWord extends WordObject
...
@@ -121,7 +99,16 @@ class NormalWord extends WordObject
{
{
super
(
text
);
super
(
text
);
}
}
destroy
()
instantiate
(
scene
,
lenRate
)
{
let
spriteName
=
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
);
let
textColor
=
'
#000000
'
super
.
instantiate
(
scene
,
spriteName
,
textColor
,
lenRate
);
}
destroy
(
isNormallyRemoved
=
true
)
{
super
.
destroy
();
if
(
isNormallyRemoved
)
{
{
switch
(
this
.
wordGrade
)
switch
(
this
.
wordGrade
)
{
{
...
@@ -131,7 +118,9 @@ class NormalWord extends WordObject
...
@@ -131,7 +118,9 @@ class NormalWord extends WordObject
case
3
:
WordSpace
.
attackGauge
.
add
(
0.5
);
break
;
case
3
:
WordSpace
.
attackGauge
.
add
(
0.5
);
break
;
default
:
console
.
log
(
'
[ERR] wrong grade of word
'
);
break
;
default
:
console
.
log
(
'
[ERR] wrong grade of word
'
);
break
;
}
}
super
.
destroy
();
this
.
wordObj
.
destroy
();
this
.
physicsObj
.
destroy
();
}
}
}
}
}
...
@@ -155,7 +144,9 @@ class AttackWord extends WordObject
...
@@ -155,7 +144,9 @@ class AttackWord extends WordObject
}
}
instantiate
(
scene
,
lenRate
)
instantiate
(
scene
,
lenRate
)
{
{
super
.
instantiate
(
scene
,
lenRate
);
let
spriteName
=
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
);
let
textColor
=
'
#000000
'
super
.
instantiate
(
scene
,
spriteName
,
textColor
,
lenRate
);
this
.
maskBackground
=
scene
.
physics
.
add
.
sprite
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
))
this
.
maskBackground
=
scene
.
physics
.
add
.
sprite
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
))
.
setTint
(
Phaser
.
Display
.
Color
.
GetColor
(
120
,
120
,
120
)).
setScale
(
this
.
scale
);
.
setTint
(
Phaser
.
Display
.
Color
.
GetColor
(
120
,
120
,
120
)).
setScale
(
this
.
scale
);
this
.
maskBackground
.
alpha
=
this
.
isDark
?
1
:
0.5
;
this
.
maskBackground
.
alpha
=
this
.
isDark
?
1
:
0.5
;
...
@@ -189,7 +180,10 @@ class AttackWord extends WordObject
...
@@ -189,7 +180,10 @@ class AttackWord extends WordObject
else
if
(
this
.
maskBackground
!=
null
)
this
.
maskBackground
.
destroy
();
else
if
(
this
.
maskBackground
!=
null
)
this
.
maskBackground
.
destroy
();
}
}
destroy
()
destroy
(
isNormallyRemoved
=
true
)
{
super
.
destroy
();
if
(
isNormallyRemoved
)
{
{
switch
(
this
.
wordGrade
)
switch
(
this
.
wordGrade
)
{
{
...
@@ -221,8 +215,10 @@ class AttackWord extends WordObject
...
@@ -221,8 +215,10 @@ class AttackWord extends WordObject
}
}
socket
.
emit
(
'
attack
'
,
attackData
);
socket
.
emit
(
'
attack
'
,
attackData
);
}
}
}
if
(
this
.
maskBackground
!=
null
)
this
.
maskBackground
.
destroy
();
if
(
this
.
maskBackground
!=
null
)
this
.
maskBackground
.
destroy
();
super
.
destroy
();
this
.
wordObj
.
destroy
();
this
.
physicsObj
.
destroy
();
}
}
}
}
...
@@ -237,6 +233,13 @@ class NameWord extends WordObject
...
@@ -237,6 +233,13 @@ class NameWord extends WordObject
this
.
isActive
=
true
;
this
.
isActive
=
true
;
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
}
}
instantiate
(
scene
,
lenRate
)
{
let
spriteName
=
(
this
.
isStrong
?
'
strongBgr
'
:
'
nameBgr
'
)
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
)
let
textColor
=
'
#ffffff
'
super
.
instantiate
(
scene
,
spriteName
,
textColor
,
lenRate
);
this
.
wordObj
.
setOrigin
(
0.45
,
0.5
);
}
attract
()
attract
()
{
{
if
(
this
.
isActive
)
super
.
attract
();
if
(
this
.
isActive
)
super
.
attract
();
...
@@ -258,9 +261,11 @@ class NameWord extends WordObject
...
@@ -258,9 +261,11 @@ class NameWord extends WordObject
}
}
}
}
}
}
destroy
()
destroy
(
isNormallyRemoved
=
true
)
{
{
super
.
destroy
();
super
.
destroy
();
if
(
isNormallyRemoved
)
{
ScenesData
.
gameScene
.
physics
.
world
.
removeCollider
(
this
.
physicsObj
.
wordCollider
);
ScenesData
.
gameScene
.
physics
.
world
.
removeCollider
(
this
.
physicsObj
.
wordCollider
);
WordSpace
.
wordGroup
.
forEach
(
function
(
element
)
WordSpace
.
wordGroup
.
forEach
(
function
(
element
)
{
{
...
@@ -293,21 +298,60 @@ class NameWord extends WordObject
...
@@ -293,21 +298,60 @@ class NameWord extends WordObject
graphics.lineStyle(2, 0xffffff, 1);
graphics.lineStyle(2, 0xffffff, 1);
this.path.draw(graphics);*/
this.path.draw(graphics);*/
}
}
}
}
}
class
ItemWord
extends
WordObject
class
ItemWord
extends
WordObject
{
{
constructor
(
_itemType
)
constructor
(
_itemType
)
{
{
super
(
_itemType
,
false
);
super
(
_itemType
);
this
.
wordWeight
=
2
;
this
.
wordWeight
=
2
;
this
.
itemType
=
_itemType
this
.
itemType
=
_itemType
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
}
}
destroy
()
instantiate
(
scene
,
lenRate
)
{
let
spriteName
=
null
;
let
textColor
=
null
;
switch
(
this
.
itemType
)
{
case
Enums
.
item
.
invincible
:
spriteName
=
'
item0
'
;
textColor
=
'
#23D9B7
'
break
;
case
Enums
.
item
.
nameList
:
spriteName
=
'
item1
'
;
textColor
=
'
#FFB28F
'
break
;
case
Enums
.
item
.
charge
:
spriteName
=
'
item2
'
;
textColor
=
'
#FF9515
'
break
;
case
Enums
.
item
.
clean
:
spriteName
=
'
item3
'
;
textColor
=
'
#263387
'
break
;
case
Enums
.
item
.
heavy
:
spriteName
=
'
item4
'
;
textColor
=
'
#dddddd
'
break
;
case
Enums
.
item
.
dark
:
spriteName
=
'
item5
'
;
textColor
=
'
#dddd70
'
break
;
default
:
console
.
log
(
"
Item type is inappropriate. Item type :
"
+
this
.
itemType
);
break
;
}
super
.
instantiate
(
scene
,
spriteName
,
textColor
,
lenRate
);
}
destroy
(
isNormallyRemoved
=
true
)
{
{
WordSpace
.
attackGauge
.
add
(
0.5
);
super
.
destroy
();
super
.
destroy
();
if
(
isNormallyRemoved
)
{
WordSpace
.
attackGauge
.
add
(
0.5
);
switch
(
this
.
itemType
)
switch
(
this
.
itemType
)
{
{
case
Enums
.
item
.
invincible
:
case
Enums
.
item
.
invincible
:
...
@@ -336,7 +380,7 @@ class ItemWord extends WordObject
...
@@ -336,7 +380,7 @@ class ItemWord extends WordObject
break
;
break
;
case
Enums
.
item
.
clean
:
case
Enums
.
item
.
clean
:
let
tempLenth
=
WordSpace
.
wordGroup
.
length
*
0.3
;
let
tempLenth
=
WordSpace
.
wordGroup
.
length
*
0.3
;
for
(
let
i
=
0
;
i
<
tempLenth
;
i
++
)
WordSpace
.
wordGroup
[
i
].
destroy
(
);
for
(
let
i
=
0
;
i
<
tempLenth
;
i
++
)
WordSpace
.
wordGroup
[
i
].
destroy
(
false
);
break
;
break
;
case
Enums
.
item
.
heavy
:
case
Enums
.
item
.
heavy
:
Input
.
attackOption
.
isHeavy
=
true
;
Input
.
attackOption
.
isHeavy
=
true
;
...
@@ -349,4 +393,7 @@ class ItemWord extends WordObject
...
@@ -349,4 +393,7 @@ class ItemWord extends WordObject
break
;
break
;
}
}
}
}
this
.
wordObj
.
destroy
();
this
.
physicsObj
.
destroy
();
}
}
}
\ No newline at end of file
js/WordSpace.js
View file @
c6744745
...
@@ -181,6 +181,10 @@ WordSpace.loadImage = function(scene)
...
@@ -181,6 +181,10 @@ WordSpace.loadImage = function(scene)
{
{
scene
.
load
.
image
(
'
attackAlert
'
+
i
,
'
assets/placeholder/attackalert
'
+
(
i
+
1
)
+
'
.png
'
);
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
++
)
for
(
let
i
=
2
;
i
<
7
;
i
++
)
{
{
scene
.
load
.
image
(
'
nameBgr
'
+
i
,
'
assets/placeholder/name
'
+
i
+
'
.png
'
);
scene
.
load
.
image
(
'
nameBgr
'
+
i
,
'
assets/placeholder/name
'
+
i
+
'
.png
'
);
...
...
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