Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
L4R4
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
L4R4
Commits
145fbcf9
Commit
145fbcf9
authored
Nov 10, 2022
by
杨一航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v1.0
parent
174d6104
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
3711 additions
and
1291 deletions
+3711
-1291
coin_overturn_ske.json
assets/L4R4/animation/coin_overturn_ske.json
+1
-0
coin_overturn_ske.json.meta
assets/L4R4/animation/coin_overturn_ske.json.meta
+5
-0
coin_overturn_tex.json
assets/L4R4/animation/coin_overturn_tex.json
+1
-0
coin_overturn_tex.json.meta
assets/L4R4/animation/coin_overturn_tex.json.meta
+5
-0
coin_overturn_tex.png
assets/L4R4/animation/coin_overturn_tex.png
+0
-0
coin_overturn_tex.png.meta
assets/L4R4/animation/coin_overturn_tex.png.meta
+36
-0
L4R4.fire
assets/L4R4/scene/L4R4.fire
+3318
-1092
L4R4.ts
assets/L4R4/scene/L4R4.ts
+169
-140
Server.ts
assets/L4R4/script/Server.ts
+102
-59
红色方标记.png
assets/L4R4/texture/红色方标记.png
+0
-0
红色方标记.png.meta
assets/L4R4/texture/红色方标记.png.meta
+37
-0
蓝色方标记.png
assets/L4R4/texture/蓝色方标记.png
+0
-0
蓝色方标记.png.meta
assets/L4R4/texture/蓝色方标记.png.meta
+37
-0
No files found.
assets/L4R4/animation/coin_overturn_ske.json
0 → 100755
View file @
145fbcf9
{
"frameRate"
:
24
,
"name"
:
"coin_overturn"
,
"version"
:
"5.5"
,
"compatibleVersion"
:
"5.5"
,
"armature"
:[{
"type"
:
"Armature"
,
"frameRate"
:
24
,
"name"
:
"Armature"
,
"aabb"
:{
"x"
:
-119
,
"y"
:
-85.5
,
"width"
:
233
,
"height"
:
178
},
"bone"
:[{
"name"
:
"root"
},{
"length"
:
43
,
"name"
:
"1"
,
"parent"
:
"root"
,
"transform"
:{
"x"
:
-1.25
,
"y"
:
-4.45
,
"skX"
:
-86.688
,
"skY"
:
-86.688
}}],
"slot"
:[{
"name"
:
"1"
,
"parent"
:
"1"
}],
"skin"
:[{
"slot"
:[{
"name"
:
"1"
,
"display"
:[{
"name"
:
"coin_overturn/1"
,
"transform"
:{
"x"
:
-8.01
,
"y"
:
-0.79
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/2"
,
"transform"
:{
"x"
:
-8.01
,
"y"
:
-0.79
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/3"
,
"transform"
:{
"x"
:
-5.4
,
"y"
:
1.06
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/4"
,
"transform"
:{
"x"
:
-4.96
,
"y"
:
0.04
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/5"
,
"transform"
:{
"x"
:
-6.01
,
"y"
:
-0.9
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/6"
,
"transform"
:{
"x"
:
-8.01
,
"y"
:
-0.79
,
"skX"
:
86.69
,
"skY"
:
86.69
}},{
"name"
:
"coin_overturn/7"
,
"transform"
:{
"x"
:
-5.01
,
"y"
:
-0.96
,
"skX"
:
86.69
,
"skY"
:
86.69
}}]}]}],
"animation"
:[{
"duration"
:
14
,
"playTimes"
:
0
,
"name"
:
"normal"
,
"slot"
:[{
"name"
:
"1"
,
"displayFrame"
:[{},{
"value"
:
1
},{
"value"
:
2
},{
"value"
:
3
},{
"value"
:
4
},{
"value"
:
5
},{
"value"
:
6
},{},{
"value"
:
1
},{
"value"
:
2
},{
"value"
:
3
},{
"value"
:
4
},{
"value"
:
5
},{
"value"
:
6
},{
"duration"
:
0
}]}]}],
"defaultActions"
:[{
"gotoAndPlay"
:
"normal"
}]}]}
\ No newline at end of file
assets/L4R4/animation/coin_overturn_ske.json.meta
0 → 100644
View file @
145fbcf9
{
"ver": "1.0.1",
"uuid": "2b6b7708-44d5-4679-9880-777f48407ec1",
"subMetas": {}
}
\ No newline at end of file
assets/L4R4/animation/coin_overturn_tex.json
0 → 100755
View file @
145fbcf9
{
"width"
:
512
,
"SubTexture"
:[{
"width"
:
233
,
"y"
:
1
,
"height"
:
178
,
"name"
:
"coin_overturn/7"
,
"x"
:
1
},{
"width"
:
253
,
"y"
:
181
,
"height"
:
98
,
"name"
:
"coin_overturn/2"
,
"x"
:
1
},{
"width"
:
257
,
"y"
:
365
,
"height"
:
59
,
"name"
:
"coin_overturn/3"
,
"x"
:
1
},{
"width"
:
253
,
"y"
:
181
,
"height"
:
98
,
"name"
:
"coin_overturn/6"
,
"x"
:
256
},{
"width"
:
253
,
"y"
:
281
,
"height"
:
82
,
"name"
:
"coin_overturn/5"
,
"x"
:
1
},{
"width"
:
233
,
"y"
:
1
,
"height"
:
178
,
"name"
:
"coin_overturn/1"
,
"x"
:
236
},{
"width"
:
255
,
"y"
:
281
,
"height"
:
58
,
"name"
:
"coin_overturn/4"
,
"x"
:
256
}],
"height"
:
512
,
"name"
:
"coin_overturn"
,
"imagePath"
:
"coin_overturn_tex.png"
}
\ No newline at end of file
assets/L4R4/animation/coin_overturn_tex.json.meta
0 → 100644
View file @
145fbcf9
{
"ver": "1.0.1",
"uuid": "d2e64191-0d23-44ba-bd59-24a0b80c6525",
"subMetas": {}
}
\ No newline at end of file
assets/L4R4/animation/coin_overturn_tex.png
0 → 100755
View file @
145fbcf9
318 KB
assets/L4R4/animation/coin_overturn_tex.png.meta
0 → 100644
View file @
145fbcf9
{
"ver": "2.3.5",
"uuid": "f48beade-3501-49c9-87c5-0657f20ff2f4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 512,
"platformSettings": {},
"subMetas": {
"coin_overturn_tex": {
"ver": "1.0.4",
"uuid": "907db0c0-a56c-4168-aa9f-6c5630628187",
"rawTextureUuid": "f48beade-3501-49c9-87c5-0657f20ff2f4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 43.5,
"trimX": 1,
"trimY": 1,
"width": 510,
"height": 423,
"rawWidth": 512,
"rawHeight": 512,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/L4R4/scene/L4R4.fire
View file @
145fbcf9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
assets/L4R4/scene/L4R4.ts
View file @
145fbcf9
import
{
delayCall
}
from
"
../../../form/src/app/play/Unit
"
;
import
LoadingLayer
from
"
../script/BoardGame_yyh_LoadingLayer
"
;
import
LoadingLayer
from
"
../script/BoardGame_yyh_LoadingLayer
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
...
@@ -17,6 +18,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -17,6 +18,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
cat
=
null
cat
=
null
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
clockNode
=
null
@
property
(
cc
.
Node
)
cover
=
null
cover
=
null
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
recordCat
=
null
recordCat
=
null
...
@@ -25,7 +28,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -25,7 +28,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
_isRolling
:
any
;
private
_isRolling
:
any
;
_randomList
=
[
"
1
"
,
"
2
"
,
"
3
"
,
"
4
"
,
"
5
"
,
"
6
"
]
_randomList
=
[
];
excellent
:
any
;
excellent
:
any
;
_nowData
:
any
;
_nowData
:
any
;
private
_myData
:
any
;
private
_myData
:
any
;
...
@@ -33,9 +36,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -33,9 +36,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
_playingAudio
:
boolean
;
private
_playingAudio
:
boolean
;
private
_canClick
:
any
;
private
_canClick
:
any
;
private
_recordBefore
:
boolean
=
false
;
private
_recordBefore
:
boolean
=
false
;
private
_coinNode
:
cc
.
Node
;
private
_springNode
:
cc
.
Node
;
private
_leftTime
:
number
;
private
_redLb
:
cc
.
Label
;
private
_blueLb
:
cc
.
Label
;
private
_redDot
:
cc
.
Node
;
private
_blueDot
:
cc
.
Node
;
private
_lastIndex
:
any
;
addPreloadImage
()
{
addPreloadImage
()
{
...
@@ -65,13 +73,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -65,13 +73,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
_status
=
{
_status
=
{
state
:
-
1
,
// -1:未开始 0 准备阶段 1 roll 2 判定
state
:
0
,
// -1:未开始 0 准备阶段 1 roll 2 判定
Red
:
-
1
,
Red
:
0
,
Blue
:
-
1
,
Blue
:
0
,
RedTime
:
0
,
BlueTime
:
0
,
step
:
0
,
step
:
0
,
current
:
"
Red
"
,
current
:
"
Red
"
,
jump
:
null
,
time
:
0
back
:
null
,
};
};
playerId
;
playerId
;
isRoomOwner
;
isRoomOwner
;
...
@@ -96,10 +105,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -96,10 +105,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
log
(
"
房主
"
);
this
.
log
(
"
房主
"
);
this
.
isRoomOwner
=
true
;
this
.
isRoomOwner
=
true
;
this
.
server
=
new
GameServer
(
2
,
this
.
networkHelper
);
this
.
server
=
new
GameServer
(
2
,
this
.
networkHelper
);
this
.
server
.
jumpList
=
this
.
getJumpList
();
this
.
server
.
randomList
=
this
.
_randomList
;
this
.
server
.
randomList
=
this
.
_randomList
;
this
.
server
.
TotalStep
=
this
.
_cardList
.
length
;
this
.
server
.
TotalStep
=
this
.
_cardList
.
length
;
this
.
server
.
forceWrongIndexList
=
this
.
getForceWrongList
();
await
this
.
networkHelper
.
startFrameSync
();
await
this
.
networkHelper
.
startFrameSync
();
this
.
server
.
addPlayer
({
this
.
server
.
addPlayer
({
uuid
:
this
.
playerId
,
uuid
:
this
.
playerId
,
...
@@ -140,76 +148,76 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -140,76 +148,76 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
cardDatas
=
[
let
cardDatas
=
[
{
{
id
:
0
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cage
"
,
url
:
""
,
id
:
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cage
"
,
url
:
""
,
},
},
{
{
id
:
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cellphone
"
,
url
:
""
,
id
:
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cellphone
"
,
url
:
""
,
},
},
{
{
id
:
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cheese
"
,
url
:
""
,
id
:
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
cheese
"
,
url
:
""
,
},
},
{
{
id
:
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
city
"
,
url
:
""
,
id
:
4
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
city
"
,
url
:
""
,
},
},
{
{
id
:
4
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
desk
"
,
url
:
""
,
id
:
5
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
desk
"
,
url
:
""
,
},
},
{
{
id
:
5
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
giant
"
,
url
:
""
,
id
:
6
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
giant
"
,
url
:
""
,
},
},
{
{
id
:
6
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
giraffe
"
,
url
:
""
,
id
:
7
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
giraffe
"
,
url
:
""
,
},
},
{
{
id
:
7
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
icecream
"
,
url
:
""
,
id
:
8
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
icecream
"
,
url
:
""
,
},
},
{
{
id
:
8
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
jeans
"
,
url
:
""
,
id
:
9
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
jeans
"
,
url
:
""
,
},
},
{
{
id
:
9
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
legs
"
,
url
:
""
,
id
:
10
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
legs
"
,
url
:
""
,
},
},
{
{
id
:
1
0
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
orange
"
,
url
:
""
,
id
:
1
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
orange
"
,
url
:
""
,
},
},
{
{
id
:
1
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
rice
"
,
url
:
""
,
id
:
1
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
rice
"
,
url
:
""
,
},
},
{
{
id
:
1
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
rose
"
,
url
:
""
,
id
:
1
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
rose
"
,
url
:
""
,
},
},
{
{
id
:
1
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
scale
"
,
url
:
""
,
id
:
1
4
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
scale
"
,
url
:
""
,
},
},
{
{
id
:
1
4
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
school
"
,
url
:
""
,
id
:
1
5
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
school
"
,
url
:
""
,
},
},
{
{
id
:
1
5
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
skunk
"
,
url
:
""
,
id
:
1
6
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
skunk
"
,
url
:
""
,
},
},
{
{
id
:
1
6
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
splash
"
,
url
:
""
,
id
:
1
7
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
splash
"
,
url
:
""
,
},
},
{
{
id
:
1
7
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
splint
"
,
url
:
""
,
id
:
1
8
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
splint
"
,
url
:
""
,
},
},
{
{
id
:
1
8
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
spray
"
,
url
:
""
,
id
:
1
9
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
spray
"
,
url
:
""
,
},
},
{
{
id
:
19
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
spring
"
,
url
:
""
,
id
:
20
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
spring
"
,
url
:
""
,
},
},
{
{
id
:
2
0
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
square
"
,
url
:
""
,
id
:
2
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
square
"
,
url
:
""
,
},
},
{
{
id
:
2
1
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
squid
"
,
url
:
""
,
id
:
2
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
squid
"
,
url
:
""
,
},
},
{
{
id
:
2
2
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
string
"
,
url
:
""
,
id
:
2
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
string
"
,
url
:
""
,
},
},
{
{
id
:
2
3
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
strong
"
,
url
:
""
,
id
:
2
4
,
rJumpId
:
null
,
wJumpId
:
null
,
word
:
"
strong
"
,
url
:
""
,
},
},
]
]
this
.
_cardList
=
cc
.
find
(
"
Canvas/road/root/wordCards
"
).
children
;
this
.
_cardList
=
cc
.
find
(
"
Canvas/road/root/wordCards
"
).
children
;
...
@@ -218,6 +226,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -218,6 +226,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
data
=
list
[
i
];
let
data
=
list
[
i
];
let
com
=
this
.
_cardList
[
i
].
addComponent
(
BoardCardItem
);
let
com
=
this
.
_cardList
[
i
].
addComponent
(
BoardCardItem
);
com
.
cardData
=
data
;
com
.
cardData
=
data
;
this
.
_randomList
.
push
(
i
);
}
}
}
}
...
@@ -266,9 +275,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -266,9 +275,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
endRoot
=
cc
.
find
(
"
Canvas/endRoot
"
)
const
endRoot
=
cc
.
find
(
"
Canvas/endRoot
"
)
endRoot
.
scale
=
this
.
_mapScaleMax
;
endRoot
.
scale
=
this
.
_mapScaleMax
;
// const bg1 = cc.find("Canvas/bg1")
// bg1.width = cc.winSize.width;
this
.
_redDot
=
cc
.
find
(
"
Canvas/redDot
"
);
// bg1.height = cc.winSize.height;
this
.
_redDot
.
active
=
false
;
this
.
_blueDot
=
cc
.
find
(
"
Canvas/blueDot
"
);
this
.
_blueDot
.
active
=
false
;
this
.
_coinNode
=
cc
.
find
(
"
Canvas/road/board/coinRoot
"
);
this
.
_coinNode
.
getChildByName
(
"
coinA
"
).
active
=
true
;
this
.
_coinNode
.
getChildByName
(
"
coinB
"
).
active
=
false
;
const
blueHead
=
cc
.
find
(
"
Canvas/road/blueHead
"
);
const
redHead
=
cc
.
find
(
"
Canvas/road/redHead
"
);
this
.
_redLb
=
redHead
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
)
this
.
_blueLb
=
blueHead
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
)
this
.
_springNode
=
cc
.
find
(
"
Canvas/road/board/btn
"
);
this
.
cat
.
getComponent
(
dragonBones
.
ArmatureDisplay
).
addEventListener
(
dragonBones
.
EventObject
.
COMPLETE
,
()
=>
{
this
.
cat
.
getComponent
(
dragonBones
.
ArmatureDisplay
).
addEventListener
(
dragonBones
.
EventObject
.
COMPLETE
,
()
=>
{
...
@@ -325,8 +348,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -325,8 +348,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
switch
(
state
)
{
switch
(
state
)
{
case
-
1
:
case
-
1
:
break
;
break
;
case
0
:
case
0
:
if
(
this
.
isMySide
)
{
if
(
this
.
isMySide
)
{
...
@@ -342,7 +363,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -342,7 +363,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
})
}
}
// this.rollPiece();
this
.
_redLb
.
string
=
`
${
this
.
_status
.
Red
}
/10`
;
this
.
_blueLb
.
string
=
`
${
this
.
_status
.
Blue
}
/10`
;
let
costTime
=
this
.
_status
.
current
==
"
Red
"
?
this
.
_status
.
RedTime
:
this
.
_status
.
BlueTime
;
this
.
_leftTime
=
150
-
(
+
costTime
)
break
;
break
;
case
1
:
case
1
:
if
(
this
.
isMySide
)
{
if
(
this
.
isMySide
)
{
...
@@ -350,7 +376,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -350,7 +376,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
}
else
{
this
.
greyDice
();
this
.
greyDice
();
}
}
this
.
stopRollPiece
();
break
;
break
;
case
2
:
case
2
:
if
(
this
.
isMySide
)
{
if
(
this
.
isMySide
)
{
...
@@ -358,6 +384,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -358,6 +384,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
}
else
{
this
.
greyDice
();
this
.
greyDice
();
}
}
this
.
_leftTime
=
-
1
;
break
;
break
;
}
}
...
@@ -395,29 +422,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -395,29 +422,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
blinkTheDice
()
{
blinkTheDice
()
{
cc
.
find
(
"
Canvas/road/board
"
).
children
.
forEach
((
node
)
=>
{
cc
.
tween
(
node
)
let
finger
=
cc
.
find
(
"
Canvas/road/board/finger
"
)
.
set
({
scale
:
1
})
finger
.
zIndex
=
10
;
.
to
(
0.2
,
{
scale
:
1.1
})
finger
.
active
=
true
;
.
to
(
0.2
,
{
scale
:
1.0
})
cc
.
tween
(
finger
)
.
set
({
scale
:
3
})
.
to
(
0.2
,
{
scale
:
3.3
})
.
to
(
0.2
,
{
scale
:
3.0
})
.
union
()
.
union
()
.
repeatForever
()
.
repeatForever
()
.
start
();
.
start
();
});
}
}
normaltheDice
()
{
normaltheDice
()
{
cc
.
find
(
"
Canvas/road/board
"
).
children
.
forEach
((
node
)
=>
{
let
finger
=
cc
.
find
(
"
Canvas/road/board/finger
"
)
node
.
stopAllActions
();
finger
.
active
=
false
;
node
.
color
=
cc
.
color
(
250
,
250
,
250
);
});
// cc.find("Canvas/road/board").children.forEach((node) => {
// node.stopAllActions();
// node.color = cc.color(250, 250, 250);
// });
}
}
greyDice
()
{
greyDice
()
{
cc
.
find
(
"
Canvas/road/board
"
).
children
.
forEach
((
node
)
=>
{
node
.
color
=
cc
.
color
(
150
,
150
,
150
);
let
finger
=
cc
.
find
(
"
Canvas/road/board/finger
"
)
});
finger
.
active
=
false
;
// cc.find("Canvas/road/board").children.forEach((node) => {
// node.color = cc.color(150, 150, 150);
// });
}
}
...
@@ -438,36 +475,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -438,36 +475,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
stopRollPiece
()
{
backCoin
(
right
=
false
)
{
let
node
=
this
.
getCurrentPiece
()
node
.
stopAllActions
();
}
rollPiece
()
{
let
node
=
this
.
getCurrentPiece
()
node
.
stopAllActions
();
cc
.
tween
(
node
)
.
set
({
scale
:
1
,
angle
:
0
})
.
to
(
0.1
,
{
angle
:
-
10
})
.
to
(
0.2
,
{
angle
:
10
})
.
to
(
0.1
,
{
angle
:
0
})
.
delay
(
1
)
.
union
()
.
repeatForever
()
.
start
();
this
.
playLocalAudio
(
"
grow
"
);
let
board
=
cc
.
find
(
"
Canvas/road/board
"
)
this
.
_cardList
.
forEach
((
child
:
cc
.
Node
,
idx
,
list
)
=>
{
this
.
_coinNode
.
parent
=
board
;
cc
.
tween
(
child
)
this
.
_coinNode
.
position
=
cc
.
v3
(
-
67
,
139
);
.
set
({
scale
:
1
})
this
.
_coinNode
.
getChildByName
(
"
coinA
"
).
active
=
true
;
.
delay
(
idx
*
0.1
)
this
.
_coinNode
.
getChildByName
(
"
coinB
"
).
active
=
false
;
.
to
(
0.1
,
{
scale
:
1.1
})
.
to
(
0.1
,
{
scale
:
1
})
if
(
right
)
{
.
delay
(
list
.
length
*
0.11
-
idx
*
0.11
)
let
point
=
this
.
_cardList
[
this
.
_lastIndex
].
getChildByName
(
"
p
"
);
.
start
();
let
dot
=
this
.
_redDot
;
});
if
(
this
.
_status
.
current
==
"
Blue
"
)
{
dot
=
this
.
_blueDot
;
}
}
let
dotNode
=
cc
.
instantiate
(
dot
);
dotNode
.
active
=
true
;
dotNode
.
parent
=
point
;
dotNode
.
position
=
cc
.
Vec3
.
ZERO
;
}
}
jumpBlock
(
idx
)
{
jumpBlock
(
idx
)
{
...
@@ -481,14 +514,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -481,14 +514,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
async
peaceJumpAndSpeak
()
{
async
peaceJumpAndSpeak
()
{
let
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
);
//
let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
let
nowIdx
=
this
.
_status
[
this
.
_status
.
current
];
//
let nowIdx = this._status[this._status.current];
let
nextIdx
=
nowIdx
+
this
.
_status
.
step
;
//
let nextIdx = nowIdx + this._status.step;
this
.
playLocalAudio
(
"
piece
"
);
this
.
playLocalAudio
(
"
piece
"
);
let
word
=
await
this
.
pieceMove
(
node
,
nowIdx
,
nextIdx
);
let
word
=
await
this
.
pieceMove
();
if
(
this
.
isMySide
)
{
if
(
this
.
isMySide
)
{
let
card
=
this
.
_cardList
[
nextIdx
];
let
card
=
this
.
_cardList
[
this
.
_status
.
step
];
await
asyncDelay
(
0.5
);
await
asyncDelay
(
0.5
);
this
.
openCoursView
(
card
,
word
);
this
.
openCoursView
(
card
,
word
);
...
@@ -501,10 +534,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -501,10 +534,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
nowIdx
=
this
.
_status
[
this
.
_status
.
current
];
let
nowIdx
=
this
.
_status
[
this
.
_status
.
current
];
let
nextIdx
=
nowIdx
+
this
.
_status
.
step
;
let
nextIdx
=
nowIdx
+
this
.
_status
.
step
;
this
.
playLocalAudio
(
"
piece
"
);
this
.
playLocalAudio
(
"
piece
"
);
await
this
.
pieceMove
(
node
,
nowIdx
,
nextIdx
);
await
this
.
pieceMove
();
//todo
//todo
this
.
playLocalAudio
(
"
wrong
"
);
this
.
playLocalAudio
(
"
wrong
"
);
await
this
.
pieceGoBack
(
node
,
node
[
"
nowIndex
"
],
nowIdx
);
await
this
.
pieceGoBack
();
}
}
...
@@ -551,7 +584,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -551,7 +584,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
probar
.
getComponent
(
cc
.
ProgressBar
).
unscheduleAllCallbacks
();
probar
.
getComponent
(
cc
.
ProgressBar
).
unscheduleAllCallbacks
();
this
.
_coursewareStoped
();
this
.
_coursewareStoped
();
}
}
},
0.1
,
6
1
,
0.1
)
},
0.1
,
3
1
,
0.1
)
}
}
async
_startCourseware
(
word
)
{
async
_startCourseware
(
word
)
{
...
@@ -708,25 +741,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -708,25 +741,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
async
fixStep
()
{
async
fixStep
()
{
if
(
this
.
_status
.
jump
)
{
this
.
log
(
"
===fix====jump====
"
);
let
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
);
let
nowStep
=
this
.
_status
[
this
.
_status
.
current
]
let
offset
=
this
.
_status
.
current
==
"
Red
"
?
-
25
:
25
;
let
pos
=
this
.
_cardList
[
nowStep
].
position
;
await
asyncTweenTo
(
node
,
0.7
,
{
x
:
pos
.
x
+
offset
,
y
:
pos
.
y
},
{
easing
:
"
cubicOut
"
}
);
await
asyncDelay
(
0.2
);
node
.
stopAllActions
();
}
}
}
get
isMySide
()
{
get
isMySide
()
{
...
@@ -819,7 +835,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -819,7 +835,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
}
else
{
this
.
greyDice
();
this
.
greyDice
();
}
}
let
rollNum
=
this
.
_status
.
step
-
1
+
6
+
(
Math
.
random
()
>
0.5
?
0
:
6
);
let
rollNum
=
this
.
_status
.
step
this
.
_lastIndex
=
rollNum
;
await
this
.
rollTheDice
(
rollNum
);
await
this
.
rollTheDice
(
rollNum
);
this
.
log
(
"
rollTheDice done
"
);
this
.
log
(
"
rollTheDice done
"
);
...
@@ -828,30 +846,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -828,30 +846,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
log
(
"
peaceJumpAndSpeak done
"
);
this
.
log
(
"
peaceJumpAndSpeak done
"
);
this
.
roundEndCheck
();
this
.
roundEndCheck
();
}
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerRight
"
)
{
else
if
(
item
.
data
.
type
==
"
SERVER_playerRight
"
)
{
this
.
_leftTime
=
-
1
;
!
this
.
isMySide
&&
this
.
playLocalAudio
(
"
right
"
);
!
this
.
isMySide
&&
this
.
playLocalAudio
(
"
right
"
);
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
await
this
.
fixStep
();
this
.
backCoin
(
true
)
await
asyncDelay
(
2
);
await
asyncDelay
(
2
);
this
.
roundEndCheck
(
true
);
this
.
roundEndCheck
(
true
);
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWrong
"
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWrong
"
)
{
this
.
_leftTime
=
-
1
;
!
this
.
isMySide
&&
this
.
playLocalAudio
(
"
wrong
"
);
!
this
.
isMySide
&&
this
.
playLocalAudio
(
"
wrong
"
);
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
if
(
this
.
_status
.
jump
)
{
this
.
backCoin
()
await
this
.
fixStep
();
}
else
{
let
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
);
let
nowIdx
=
this
.
_status
[
this
.
_status
.
current
];
await
this
.
pieceGoBack
(
node
,
node
[
"
nowIndex
"
],
nowIdx
);
}
await
asyncDelay
(
2
);
await
asyncDelay
(
2
);
this
.
roundEndCheck
();
this
.
roundEndCheck
();
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWin
"
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWin
"
)
{
this
.
_leftTime
=
-
1
;
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
data
.
status
));
const
node
=
cc
.
find
(
const
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
...
@@ -870,14 +884,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -870,14 +884,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
});
}
}
pieceGoBack
(
a
,
v
,
c
)
{
update
(
dt
)
{
if
(
this
.
_leftTime
>
0
)
{
this
.
_leftTime
-=
dt
;
this
.
clockNode
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
).
string
=
""
+
Math
.
round
(
this
.
_leftTime
);
this
.
clockNode
.
getChildByName
(
"
lb
"
).
color
=
this
.
_status
.
current
==
"
Red
"
?
cc
.
Color
.
RED
:
cc
.
Color
.
BLUE
;
}
}
}
pieceMove
(
a
,
b
,
c
)
{
}
pieceGoBack
()
{
this
.
backCoin
();
}
pieceMove
()
{
}
async
toEnd
()
{
async
toEnd
()
{
this
.
_redLb
.
string
=
`
${
this
.
_status
.
Red
}
/10`
;
this
.
_blueLb
.
string
=
`
${
this
.
_status
.
Blue
}
/10`
;
let
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
);
let
node
=
cc
.
find
(
`Canvas/road/root/piece
${
this
.
_status
.
current
}
`
);
// let pos = this._bluePointRoot.getChildByName("19").position;
// let pos = this._bluePointRoot.getChildByName("19").position;
...
@@ -936,29 +967,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -936,29 +967,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
// onHomeworkFinish();
// onHomeworkFinish();
}
}
rollTheDice
(
num
)
{
async
rollTheDice
(
num
)
{
if
(
this
.
_isRolling
)
{
if
(
this
.
_isRolling
)
{
return
;
return
;
}
}
const
dice
=
cc
.
find
(
"
Canvas/road/board/runBoard
"
);
this
.
_springNode
.
getComponent
(
cc
.
Animation
).
play
();
return
new
Promise
((
resolve
,
reject
)
=>
{
const
targetAngle
=
Math
.
ceil
(
dice
.
angle
/
360
+
1
)
*
360
;
cc
.
tween
(
this
.
_coinNode
).
by
(
0.14
,
{
y
:
-
10
}).
start
();
const
time
=
(
targetAngle
-
360
-
dice
.
angle
)
/
360
;
this
.
_isRolling
=
true
;
await
asyncDelay
(
0.14
);
cc
.
tween
(
dice
)
this
.
_coinNode
.
getChildByName
(
"
coinA
"
).
active
=
false
;
.
by
(
1.5
,
{
angle
:
360
},
{
easing
:
"
cubicIn
"
})
this
.
_coinNode
.
getChildByName
(
"
coinB
"
).
active
=
true
;
.
to
(
time
/
2
,
{
angle
:
targetAngle
})
.
by
(
0.5
,
{
angle
:
360
})
cc
.
tween
(
this
.
_coinNode
).
by
(
0.5
,
{
y
:
400
}).
start
();
.
by
(
0.5
,
{
angle
:
360
})
await
asyncDelay
(
0.5
);
.
by
((
1
/
12
)
*
num
,
{
angle
:
60
*
num
})
this
.
_coinNode
.
parent
=
this
.
_cardList
[
num
].
parent
;
.
by
(
1.5
,
{
angle
:
360
},
{
easing
:
"
cubicOut
"
})
this
.
_coinNode
.
position
=
cc
.
v3
(
this
.
_cardList
[
num
].
x
,
this
.
_cardList
[
num
].
y
+
1000
,
0
)
.
call
(()
=>
{
this
.
_isRolling
=
false
;
cc
.
tween
(
this
.
_coinNode
).
by
(
0.5
,
{
y
:
-
1000
},
{
easing
:
cc
.
easeBounceIn
.
name
}).
start
();
resolve
(
null
);
await
asyncDelay
(
0.5
);
})
return
Promise
.
resolve
();
.
start
();
});
}
}
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
...
...
assets/L4R4/script/Server.ts
View file @
145fbcf9
...
@@ -29,14 +29,11 @@ export class GameServer {
...
@@ -29,14 +29,11 @@ export class GameServer {
"
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
"
,
"
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
"
,
];
];
jumpList
=
[
// { from: 2, rto: 11 ,wto:1},
];
forceWrongIndexList
=
[];
private
_totalStep
:
any
;
private
_totalStep
:
any
;
randomList
=
[];
randomList
=
[];
private
_useAI
:
boolean
;
private
_useAI
:
boolean
;
private
_timer
:
number
;
private
_totalTime
:
number
=
150
;
constructor
(
playerMaxNumber
,
networkHelper
)
{
constructor
(
playerMaxNumber
,
networkHelper
)
{
this
.
playerMaxNumber
=
playerMaxNumber
;
this
.
playerMaxNumber
=
playerMaxNumber
;
...
@@ -80,14 +77,20 @@ export class GameServer {
...
@@ -80,14 +77,20 @@ export class GameServer {
gameStatus
=
{
gameStatus
=
{
state
:
0
,
// -1:未开始 0 准备阶段 1 roll 2 判定
state
:
0
,
// -1:未开始 0 准备阶段 1 roll 2 判定
Red
:
-
1
,
Red
:
0
,
Blue
:
-
1
,
Blue
:
0
,
RedTime
:
0
,
BlueTime
:
0
,
step
:
0
,
step
:
0
,
current
:
"
Red
"
,
current
:
"
Red
"
,
jump
:
false
,
time
:
"
0
"
back
:
false
,
};
};
startGame
()
{
startGame
()
{
this
.
openTimerCounter
();
console
.
log
(
"
startGame set time ------
"
);
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_updateStatus
"
,
type
:
"
SERVER_updateStatus
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
...
@@ -154,57 +157,46 @@ export class GameServer {
...
@@ -154,57 +157,46 @@ export class GameServer {
}
}
if
(
sender
.
color
==
this
.
gameStatus
.
current
)
{
if
(
sender
.
color
==
this
.
gameStatus
.
current
)
{
let
nowStep
=
this
.
gameStatus
[
this
.
gameStatus
.
current
];
let
index
=
Math
.
floor
(
Math
.
random
()
*
this
.
randomList
.
length
)
let
i
=
Math
.
floor
(
Math
.
random
()
*
this
.
randomList
.
length
)
let
step
=
this
.
randomList
[
index
];
let
index
=
this
.
randomList
[
i
];
// if (nowStep < 5) {
// step = 3;
console
.
log
(
"
random index ===
"
+
index
);
// } else {
this
.
gameStatus
.
step
=
index
;
// step = 1;
// }
// step = 3
step
=
Math
.
min
(
step
,
this
.
_totalStep
-
1
-
nowStep
);
console
.
log
(
"
random step ===
"
+
step
);
this
.
gameStatus
.
step
=
step
;
this
.
gameStatus
.
state
=
1
;
this
.
gameStatus
.
state
=
1
;
let
endStep
=
nowStep
+
step
;
this
.
gameStatus
.
back
=
false
;
if
(
this
.
forceWrongIndexList
.
indexOf
(
endStep
)
>
-
1
)
{
this
.
gameStatus
.
back
=
true
;
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerRoll
"
,
status
:
this
.
gameStatus
,
});
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
step
=
null
;
this
.
changeSide
();
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerRoll
"
,
type
:
"
SERVER_playerRoll
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
});
});
}
}
else
{
}
else
{
console
.
warn
(
"
data uuid not match
"
);
console
.
warn
(
"
data uuid not match
"
);
}
}
}
}
else
if
(
data
.
type
==
"
right
"
)
{
else
if
(
data
.
type
==
"
right
"
)
{
let
nowStep
:
number
=
this
.
gameStatus
[
this
.
gameStatus
.
current
];
console
.
log
(
"
nowStep ===
"
+
nowStep
);
const
jump
=
this
.
jumpList
.
find
(
jump
=>
parseInt
(
jump
.
from
)
==
nowStep
+
this
.
gameStatus
.
step
);
this
.
gameStatus
[
this
.
gameStatus
.
current
]
=
jump
?.
rto
?
parseInt
(
jump
.
rto
)
:
nowStep
+
this
.
gameStatus
.
step
;
if
(
jump
)
{
let
posIndex
=
this
.
gameStatus
.
step
console
.
log
(
"
jump=============
"
);
this
.
gameStatus
[
this
.
gameStatus
.
current
]
++
;
console
.
log
(
jump
);
let
lastTime
=
+
this
.
gameStatus
.
time
;
console
.
log
(
"
lasttime =
"
+
lastTime
);
let
costTime
=
(
Math
.
floor
(
Date
.
now
()
/
1000
)
-
lastTime
).
toFixed
(
1
)
console
.
log
(
"
=right===cost time =
"
+
costTime
);
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
RedTime
+=
+
costTime
}
else
{
this
.
gameStatus
.
BlueTime
+=
+
costTime
}
}
if
(
this
.
gameStatus
[
this
.
gameStatus
.
current
]
<
this
.
_totalStep
-
1
)
{
let
i
=
this
.
randomList
.
indexOf
(
posIndex
);
this
.
randomList
[
i
]
=
this
.
randomList
[
this
.
randomList
.
length
-
1
];
this
.
randomList
.
length
--
;
if
(
this
.
gameStatus
[
this
.
gameStatus
.
current
]
<
10
)
{
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
jump
=
!!
jump
?.
rto
;
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerRight
"
,
type
:
"
SERVER_playerRight
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
...
@@ -213,7 +205,6 @@ export class GameServer {
...
@@ -213,7 +205,6 @@ export class GameServer {
}
else
{
}
else
{
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
jump
=
!!
jump
;
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerWin
"
,
type
:
"
SERVER_playerWin
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
...
@@ -222,15 +213,19 @@ export class GameServer {
...
@@ -222,15 +213,19 @@ export class GameServer {
}
}
}
else
if
(
data
.
type
==
"
wrong
"
)
{
}
else
if
(
data
.
type
==
"
wrong
"
)
{
console
.
log
(
"
data =
"
+
JSON
.
stringify
(
data
));
let
nowStep
:
number
=
this
.
gameStatus
[
this
.
gameStatus
.
current
];
let
lastTime
=
+
this
.
gameStatus
.
time
;
console
.
log
(
"
nowStep ===
"
+
nowStep
);
let
costTime
=
(
Math
.
floor
(
Date
.
now
()
/
1000
)
-
lastTime
).
toFixed
(
1
)
const
jump
=
this
.
jumpList
.
find
(
jump
=>
parseInt
(
jump
.
from
)
==
nowStep
+
this
.
gameStatus
.
step
);
console
.
log
(
"
=wrong and ===cost time =
"
+
costTime
);
this
.
gameStatus
[
this
.
gameStatus
.
current
]
=
jump
?.
wto
?
parseInt
(
jump
.
wto
)
:
nowStep
;
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
RedTime
+=
+
costTime
}
else
{
this
.
gameStatus
.
BlueTime
+=
+
costTime
}
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
step
=
null
;
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
jump
=
!!
jump
?.
wto
;
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerWrong
"
,
type
:
"
SERVER_playerWrong
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
...
@@ -241,15 +236,19 @@ export class GameServer {
...
@@ -241,15 +236,19 @@ export class GameServer {
if
(
this
.
_useAI
||
sender
.
color
==
this
.
gameStatus
.
current
)
{
if
(
this
.
_useAI
||
sender
.
color
==
this
.
gameStatus
.
current
)
{
if
(
this
.
gameStatus
.
state
==
2
||
this
.
gameStatus
.
back
)
{
if
(
this
.
gameStatus
.
state
==
2
)
{
this
.
gameStatus
.
state
=
0
;
this
.
gameStatus
.
state
=
0
;
}
}
if
(
this
.
gameStatus
.
state
==
0
)
{
this
.
openTimerCounter
();
}
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_updateStatus
"
,
type
:
"
SERVER_updateStatus
"
,
status
:
this
.
gameStatus
,
status
:
this
.
gameStatus
,
});
});
this
.
gameStatus
.
jump
=
null
;
this
.
gameStatus
.
back
=
null
;
}
}
}
}
...
@@ -264,6 +263,50 @@ export class GameServer {
...
@@ -264,6 +263,50 @@ export class GameServer {
this
.
_totalStep
=
step
;
this
.
_totalStep
=
step
;
}
}
openTimerCounter
()
{
let
prepareTime
=
4
;
// AI 无准备时间
if
(
this
.
_useAI
&&
this
.
gameStatus
.
current
==
"
Blue
"
)
{
prepareTime
=
0
}
this
.
gameStatus
.
time
=
""
+
(
Math
.
floor
(
Date
.
now
()
/
1000
)
+
prepareTime
);
console
.
log
(
"
openTimerCounter set time ------
"
);
clearTimeout
(
this
.
_timer
)
let
leftTime
=
this
.
gameStatus
.
BlueTime
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
leftTime
=
this
.
gameStatus
.
RedTime
;
}
leftTime
=
this
.
_totalTime
-
leftTime
+
prepareTime
;
console
.
log
(
`
${
this
.
gameStatus
.
current
}
left time
${
leftTime
}
, now time
${
Date
.
now
()
/
1000
}
`
)
this
.
_timer
=
setTimeout
(
this
.
timeOver
.
bind
(
this
),
leftTime
*
1000
);
}
timeOver
()
{
let
lastTime
=
+
this
.
gameStatus
.
time
;
let
costTime
=
(
Math
.
floor
(
Date
.
now
()
/
1000
)
-
lastTime
).
toFixed
(
1
)
console
.
log
(
`time over and time now
${
Date
.
now
()
/
1000
}
`
);
console
.
log
(
"
=wrong and ===cost time =
"
+
costTime
);
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
RedTime
+=
+
costTime
}
else
{
this
.
gameStatus
.
BlueTime
+=
+
costTime
}
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
current
=
"
Blue
"
}
this
.
gameStatus
.
state
=
2
;
this
.
gameStatus
.
step
=
null
;
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_playerWin
"
,
status
:
this
.
gameStatus
,
});
this
.
gameStatus
[
'
gameOver
'
]
=
true
;
}
changeSide
()
{
changeSide
()
{
...
...
assets/L4R4/texture/红色方标记.png
0 → 100644
View file @
145fbcf9
6.98 KB
assets/L4R4/texture/红色方标记.png.meta
0 → 100644
View file @
145fbcf9
{
"ver": "2.3.5",
"uuid": "a2aaf5ad-5e41-4c6b-8e88-20d13def81e2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 65,
"height": 65,
"platformSettings": {},
"subMetas": {
"红色方标记": {
"ver": "1.0.4",
"uuid": "0d662d0a-e52c-465c-b2e3-3ded3c5c5cf3",
"rawTextureUuid": "a2aaf5ad-5e41-4c6b-8e88-20d13def81e2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 1,
"trimX": 2,
"trimY": 0,
"width": 61,
"height": 63,
"rawWidth": 65,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/L4R4/texture/蓝色方标记.png
0 → 100644
View file @
145fbcf9
7.21 KB
assets/L4R4/texture/蓝色方标记.png.meta
0 → 100644
View file @
145fbcf9
{
"ver": "2.3.5",
"uuid": "4a17542f-6342-48aa-ac6a-6c41cca3c59a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 65,
"height": 65,
"platformSettings": {},
"subMetas": {
"蓝色方标记": {
"ver": "1.0.4",
"uuid": "5ccb965e-4c30-4b3a-914c-20367db3d00f",
"rawTextureUuid": "4a17542f-6342-48aa-ac6a-6c41cca3c59a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 1,
"trimX": 2,
"trimY": 0,
"width": 61,
"height": 63,
"rawWidth": 65,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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