Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
op_16
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
op_16
Commits
912c2a58
Commit
912c2a58
authored
Feb 17, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: bugs
parent
3acf5050
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1982 additions
and
982 deletions
+1982
-982
.DS_Store
.DS_Store
+0
-0
match.mp3
assets/op_16/audios/match.mp3
+0
-0
match.mp3.meta
assets/op_16/audios/match.mp3.meta
+7
-0
LoadingLayer.prefab
assets/op_16/prefab/LoadingLayer/LoadingLayer.prefab
+175
-3
op_16.fire
assets/op_16/scene/op_16.fire
+631
-172
op_16.ts
assets/op_16/scene/op_16.ts
+854
-654
AI.ts
assets/op_16/script/AI.ts
+28
-25
LoadingLayer.ts
assets/op_16/script/LoadingLayer.ts
+20
-0
NetworkHelper.ts
assets/op_16/script/NetworkHelper.ts
+151
-69
Server.ts
assets/op_16/script/Server.ts
+74
-59
yourturn.png
assets/op_16/textures/yourturn.png
+0
-0
yourturn.png.meta
assets/op_16/textures/yourturn.png.meta
+36
-0
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+1
-0
No files found.
.DS_Store
View file @
912c2a58
No preview for this file type
assets/op_16/audios/match.mp3
0 → 100644
View file @
912c2a58
File added
assets/op_16/audios/match.mp3.meta
0 → 100644
View file @
912c2a58
{
"ver": "2.0.1",
"uuid": "64769aad-08a2-4b33-8fbb-6a6ba01f53f2",
"downloadMode": 0,
"duration": 3.474286,
"subMetas": {}
}
\ No newline at end of file
assets/op_16/prefab/LoadingLayer/LoadingLayer.prefab
View file @
912c2a58
...
@@ -40,19 +40,22 @@
...
@@ -40,19 +40,22 @@
},
},
{
{
"__id__": 34
"__id__": 34
},
{
"__id__": 54
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 5
4
"__id__": 5
9
},
},
{
{
"__id__":
55
"__id__":
60
}
}
],
],
"_prefab": {
"_prefab": {
"__id__":
56
"__id__":
61
},
},
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -1959,6 +1962,175 @@
...
@@ -1959,6 +1962,175 @@
"fileId": "f9qrJyDh5P1oErn3FfsNL7",
"fileId": "f9qrJyDh5P1oErn3FfsNL7",
"sync": false
"sync": false
},
},
{
"__type__": "cc.Node",
"_name": "res",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 55
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 58
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "match",
"_objFlags": 0,
"_parent": {
"__id__": 54
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 56
}
],
"_prefab": {
"__id__": 57
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 55
},
"_enabled": true,
"_clip": {
"__uuid__": "64769aad-08a2-4b33-8fbb-6a6ba01f53f2"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "4839576b-7c74-49ab-aa3e-8eeec631d7c0"
},
"fileId": "24pM39t0xAcpeV3Rbf7iK5",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "4839576b-7c74-49ab-aa3e-8eeec631d7c0"
},
"fileId": "28B+az6rRACpZT/KUohVaz",
"sync": false
},
{
{
"__type__": "cc.Widget",
"__type__": "cc.Widget",
"_name": "",
"_name": "",
...
...
assets/op_16/scene/op_16.fire
View file @
912c2a58
...
@@ -17,7 +17,10 @@
...
@@ -17,7 +17,10 @@
"__id__": 2
"__id__": 2
},
},
{
{
"__id__": 168
"__id__": 172
},
{
"__id__": 185
}
}
],
],
"_active": false,
"_active": false,
...
@@ -81,19 +84,19 @@
...
@@ -81,19 +84,19 @@
"__id__": 7
"__id__": 7
},
},
{
{
"__id__": 15
1
"__id__": 15
4
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 16
5
"__id__": 16
9
},
},
{
{
"__id__": 1
66
"__id__": 1
70
},
},
{
{
"__id__": 1
67
"__id__": 1
71
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -354,19 +357,22 @@
...
@@ -354,19 +357,22 @@
"__id__": 112
"__id__": 112
},
},
{
{
"__id__": 12
6
"__id__": 12
7
},
},
{
{
"__id__": 14
1
"__id__": 14
2
},
},
{
{
"__id__": 148
"__id__": 149
},
{
"__id__": 151
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 15
0
"__id__": 15
3
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -4725,10 +4731,10 @@
...
@@ -4725,10 +4731,10 @@
"__id__": 121
"__id__": 121
},
},
{
{
"__id__": 12
2
"__id__": 12
3
},
},
{
{
"__id__": 12
4
"__id__": 12
5
}
}
],
],
"_active": true,
"_active": true,
...
@@ -5162,7 +5168,11 @@
...
@@ -5162,7 +5168,11 @@
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [],
"_components": [
{
"__id__": 122
}
],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -5211,6 +5221,38 @@
...
@@ -5211,6 +5221,38 @@
"groupIndex": 0,
"groupIndex": 0,
"_id": "0bfyX/nTdPJIpfRKUryv4/"
"_id": "0bfyX/nTdPJIpfRKUryv4/"
},
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 121
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "961b4c40-b93f-4af5-af66-e3683eb2b5b6"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "06teYaEQRIa5GjLPZjiTIu"
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "faceBlue",
"_name": "faceBlue",
...
@@ -5222,7 +5264,7 @@
...
@@ -5222,7 +5264,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 12
3
"__id__": 12
4
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5278,7 +5320,7 @@
...
@@ -5278,7 +5320,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 12
2
"__id__": 12
3
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5316,7 +5358,7 @@
...
@@ -5316,7 +5358,7 @@
"_active": false,
"_active": false,
"_components": [
"_components": [
{
{
"__id__": 12
5
"__id__": 12
6
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5372,7 +5414,7 @@
...
@@ -5372,7 +5414,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 12
4
"__id__": 12
5
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5416,19 +5458,19 @@
...
@@ -5416,19 +5458,19 @@
},
},
"_children": [
"_children": [
{
{
"__id__": 12
7
"__id__": 12
8
},
},
{
{
"__id__": 13
3
"__id__": 13
4
},
},
{
{
"__id__": 13
5
"__id__": 13
6
},
},
{
{
"__id__": 13
7
"__id__": 13
8
},
},
{
{
"__id__": 1
39
"__id__": 1
40
}
}
],
],
"_active": true,
"_active": true,
...
@@ -5486,17 +5528,17 @@
...
@@ -5486,17 +5528,17 @@
"_name": "life_red",
"_name": "life_red",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
6
"__id__": 12
7
},
},
"_children": [
"_children": [
{
{
"__id__": 12
8
"__id__": 12
9
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
2
"__id__": 13
3
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5552,17 +5594,17 @@
...
@@ -5552,17 +5594,17 @@
"_name": "mask",
"_name": "mask",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
7
"__id__": 12
8
},
},
"_children": [
"_children": [
{
{
"__id__": 1
29
"__id__": 1
30
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
1
"__id__": 13
2
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5618,13 +5660,13 @@
...
@@ -5618,13 +5660,13 @@
"_name": "prograssbar",
"_name": "prograssbar",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
8
"__id__": 12
9
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
0
"__id__": 13
1
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5680,7 +5722,7 @@
...
@@ -5680,7 +5722,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
29
"__id__": 1
30
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5712,7 +5754,7 @@
...
@@ -5712,7 +5754,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 12
8
"__id__": 12
9
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5732,7 +5774,7 @@
...
@@ -5732,7 +5774,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 12
7
"__id__": 12
8
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5764,13 +5806,13 @@
...
@@ -5764,13 +5806,13 @@
"_name": "dice_bg",
"_name": "dice_bg",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
6
"__id__": 12
7
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
4
"__id__": 13
5
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5826,7 +5868,7 @@
...
@@ -5826,7 +5868,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 13
3
"__id__": 13
4
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5858,13 +5900,13 @@
...
@@ -5858,13 +5900,13 @@
"_name": "faceFrame",
"_name": "faceFrame",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
6
"__id__": 12
7
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
6
"__id__": 13
7
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5920,7 +5962,7 @@
...
@@ -5920,7 +5962,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 13
5
"__id__": 13
6
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5952,13 +5994,13 @@
...
@@ -5952,13 +5994,13 @@
"_name": "faceRed",
"_name": "faceRed",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
6
"__id__": 12
7
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 13
8
"__id__": 13
9
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6014,7 +6056,7 @@
...
@@ -6014,7 +6056,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 13
7
"__id__": 13
8
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -6046,13 +6088,13 @@
...
@@ -6046,13 +6088,13 @@
"_name": "effect",
"_name": "effect",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 12
6
"__id__": 12
7
},
},
"_children": [],
"_children": [],
"_active": false,
"_active": false,
"_components": [
"_components": [
{
{
"__id__": 14
0
"__id__": 14
1
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6108,7 +6150,7 @@
...
@@ -6108,7 +6150,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
39
"__id__": 1
40
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -6152,13 +6194,13 @@
...
@@ -6152,13 +6194,13 @@
},
},
"_children": [
"_children": [
{
{
"__id__": 14
2
"__id__": 14
3
}
}
],
],
"_active": false,
"_active": false,
"_components": [
"_components": [
{
{
"__id__": 14
7
"__id__": 14
8
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6214,20 +6256,20 @@
...
@@ -6214,20 +6256,20 @@
"_name": "Background",
"_name": "Background",
"_objFlags": 512,
"_objFlags": 512,
"_parent": {
"_parent": {
"__id__": 14
1
"__id__": 14
2
},
},
"_children": [
"_children": [
{
{
"__id__": 14
3
"__id__": 14
4
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 14
5
"__id__": 14
6
},
},
{
{
"__id__": 14
6
"__id__": 14
7
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6283,13 +6325,13 @@
...
@@ -6283,13 +6325,13 @@
"_name": "Label",
"_name": "Label",
"_objFlags": 512,
"_objFlags": 512,
"_parent": {
"_parent": {
"__id__": 14
2
"__id__": 14
3
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 14
4
"__id__": 14
5
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6345,7 +6387,7 @@
...
@@ -6345,7 +6387,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 14
3
"__id__": 14
4
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -6378,7 +6420,7 @@
...
@@ -6378,7 +6420,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 14
2
"__id__": 14
3
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -6410,7 +6452,7 @@
...
@@ -6410,7 +6452,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 14
2
"__id__": 14
3
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 0,
"alignMode": 0,
...
@@ -6437,7 +6479,7 @@
...
@@ -6437,7 +6479,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 14
1
"__id__": 14
2
},
},
"_enabled": true,
"_enabled": true,
"_normalMaterial": null,
"_normalMaterial": null,
...
@@ -6510,7 +6552,7 @@
...
@@ -6510,7 +6552,7 @@
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
},
"_N$target": {
"_N$target": {
"__id__": 14
2
"__id__": 14
3
},
},
"_id": "72uh6FFMhPZJXe9I3tJ4Qt"
"_id": "72uh6FFMhPZJXe9I3tJ4Qt"
},
},
...
@@ -6525,7 +6567,7 @@
...
@@ -6525,7 +6567,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
49
"__id__": 1
50
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6581,7 +6623,7 @@
...
@@ -6581,7 +6623,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 14
8
"__id__": 14
9
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 2,
"alignMode": 2,
...
@@ -6603,49 +6645,18 @@
...
@@ -6603,49 +6645,18 @@
"_originalHeight": 0,
"_originalHeight": 0,
"_id": "9fr0grwX5J57n69Cqpwnin"
"_id": "9fr0grwX5J57n69Cqpwnin"
},
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 2560,
"_originalHeight": 1920,
"_id": "17YA8Nu1dLN6R6o3Ie/SyN"
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
endBg
",
"_name": "
yourturn
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
2
"__id__":
7
},
},
"_children": [
"_children": [],
{
"_active": false,
"__id__": 152
}
],
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
64
"__id__": 1
52
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6659,8 +6670,8 @@
...
@@ -6659,8 +6670,8 @@
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
2560
,
"width":
584
,
"height":
1920
"height":
235
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -6678,8 +6689,8 @@
...
@@ -6678,8 +6689,8 @@
0,
0,
0,
0,
1,
1,
1
,
2
,
1
,
2
,
1
1
]
]
},
},
...
@@ -6694,55 +6705,117 @@
...
@@ -6694,55 +6705,117 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
c2LGM+IBlEgp7HT+DBiBoZ
"
"_id": "
beNbXPSUZO3JERirbadq6E
"
},
},
{
{
"__type__": "cc.
Nod
e",
"__type__": "cc.
Sprit
e",
"_name": "
bg
",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"
_parent
": {
"
node
": {
"__id__": 151
"__id__": 151
},
},
"_children": [
"_enabled": true,
{
"_materials": [
"__id__": 153
}
],
"_active": true,
"_components": [
{
"__id__": 162
},
{
{
"__
id__": 163
"__
uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
}
],
],
"_prefab": null,
"_srcBlendFactor": 770,
"_opacity": 0,
"_dstBlendFactor": 771,
"_color": {
"_spriteFrame": {
"__type__": "cc.Color",
"__uuid__": "eeb8a1d1-4858-4241-8733-38b1cff4c7cf"
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
},
"_anchorPoint": {
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
"x": 0
.5
,
"x": 0,
"y": 0
.5
"y": 0
},
},
"_trs": {
"_fillStart": 0,
"__type__": "TypedArray",
"_fillRange": 0,
"ctor": "Float64Array",
"_isTrimmedMode": true,
"array": [
"_atlas": null,
0,
"_id": "fc8448+HZJqqhlGZue2Lzm"
0,
},
0,
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 2560,
"_originalHeight": 1920,
"_id": "17YA8Nu1dLN6R6o3Ie/SyN"
},
{
"__type__": "cc.Node",
"_name": "endBg",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 155
},
{
"__id__": 158
}
],
"_active": false,
"_components": [
{
"__id__": 167
},
{
"__id__": 168
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
...
@@ -6763,30 +6836,154 @@
...
@@ -6763,30 +6836,154 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
9cjbtB0sNCsLMdza0zrJ8B
"
"_id": "
c2LGM+IBlEgp7HT+DBiBoZ
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "bg",
"_name": "bg",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 15
2
"__id__": 15
4
},
},
"_children": [
"_children": [],
"_active": true,
"_components": [
{
{
"__id__": 15
4
"__id__": 15
6
},
},
{
{
"__id__": 157
"__id__": 157
}
}
],
],
"_prefab": null,
"_opacity": 0,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "9cjbtB0sNCsLMdza0zrJ8B"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 155
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "60jQo7aKpO+755Gs2kdTZQ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 155
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_id": "3c8tUAlc9PQoBjysSDbTCd"
},
{
"__type__": "cc.Node",
"_name": "labelBg",
"_objFlags": 0,
"_parent": {
"__id__": 154
},
"_children": [
{
"__id__": 159
},
{
"__id__": 162
}
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 16
0
"__id__": 16
5
},
},
{
{
"__id__": 16
1
"__id__": 16
6
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6842,16 +7039,16 @@
...
@@ -6842,16 +7039,16 @@
"_name": "labelLoss",
"_name": "labelLoss",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 15
3
"__id__": 15
8
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
55
"__id__": 1
60
},
},
{
{
"__id__": 1
56
"__id__": 1
61
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -6907,7 +7104,7 @@
...
@@ -6907,7 +7104,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
4
"__id__": 15
9
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -6939,7 +7136,7 @@
...
@@ -6939,7 +7136,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
4
"__id__": 15
9
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 1,
"alignMode": 1,
...
@@ -6966,16 +7163,16 @@
...
@@ -6966,16 +7163,16 @@
"_name": "labelWin",
"_name": "labelWin",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 15
3
"__id__": 15
8
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
58
"__id__": 1
63
},
},
{
{
"__id__": 1
59
"__id__": 1
64
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7031,7 +7228,7 @@
...
@@ -7031,7 +7228,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
57
"__id__": 1
62
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -7063,7 +7260,7 @@
...
@@ -7063,7 +7260,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
57
"__id__": 1
62
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 1,
"alignMode": 1,
...
@@ -7090,7 +7287,7 @@
...
@@ -7090,7 +7287,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
3
"__id__": 15
8
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -7122,7 +7319,7 @@
...
@@ -7122,7 +7319,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
3
"__id__": 15
8
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 2,
"alignMode": 2,
...
@@ -7144,44 +7341,12 @@
...
@@ -7144,44 +7341,12 @@
"_originalHeight": 0,
"_originalHeight": 0,
"_id": "e8w4Lw+2VNObnuwPQ1d2O8"
"_id": "e8w4Lw+2VNObnuwPQ1d2O8"
},
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 152
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "60jQo7aKpO+755Gs2kdTZQ"
},
{
{
"__type__": "cc.Widget",
"__type__": "cc.Widget",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
2
"__id__": 15
4
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 2,
"alignMode": 2,
...
@@ -7199,36 +7364,77 @@
...
@@ -7199,36 +7364,77 @@
"_isAbsBottom": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth":
10
0,
"_originalWidth": 0,
"_originalHeight":
10
0,
"_originalHeight": 0,
"_id": "3
c8tUAlc9PQoBjysSDbTCd
"
"_id": "3
8i+Ag8ZBHWY+hWxjSeIa4
"
},
},
{
{
"__type__": "cc.
Widget
",
"__type__": "cc.
Button
",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 15
1
"__id__": 15
4
},
},
"_enabled": true,
"_enabled": true,
"alignMode": 2,
"_normalMaterial": null,
"_target": null,
"_grayMaterial": null,
"_alignFlags": 45,
"duration": 0.1,
"_left": 0,
"zoomScale": 1.2,
"_right": 0,
"clickEvents": [],
"_top": 0,
"_N$interactable": true,
"_bottom": 0,
"_N$enableAutoGrayEffect": false,
"_verticalCenter": 0,
"_N$transition": 0,
"_horizontalCenter": 0,
"transition": 0,
"_isAbsLeft": true,
"_N$normalColor": {
"_isAbsRight": true,
"__type__": "cc.Color",
"_isAbsTop": true,
"r": 255,
"_isAbsBottom": true,
"g": 255,
"_isAbsHorizontalCenter": true,
"b": 255,
"_isAbsVerticalCenter": true,
"a": 255
"_originalWidth": 0,
},
"_originalHeight": 0,
"_N$pressedColor": {
"_id": "38i+Ag8ZBHWY+hWxjSeIa4"
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "9bSBBJ8ORHaKrvJv70h0XL"
},
},
{
{
"__type__": "cc.Canvas",
"__type__": "cc.Canvas",
...
@@ -7275,47 +7481,190 @@
...
@@ -7275,47 +7481,190 @@
"_id": "29zXboiXFBKoIV4PQ2liTe"
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
},
{
{
"__type__": "408a6f4ZfpM8Yzyg+IOGg/V",
"__type__": "408a6f4ZfpM8Yzyg+IOGg/V",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"loadingLayerPrefab": {
"__uuid__": "4839576b-7c74-49ab-aa3e-8eeec631d7c0"
},
"_id": "eaTVUpqahPfZeO9+sUI7RP"
},
{
"__type__": "cc.Node",
"_name": "audioClips",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 173
},
{
"__id__": 175
},
{
"__id__": 177
},
{
"__id__": 179
},
{
"__id__": 181
},
{
"__id__": 183
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e0DsZcJ3NJSarF6ocrcQwO"
},
{
"__type__": "cc.Node",
"_name": "落子",
"_objFlags": 0,
"_parent": {
"__id__": 172
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 174
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "12w753jQFLVaui7MMYGUrU"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
2
"__id__":
173
},
},
"_enabled": true,
"_enabled": true,
"
loadingLayerPrefab
": {
"
_clip
": {
"__uuid__": "
4839576b-7c74-49ab-aa3e-8eeec631d7c0
"
"__uuid__": "
5a3c1f94-ee24-4cdc-91ba-eaa7efe3070e
"
},
},
"_id": "eaTVUpqahPfZeO9+sUI7RP"
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "44+cR9NexGvom9WzMCCVRA"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
audioClips
",
"_name": "
正确
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
"__id__": 172
},
"_children": [
{
"__id__": 169
},
{
"__id__": 171
},
{
"__id__": 173
},
{
"__id__": 175
},
{
"__id__": 177
},
},
"_children": [],
"_active": true,
"_components": [
{
{
"__id__": 17
9
"__id__": 17
6
}
}
],
],
"_active": true,
"_components": [],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -7362,20 +7711,39 @@
...
@@ -7362,20 +7711,39 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "e0DsZcJ3NJSarF6ocrcQwO"
"_id": "802AVhgZhNR7+Wmor3KYbC"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 175
},
"_enabled": true,
"_clip": {
"__uuid__": "f6c4b544-baa4-490f-b440-f9d553c9cdfe"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "7dl8JLRzBN4bKb42sAXOrL"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
落子
",
"_name": "
失败
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 17
0
"__id__": 17
8
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7424,18 +7792,18 @@
...
@@ -7424,18 +7792,18 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
12w753jQFLVaui7MMYGUrU
"
"_id": "
39kPM0rYxEFILg5hp7txni
"
},
},
{
{
"__type__": "cc.AudioSource",
"__type__": "cc.AudioSource",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
69
"__id__": 1
77
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_clip": {
"__uuid__": "
5a3c1f94-ee24-4cdc-91ba-eaa7efe3070e
"
"__uuid__": "
7dd331c0-bfda-43a7-8e24-7166504efc99
"
},
},
"_volume": 1,
"_volume": 1,
"_mute": false,
"_mute": false,
...
@@ -7443,20 +7811,20 @@
...
@@ -7443,20 +7811,20 @@
"_firstlyEnabled": true,
"_firstlyEnabled": true,
"playOnLoad": false,
"playOnLoad": false,
"preload": false,
"preload": false,
"_id": "
44+cR9NexGvom9WzMCCVRA
"
"_id": "
ddMUn0MOdG+qZEUCwblI1P
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
正确
",
"_name": "
错误弹回
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
72
"__id__": 1
80
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7505,18 +7873,18 @@
...
@@ -7505,18 +7873,18 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
802AVhgZhNR7+Wmor3KYbC
"
"_id": "
cdxgP8It1JOYW9XOPhT5sR
"
},
},
{
{
"__type__": "cc.AudioSource",
"__type__": "cc.AudioSource",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 17
1
"__id__": 17
9
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_clip": {
"__uuid__": "
f6c4b544-baa4-490f-b440-f9d553c9cdfe
"
"__uuid__": "
e896297a-99eb-4c87-9978-0c018c604443
"
},
},
"_volume": 1,
"_volume": 1,
"_mute": false,
"_mute": false,
...
@@ -7524,20 +7892,20 @@
...
@@ -7524,20 +7892,20 @@
"_firstlyEnabled": true,
"_firstlyEnabled": true,
"playOnLoad": false,
"playOnLoad": false,
"preload": false,
"preload": false,
"_id": "
7dl8JLRzBN4bKb42sAXOrL
"
"_id": "
d4TzQR0kBOl6F53gg/+UBi
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
失败
",
"_name": "
进度条升高
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
74
"__id__": 1
82
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7586,18 +7954,18 @@
...
@@ -7586,18 +7954,18 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
39kPM0rYxEFILg5hp7txni
"
"_id": "
46d6+a09pIL4lwaMFFGkaB
"
},
},
{
{
"__type__": "cc.AudioSource",
"__type__": "cc.AudioSource",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
73
"__id__": 1
81
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_clip": {
"__uuid__": "
7dd331c0-bfda-43a7-8e24-7166504efc99
"
"__uuid__": "
ca971933-de5e-40f2-a18f-43b4e7e733de
"
},
},
"_volume": 1,
"_volume": 1,
"_mute": false,
"_mute": false,
...
@@ -7605,20 +7973,20 @@
...
@@ -7605,20 +7973,20 @@
"_firstlyEnabled": true,
"_firstlyEnabled": true,
"playOnLoad": false,
"playOnLoad": false,
"preload": false,
"preload": false,
"_id": "
ddMUn0MOdG+qZEUCwblI1P
"
"_id": "
bcENL6B4tFk54F0B/I9BmR
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
错误弹回
",
"_name": "
胜利
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 1
76
"__id__": 1
84
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7667,18 +8035,18 @@
...
@@ -7667,18 +8035,18 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
cdxgP8It1JOYW9XOPhT5sR
"
"_id": "
ff7VDzvnVCs6DBaxl+4fc3
"
},
},
{
{
"__type__": "cc.AudioSource",
"__type__": "cc.AudioSource",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
75
"__id__": 1
83
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_clip": {
"__uuid__": "
e896297a-99eb-4c87-9978-0c018c604443
"
"__uuid__": "
b28063de-0f80-4f41-a084-40929c129b4f
"
},
},
"_volume": 1,
"_volume": 1,
"_mute": false,
"_mute": false,
...
@@ -7686,22 +8054,25 @@
...
@@ -7686,22 +8054,25 @@
"_firstlyEnabled": true,
"_firstlyEnabled": true,
"playOnLoad": false,
"playOnLoad": false,
"preload": false,
"preload": false,
"_id": "d
4TzQR0kBOl6F53gg/+UBi
"
"_id": "d
bccc2jl1Lw6v0V1Jts0W8
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
进度条升高
",
"_name": "
nodes
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
},
},
"_children": [],
"_children": [
"_active": true,
"_components": [
{
{
"__id__": 178
"__id__": 186
},
{
"__id__": 188
}
}
],
],
"_active": true,
"_components": [],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -7725,8 +8096,70 @@
...
@@ -7725,8 +8096,70 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
-327.507,
-307.694,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "6c/o2REGNNmIqMKaQvJKah"
},
{
"__type__": "cc.Node",
"_name": "light",
"_objFlags": 0,
"_parent": {
"__id__": 185
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 187
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 95,
"height": 95
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-170.747,
-97.32,
0,
0,
0,
0,
0,
0,
...
@@ -7748,39 +8181,52 @@
...
@@ -7748,39 +8181,52 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
46d6+a09pIL4lwaMFFGkaB
"
"_id": "
b5/gThiGlNm4NZRYBzwYQo
"
},
},
{
{
"__type__": "cc.
AudioSourc
e",
"__type__": "cc.
Sprit
e",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
77
"__id__": 1
86
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_materials": [
"__uuid__": "ca971933-de5e-40f2-a18f-43b4e7e733de"
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "003d9202-6c8b-4161-9866-fd33e95c843c"
},
},
"_volume": 1,
"_type": 0,
"_mute": false,
"_sizeMode": 1,
"_loop": false,
"_fillType": 0,
"_firstlyEnabled": true,
"_fillCenter": {
"playOnLoad": false,
"__type__": "cc.Vec2",
"preload": false,
"x": 0,
"_id": "bcENL6B4tFk54F0B/I9BmR"
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "1axoRCh9RDnqm//Vc+f2nn"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
胜利
",
"_name": "
star
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 1
68
"__id__": 1
85
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 18
0
"__id__": 18
9
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -7794,8 +8240,8 @@
...
@@ -7794,8 +8240,8 @@
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
0
,
"width":
174
,
"height":
0
"height":
169
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -7806,8 +8252,8 @@
...
@@ -7806,8 +8252,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0
,
159.674
,
0
,
-89.744
,
0,
0,
0,
0,
0,
0,
...
@@ -7829,25 +8275,38 @@
...
@@ -7829,25 +8275,38 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
ff7VDzvnVCs6DBaxl+4fc3
"
"_id": "
0fWbpUGHlF0rvwnhw2gGl9
"
},
},
{
{
"__type__": "cc.
AudioSourc
e",
"__type__": "cc.
Sprit
e",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 1
79
"__id__": 1
88
},
},
"_enabled": true,
"_enabled": true,
"_clip": {
"_materials": [
"__uuid__": "b28063de-0f80-4f41-a084-40929c129b4f"
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "1f2bd6e5-dfe4-4b37-a62b-c9031bc01d99"
},
},
"_volume": 1,
"_type": 0,
"_mute": false,
"_sizeMode": 1,
"_loop": false,
"_fillType": 0,
"_firstlyEnabled": true,
"_fillCenter": {
"playOnLoad": false,
"__type__": "cc.Vec2",
"preload": false,
"x": 0,
"_id": "dbccc2jl1Lw6v0V1Jts0W8"
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "3evuefar1Ko6Mg4PWqq/28"
}
}
]
]
\ No newline at end of file
assets/op_16/scene/op_16.ts
View file @
912c2a58
import
{
asyncDelay
,
asyncPlayDragonBoneAnimation
,
asyncTweenTo
,
onHomeworkFinish
,
RandomInt
}
from
"
../script/util
"
;
import
{
asyncDelay
,
asyncPlayDragonBoneAnimation
,
asyncTweenTo
,
onHomeworkFinish
,
RandomInt
,
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
import
{
GameServer
}
from
"
../script/Server
"
;
import
{
GameServer
}
from
"
../script/Server
"
;
...
@@ -7,7 +13,6 @@ const { ccclass, property } = cc._decorator;
...
@@ -7,7 +13,6 @@ const { ccclass, property } = cc._decorator;
@
ccclass
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
@
property
(
cc
.
Prefab
)
@
property
(
cc
.
Prefab
)
loadingLayerPrefab
=
null
;
loadingLayerPrefab
=
null
;
...
@@ -25,9 +30,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -25,9 +30,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
_audioResList
.
push
({
url
:
this
.
data
.
waitingTurn
});
this
.
_audioResList
.
push
({
url
:
this
.
data
.
waitingTurn
});
}
}
addPreloadAnima
()
{
addPreloadAnima
()
{}
}
onLoadEnd
()
{
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
...
@@ -39,8 +42,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -39,8 +42,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
_status
=
{
_status
=
{
Red
:
0
,
Red
:
0
,
Blue
:
0
,
Blue
:
0
,
letter
:
''
,
letter
:
""
,
current
:
'
Blue
'
current
:
"
Blue
"
,
};
};
playerId
;
playerId
;
isRoomOwner
;
isRoomOwner
;
...
@@ -48,20 +51,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -48,20 +51,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
networkHelper
:
NetworkHelper
;
networkHelper
:
NetworkHelper
;
async
initData
()
{
async
initData
()
{
this
.
networkHelper
=
new
NetworkHelper
();
this
.
networkHelper
=
new
NetworkHelper
();
this
.
initNetworkListener
();
this
.
initNetworkListener
();
do
{
this
.
playerId
=
await
this
.
networkHelper
.
init
(
'
op_16
'
,
2
);
this
.
playerId
=
await
this
.
networkHelper
.
init
(
"
op_16
"
,
2
);
if
(
this
.
playerId
===
null
)
{
console
.
log
(
"
onDestroy
"
);
this
.
networkHelper
.
onDestroy
();
}
console
.
log
(
"
this.playerId =
"
+
this
.
playerId
);
}
while
(
this
.
playerId
===
null
);
const
room
=
this
.
networkHelper
.
room
;
const
room
=
this
.
networkHelper
.
room
;
if
(
this
.
playerId
==
room
.
roomInfo
.
owner
)
{
if
(
this
.
playerId
==
room
.
roomInfo
.
owner
)
{
console
.
log
(
'
房主
'
);
console
.
log
(
"
房主
"
);
this
.
isRoomOwner
=
true
;
this
.
isRoomOwner
=
true
;
this
.
server
=
new
GameServer
(
2
,
this
.
networkHelper
);
this
.
server
=
new
GameServer
(
2
,
this
.
networkHelper
);
await
this
.
networkHelper
.
startFrameSync
();
await
this
.
networkHelper
.
startFrameSync
();
this
.
server
.
addPlayer
({
this
.
server
.
addPlayer
({
uuid
:
this
.
playerId
,
uuid
:
this
.
playerId
,
isAI
:
false
isAI
:
false
,
});
});
this
.
server
.
startMatch
();
this
.
server
.
startMatch
();
}
}
...
@@ -74,30 +82,35 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -74,30 +82,35 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
initBg
()
{
initBg
()
{
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
bgImg
=
cc
.
find
(
'
Canvas/bgImg
'
);
const
bgImg
=
cc
.
find
(
"
Canvas/bgImg
"
);
bgImg
.
scale
=
Math
.
max
(
canvas
.
width
/
bgImg
.
width
,
canvas
.
height
/
bgImg
.
height
);
bgImg
.
scale
=
Math
.
max
(
canvas
.
width
/
bgImg
.
width
,
canvas
.
height
/
bgImg
.
height
);
const
bg
=
cc
.
find
(
'
Canvas/bg
'
);
const
bg
=
cc
.
find
(
"
Canvas/bg
"
);
bg
.
scale
=
Math
.
min
(
canvas
.
width
/
bg
.
width
,
canvas
.
height
/
bg
.
height
);
bg
.
scale
=
Math
.
min
(
canvas
.
width
/
bg
.
width
,
canvas
.
height
/
bg
.
height
);
const
chessBoardBg
=
cc
.
find
(
'
Canvas/bg/chessBoard/bg
'
);
const
chessBoardBg
=
cc
.
find
(
"
Canvas/bg/chessBoard/bg
"
);
const
offsetX
=
chessBoardBg
.
width
*
chessBoardBg
.
scaleX
/
2
+
(
canvas
.
width
-
chessBoardBg
.
width
*
chessBoardBg
.
scaleX
)
/
4
;
const
offsetX
=
const
lifeblue
=
cc
.
find
(
'
Canvas/bg/Lifeblue
'
);
(
chessBoardBg
.
width
*
chessBoardBg
.
scaleX
)
/
2
+
(
canvas
.
width
-
chessBoardBg
.
width
*
chessBoardBg
.
scaleX
)
/
4
;
const
lifeblue
=
cc
.
find
(
"
Canvas/bg/Lifeblue
"
);
lifeblue
.
x
=
-
offsetX
;
lifeblue
.
x
=
-
offsetX
;
const
lifered
=
cc
.
find
(
'
Canvas/bg/Lifered
'
);
const
lifered
=
cc
.
find
(
"
Canvas/bg/Lifered
"
);
lifered
.
x
=
offsetX
;
lifered
.
x
=
offsetX
;
}
}
loadingLayer
;
loadingLayer
;
initLoadingLayer
()
{
initLoadingLayer
()
{
const
loadingLayerBase
=
cc
.
find
(
'
Canvas/bg/loadingLayerBase
'
);
const
loadingLayerBase
=
cc
.
find
(
"
Canvas/bg/loadingLayerBase
"
);
const
loadingLayerNode
=
cc
.
instantiate
(
this
.
loadingLayerPrefab
);
const
loadingLayerNode
=
cc
.
instantiate
(
this
.
loadingLayerPrefab
);
loadingLayerBase
.
addChild
(
loadingLayerNode
);
loadingLayerBase
.
addChild
(
loadingLayerNode
);
this
.
loadingLayer
=
loadingLayerNode
.
getComponent
(
'
LoadingLayer
'
);
this
.
loadingLayer
=
loadingLayerNode
.
getComponent
(
"
LoadingLayer
"
);
this
.
loadingLayer
.
setMaxPlayerNumber
(
2
);
this
.
loadingLayer
.
setMaxPlayerNumber
(
2
);
this
.
loadingLayer
.
onLoadFinished
(()
=>
{
this
.
loadingLayer
.
onLoadFinished
(()
=>
{
this
.
playAudioByUrl
(
this
.
data
.
gameStartAudio
);
this
.
playAudioByUrl
(
this
.
data
.
gameStartAudio
);
...
@@ -107,85 +120,115 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -107,85 +120,115 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
blinkTheDice
()
{
blinkTheDice
()
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/hatBlink
'
);
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/hatBlink
"
);
cc
.
tween
(
dice
)
cc
.
tween
(
dice
)
.
set
({
opacity
:
0
})
.
set
({
opacity
:
0
})
.
to
(
0.3
,
{
opacity
:
255
})
.
to
(
0.2
,
{
opacity
:
255
})
.
to
(
0.3
,
{
opacity
:
0
})
.
to
(
0.2
,
{
opacity
:
0
})
.
union
()
.
union
()
.
repeatForever
()
.
repeatForever
()
.
start
();
.
start
();
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg
"
).
children
.
forEach
((
node
)
=>
{
cc
.
tween
(
node
)
.
set
({
scale
:
1
})
.
to
(
0.2
,
{
scale
:
1.1
})
.
to
(
0.2
,
{
scale
:
1.0
})
.
union
()
.
repeatForever
()
.
start
();
});
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
[
"
canClick
"
]
=
true
;
}
}
stopBlinkTheDice
()
{
stopBlinkTheDice
()
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/hatBlink
'
);
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/hatBlink
"
);
dice
.
stopAllActions
();
dice
.
stopAllActions
();
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg
"
).
children
.
forEach
((
node
)
=>
{
node
.
stopAllActions
();
node
.
scale
=
1
;
node
.
opacity
=
255
;
});
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
[
"
canClick
"
]
=
false
;
}
}
greyDice
()
{
greyDice
()
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/dice
'
);
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg
"
).
children
.
forEach
((
node
)
=>
{
dice
.
color
=
cc
.
color
(
150
,
150
,
150
);
node
.
color
=
cc
.
color
(
150
,
150
,
150
);
});
}
}
stopGreyDice
()
{
stopGreyDice
()
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/dice
'
);
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg
"
).
children
.
forEach
((
node
)
=>
{
dice
.
color
=
cc
.
color
(
255
,
255
,
255
);
node
.
color
=
cc
.
color
(
255
,
255
,
255
);
});
}
}
initPiece
()
{
initPiece
()
{
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
pieceNodeRed
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceRed`
)
const
pieceNodeRed
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceRed`
);
const
startIdxRed
=
this
.
_status
[
'
Red
'
];
const
startIdxRed
=
this
.
_status
[
"
Red
"
];
const
boardNodeRed
=
board
.
children
[
startIdxRed
];
const
boardNodeRed
=
board
.
children
[
startIdxRed
];
pieceNodeRed
.
x
=
boardNodeRed
.
x
+
offsetX
.
Red
;
pieceNodeRed
.
x
=
boardNodeRed
.
x
+
offsetX
.
Red
;
pieceNodeRed
.
y
=
boardNodeRed
.
y
+
offsetY
.
Red
;
pieceNodeRed
.
y
=
boardNodeRed
.
y
+
offsetY
.
Red
;
const
pieceNodeBlue
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceBlue`
)
const
pieceNodeBlue
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceBlue`
);
const
startIdxBlue
=
this
.
_status
[
'
Blue
'
];
const
startIdxBlue
=
this
.
_status
[
"
Blue
"
];
const
boardNodeBlue
=
board
.
children
[
startIdxBlue
];
const
boardNodeBlue
=
board
.
children
[
startIdxBlue
];
pieceNodeBlue
.
x
=
boardNodeBlue
.
x
+
offsetX
.
Blue
;
pieceNodeBlue
.
x
=
boardNodeBlue
.
x
+
offsetX
.
Blue
;
pieceNodeBlue
.
y
=
boardNodeBlue
.
y
+
offsetY
.
Blue
;
pieceNodeBlue
.
y
=
boardNodeBlue
.
y
+
offsetY
.
Blue
;
}
}
initListener
()
{
initListener
()
{
const
btn
=
cc
.
find
(
'
Canvas/bg/New Button
'
);
const
btn
=
cc
.
find
(
"
Canvas/bg/New Button
"
);
btn
.
on
(
'
click
'
,
async
()
=>
{
btn
.
on
(
"
click
"
,
async
()
=>
{
const
idx
=
RandomInt
(
6
);
const
idx
=
RandomInt
(
6
);
await
this
.
rollTheDice
(
idx
);
await
this
.
rollTheDice
(
idx
);
this
.
_status
.
letter
=
[
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
][
idx
];
console
.
log
(
"
汪汪汪 194
"
);
this
.
_status
.
letter
=
[
"
A
"
,
"
B
"
,
"
C
"
,
"
D
"
,
"
E
"
,
"
F
"
][
idx
];
});
});
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/dice
'
);
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
.
on
(
'
click
'
,
()
=>
{
dice
.
on
(
"
click
"
,
()
=>
{
if
(
this
.
_status
.
letter
!=
''
)
{
if
(
this
.
_status
.
letter
!=
""
)
{
return
;
return
;
}
}
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
if
(
!
dice
[
"
canClick
"
])
{
return
;
}
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
this
.
_status
.
current
==
playerMe
.
color
)
{
if
(
this
.
_status
.
current
==
playerMe
.
color
)
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
roll
'
,
type
:
"
roll
"
,
uuid
:
playerMe
.
uuid
uuid
:
playerMe
.
uuid
,
});
});
}
}
});
});
const
pieceBlue
=
cc
.
find
(
'
Canvas/bg/chessBoard/pieceBlue
'
);
const
pieceBlue
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceBlue
"
);
this
.
addPieceTouchEventListener
(
pieceBlue
,
'
Blue
'
);
this
.
addPieceTouchEventListener
(
pieceBlue
,
"
Blue
"
);
const
pieceRed
=
cc
.
find
(
'
Canvas/bg/chessBoard/pieceRed
'
);
const
pieceRed
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceRed
"
);
this
.
addPieceTouchEventListener
(
pieceRed
,
'
Red
'
);
this
.
addPieceTouchEventListener
(
pieceRed
,
"
Red
"
);
const
coolCat
=
cc
.
find
(
'
Canvas/bg/tree/catBase/cat
'
);
const
coolCat
=
cc
.
find
(
"
Canvas/bg/tree/catBase/cat
"
);
const
catBtn
=
cc
.
find
(
'
Canvas/bg/tree/catBase/catBtn
'
);
const
catBtn
=
cc
.
find
(
"
Canvas/bg/tree/catBase/catBtn
"
);
catBtn
.
on
(
'
click
'
,
async
()
=>
{
catBtn
.
on
(
"
click
"
,
async
()
=>
{
asyncPlayDragonBoneAnimation
(
coolCat
,
'
begin
'
);
asyncPlayDragonBoneAnimation
(
coolCat
,
"
begin
"
);
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
await
this
.
playAudioByUrl
(
this
.
data
.
waitingWheel
);
await
this
.
playAudioByUrl
(
this
.
data
.
waitingWheel
);
}
else
{
}
else
{
await
this
.
playAudioByUrl
(
this
.
data
.
waitingPiece
);
await
this
.
playAudioByUrl
(
this
.
data
.
waitingPiece
);
...
@@ -193,14 +236,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -193,14 +236,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
}
else
{
await
this
.
playAudioByUrl
(
this
.
data
.
waitingTurn
);
await
this
.
playAudioByUrl
(
this
.
data
.
waitingTurn
);
}
}
asyncPlayDragonBoneAnimation
(
coolCat
,
'
normal
'
);
asyncPlayDragonBoneAnimation
(
coolCat
,
"
normal
"
);
});
});
}
}
addPieceTouchEventListener
(
node
:
cc
.
Node
,
color
)
{
addPieceTouchEventListener
(
node
:
cc
.
Node
,
color
)
{
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
this
.
blinkPiece
(
node
);
this
.
blinkPiece
(
node
);
return
;
return
;
...
@@ -209,74 +253,89 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -209,74 +253,89 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
blinkPiece
(
node
);
this
.
blinkPiece
(
node
);
return
;
return
;
}
}
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
this
.
blinkPiece
(
node
);
this
.
blinkPiece
(
node
);
return
;
return
;
}
}
if
(
node
[
'
cantMove
'
])
{
if
(
node
[
"
cantMove
"
])
{
this
.
blinkPiece
(
node
);
return
;
return
;
}
}
this
.
stopRollPiece
(
node
);
this
.
stopRollPiece
(
node
);
node
[
'
touchStartPos
'
]
=
{
node
[
"
touchStartPos
"
]
=
{
nodeX
:
node
.
x
,
nodeX
:
node
.
x
,
nodeY
:
node
.
y
,
nodeY
:
node
.
y
,
touchX
:
event
.
getLocation
().
x
,
touchX
:
event
.
getLocation
().
x
,
touchY
:
event
.
getLocation
().
y
touchY
:
event
.
getLocation
().
y
,
};
};
node
.
zIndex
=
1
;
this
.
showStars
(
node
);
});
});
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
return
;
return
;
}
}
if
(
this
.
_status
.
current
!=
color
)
{
if
(
this
.
_status
.
current
!=
color
)
{
return
;
return
;
}
}
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
return
;
return
;
}
}
if
(
node
[
'
cantMove
'
])
{
if
(
node
[
"
cantMove
"
])
{
return
;
return
;
}
}
const
pos
=
event
.
getLocation
();
const
pos
=
event
.
getLocation
();
const
touchStartPos
=
node
[
'
touchStartPos
'
];
const
touchStartPos
=
node
[
"
touchStartPos
"
];
const
worldNodePos
=
node
.
parent
.
convertToWorldSpaceAR
(
cc
.
v2
(
touchStartPos
.
nodeX
,
touchStartPos
.
nodeY
));
const
worldNodePos
=
node
.
parent
.
convertToWorldSpaceAR
(
const
nodePos
=
node
.
parent
.
convertToNodeSpaceAR
(
cc
.
v2
(
cc
.
v2
(
touchStartPos
.
nodeX
,
touchStartPos
.
nodeY
)
);
const
nodePos
=
node
.
parent
.
convertToNodeSpaceAR
(
cc
.
v2
(
worldNodePos
.
x
+
pos
.
x
-
touchStartPos
.
touchX
,
worldNodePos
.
x
+
pos
.
x
-
touchStartPos
.
touchX
,
worldNodePos
.
y
+
pos
.
y
-
touchStartPos
.
touchY
,
worldNodePos
.
y
+
pos
.
y
-
touchStartPos
.
touchY
))
)
);
node
.
setPosition
(
nodePos
);
node
.
setPosition
(
nodePos
);
});
});
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
async
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
async
(
event
:
cc
.
Event
.
EventTouch
)
=>
{
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
if
(
playerMe
.
color
!=
this
.
_status
.
current
)
{
return
;
return
;
}
}
if
(
this
.
_status
.
current
!=
color
)
{
if
(
this
.
_status
.
current
!=
color
)
{
return
;
return
;
}
}
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
return
;
return
;
}
}
if
(
node
[
'
cantMove
'
])
{
if
(
node
[
"
cantMove
"
])
{
return
;
return
;
}
}
if
(
this
.
checkNodeInRightBlock
(
node
,
color
))
{
if
(
this
.
checkNodeInRightBlock
(
node
,
color
))
{
const
idx
=
this
.
getNextRightIdx
();
const
idx
=
this
.
getNextRightIdx
();
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
right
'
,
type
:
"
right
"
,
idx
:
idx
,
idx
:
idx
,
uuid
:
playerMe
.
uuid
,
uuid
:
playerMe
.
uuid
,
color
:
playerMe
.
color
color
:
playerMe
.
color
,
});
});
}
else
{
}
else
{
node
[
'
cantMove
'
]
=
true
;
node
[
"
cantMove
"
]
=
true
;
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
wrong
'
,
type
:
"
wrong
"
,
uuid
:
playerMe
.
uuid
,
uuid
:
playerMe
.
uuid
,
color
:
playerMe
.
color
color
:
playerMe
.
color
,
});
});
}
}
});
});
...
@@ -303,7 +362,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -303,7 +362,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
repeatForever
()
.
repeatForever
()
.
start
();
.
start
();
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
board
.
children
.
forEach
((
child
:
cc
.
Node
,
idx
,
list
)
=>
{
board
.
children
.
forEach
((
child
:
cc
.
Node
,
idx
,
list
)
=>
{
cc
.
tween
(
child
)
cc
.
tween
(
child
)
.
set
({
scale
:
1.34
})
.
set
({
scale
:
1.34
})
...
@@ -330,12 +389,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -330,12 +389,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
getRightBlock
()
{
getRightBlock
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
console
.
log
(
"
startIdx =
"
+
JSON
.
stringify
(
startIdx
));
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
return
targetNode
;
return
targetNode
;
}
}
...
@@ -344,11 +403,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -344,11 +403,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
getNextRightIdx
()
{
getNextRightIdx
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
return
i
;
return
i
;
}
}
...
@@ -357,56 +416,125 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -357,56 +416,125 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
checkNodeInRightBlock
(
node
,
color
)
{
checkNodeInRightBlock
(
node
,
color
)
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
color
];
const
startIdx
=
this
.
_status
[
color
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
targetNode
.
getBoundingBox
().
intersects
(
node
.
getBoundingBox
()))
{
if
(
targetNode
.
getBoundingBox
().
intersects
(
node
.
getBoundingBox
()))
{
return
true
;
return
true
;
}
}
return
false
return
false
;
}
}
}
return
false
;
}
}
return
false
showStars
(
node
)
{
cc
.
tween
(
node
)
.
delay
(
0.07
)
.
call
(()
=>
{
const
light
=
cc
.
instantiate
(
cc
.
find
(
"
nodes/light
"
));
light
.
parent
=
node
.
parent
;
cc
.
tween
(
light
)
.
set
({
x
:
node
.
x
+
RandomInt
(
200
)
-
100
,
y
:
node
.
y
+
50
,
scale
:
0
,
})
.
by
(
1
,
{
y
:
200
+
RandomInt
(
200
)
-
100
,
scale
:
0.7
+
0.3
*
Math
.
random
(),
},
{
easing
:
"
cubicOut
"
}
)
.
removeSelf
()
.
start
();
})
.
union
()
.
repeatForever
()
.
start
();
}
}
async
pieceFindRightBlock
(
rightBlock
,
idx
)
{
async
pieceFindRightBlock
(
rightBlock
,
idx
)
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
color
=
this
.
_status
.
current
;
const
color
=
this
.
_status
.
current
;
const
piece
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
);
const
piece
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
);
const
prograssbar
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask/prograssbar`
);
const
prograssbar
=
cc
.
find
(
const
mask
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask`
);
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask/prograssbar`
const
targetHeight
=
(
idx
/
(
board
.
children
.
length
-
2
))
*
prograssbar
.
height
;
);
const
mask
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask`
);
const
targetHeight
=
(
idx
/
(
board
.
children
.
length
-
2
))
*
prograssbar
.
height
;
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
console
.
log
(
"
汪汪汪 450
"
);
this
.
_status
[
color
]
=
idx
;
this
.
_status
[
color
]
=
idx
;
await
this
.
playLocalAudio
(
'
正确
'
);
await
this
.
playLocalAudio
(
"
正确
"
);
await
asyncTweenTo
(
piece
,
1
,
{
x
:
rightBlock
.
x
+
offsetX
[
color
],
y
:
rightBlock
.
y
+
offsetY
[
color
]
})
;
piece
.
zIndex
=
1
;
await
this
.
playLocalAudio
(
'
落子
'
);
this
.
showStars
(
piece
);
await
asyncTweenTo
(
piece
,
1
,
{
x
:
rightBlock
.
x
+
offsetX
[
color
],
y
:
rightBlock
.
y
+
offsetY
[
color
],
});
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
const
star
=
cc
.
instantiate
(
cc
.
find
(
"
nodes/star
"
));
star
.
parent
=
piece
.
parent
;
cc
.
tween
(
star
)
.
set
({
x
:
piece
.
x
,
y
:
piece
.
y
+
50
,
scale
:
0
,
})
.
to
(
0.5
,
{
x
:
piece
.
x
+
RandomInt
(
400
)
-
200
,
y
:
piece
.
y
+
50
+
RandomInt
(
400
)
-
200
,
scale
:
0.3
+
0.2
*
Math
.
random
(),
angle
:
RandomInt
(
720
),
},
{
easing
:
"
cubicOut
"
}
)
.
removeSelf
()
.
start
();
}
piece
.
stopAllActions
();
await
this
.
playLocalAudio
(
"
落子
"
);
piece
.
zIndex
=
0
;
const
effectNode
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/effect`
);
const
effectNode
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/effect`
);
effectNode
.
active
=
true
;
effectNode
.
active
=
true
;
asyncTweenTo
(
mask
,
1
,
{
height
:
targetHeight
},
{
easing
:
'
cubicInOut
'
});
asyncTweenTo
(
mask
,
1
,
{
height
:
targetHeight
},
{
easing
:
"
cubicInOut
"
});
this
.
playLocalAudio
(
'
进度条升高
'
);
this
.
playLocalAudio
(
"
进度条升高
"
);
await
asyncPlayDragonBoneAnimation
(
effectNode
,
'
normal
'
,
1
);
await
asyncPlayDragonBoneAnimation
(
effectNode
,
"
normal
"
,
1
);
effectNode
.
active
=
false
;
effectNode
.
active
=
false
;
}
}
updateStatus
(
status
=
null
)
{
updateStatus
(
status
=
null
)
{
if
(
status
)
{
if
(
status
)
{
this
.
_status
=
status
;
console
.
log
(
"
汪汪汪 497
"
);
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
status
));
}
}
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
this
.
stopGreyDice
();
this
.
stopGreyDice
();
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
this
.
showYourTurn
();
this
.
blinkTheDice
();
this
.
blinkTheDice
();
}
else
{
}
else
{
this
.
stopBlinkTheDice
();
this
.
stopBlinkTheDice
();
...
@@ -417,10 +545,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -417,10 +545,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
greyDice
();
this
.
greyDice
();
}
}
const
blueFrame
=
cc
.
find
(
'
Canvas/bg/Lifeblue/faceFrame
'
);
const
blueFrame
=
cc
.
find
(
"
Canvas/bg/Lifeblue/faceFrame
"
);
const
redFrame
=
cc
.
find
(
'
Canvas/bg/Lifered/faceFrame
'
);
const
redFrame
=
cc
.
find
(
"
Canvas/bg/Lifered/faceFrame
"
);
let
blinkFrame
:
cc
.
Node
,
stopBlinkFrame
:
cc
.
Node
;
let
blinkFrame
:
cc
.
Node
,
stopBlinkFrame
:
cc
.
Node
;
if
(
this
.
_status
.
current
==
'
Red
'
)
{
if
(
this
.
_status
.
current
==
"
Red
"
)
{
blinkFrame
=
redFrame
;
blinkFrame
=
redFrame
;
stopBlinkFrame
=
blueFrame
;
stopBlinkFrame
=
blueFrame
;
}
else
{
}
else
{
...
@@ -430,8 +558,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -430,8 +558,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
blinkFrame
.
stopAllActions
();
blinkFrame
.
stopAllActions
();
cc
.
tween
(
blinkFrame
)
cc
.
tween
(
blinkFrame
)
.
set
({
opacity
:
100
})
.
set
({
opacity
:
100
})
.
to
(
1.5
,
{
opacity
:
255
},
{
easing
:
'
cubicOut
'
})
.
to
(
1.5
,
{
opacity
:
255
},
{
easing
:
"
cubicOut
"
})
.
to
(
1.5
,
{
opacity
:
100
},
{
easing
:
'
cubicIn
'
})
.
to
(
1.5
,
{
opacity
:
100
},
{
easing
:
"
cubicIn
"
})
.
union
()
.
union
()
.
repeatForever
()
.
repeatForever
()
.
start
();
.
start
();
...
@@ -440,65 +568,93 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -440,65 +568,93 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
getCurrentPiece
()
{
getCurrentPiece
()
{
if
(
this
.
_status
.
current
==
'
Red
'
)
{
if
(
this
.
_status
.
current
==
"
Red
"
)
{
return
cc
.
find
(
'
Canvas/bg/chessBoard/pieceRed
'
);
return
cc
.
find
(
"
Canvas/bg/chessBoard/pieceRed
"
);
}
else
{
}
else
{
return
cc
.
find
(
'
Canvas/bg/chessBoard/pieceBlue
'
);
return
cc
.
find
(
"
Canvas/bg/chessBoard/pieceBlue
"
);
}
}
}
}
changeSide
()
{
changeSide
()
{
if
(
this
.
_status
.
current
==
'
Red
'
)
{
if
(
this
.
_status
.
current
==
"
Red
"
)
{
this
.
_status
.
current
=
'
Blue
'
;
this
.
_status
.
current
=
"
Blue
"
;
}
else
{
}
else
{
this
.
_status
.
current
=
'
Red
'
;
this
.
_status
.
current
=
"
Red
"
;
}
}
}
}
async
pieceGoBack
(
node
)
{
showYourTurn
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
yourTurn
=
cc
.
find
(
"
Canvas/bg/yourturn
"
);
yourTurn
.
active
=
true
;
cc
.
tween
(
yourTurn
)
.
set
({
opacity
:
0
,
scale
:
5
})
.
to
(
1
,
{
opacity
:
255
,
scale
:
2
})
.
delay
(
0.5
)
.
to
(
0.5
,
{
opacity
:
0
})
.
call
(()
=>
{
resolve
();
})
.
start
();
});
}
const
touchStartPos
=
node
[
'
touchStartPos
'
];
async
pieceGoBack
(
node
)
{
const
touchStartPos
=
node
[
"
touchStartPos
"
];
if
(
!
touchStartPos
)
{
if
(
!
touchStartPos
)
{
return
;
return
;
}
}
this
.
playLocalAudio
(
'
错误弹回
'
);
this
.
playLocalAudio
(
"
错误弹回
"
);
await
asyncTweenTo
(
node
,
0.7
,
{
x
:
touchStartPos
.
nodeX
,
y
:
touchStartPos
.
nodeY
},
{
easing
:
'
cubicOut
'
});
await
asyncTweenTo
(
node
,
0.7
,
{
x
:
touchStartPos
.
nodeX
,
y
:
touchStartPos
.
nodeY
},
{
easing
:
"
cubicOut
"
}
);
node
.
stopAllActions
();
}
}
allPlayerList
;
allPlayerList
;
initNetworkListener
()
{
initNetworkListener
()
{
this
.
networkHelper
.
on
(
'
playerJoin
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
"
playerJoin
"
,
(
event
)
=>
{
if
(
this
.
server
)
{
if
(
this
.
server
)
{
this
.
server
.
onPlayerJoin
(
event
);
this
.
server
.
onPlayerJoin
(
event
);
}
}
cc
.
log
(
"
playerJoin
"
+
JSON
.
stringify
(
event
));
cc
.
log
(
"
playerJoin
"
+
JSON
.
stringify
(
event
));
});
});
this
.
networkHelper
.
on
(
'
playerLeave
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
"
playerLeave
"
,
(
event
)
=>
{
cc
.
log
(
"
playerLeave
"
+
JSON
.
stringify
(
event
));
cc
.
log
(
"
playerLeave
"
+
JSON
.
stringify
(
event
));
});
});
this
.
networkHelper
.
on
(
'
gameStart
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
"
playerOffLine
"
,
(
event
)
=>
{
cc
.
log
(
"
playerOffLine
"
+
JSON
.
stringify
(
event
));
});
});
this
.
networkHelper
.
on
(
'
frameEvent
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
"
gameStart
"
,
(
event
)
=>
{});
event
.
data
.
frame
.
items
.
forEach
(
async
item
=>
{
this
.
networkHelper
.
on
(
"
frameEvent
"
,
(
event
)
=>
{
event
.
data
.
frame
.
items
.
forEach
(
async
(
item
)
=>
{
if
(
this
.
server
)
{
if
(
this
.
server
)
{
this
.
server
.
onFrameEvent
(
item
.
data
);
this
.
server
.
onFrameEvent
(
item
.
data
);
}
}
if
(
item
.
data
.
type
==
'
SERVER_allPlayerInfo
'
)
{
if
(
item
.
data
.
type
==
"
SERVER_allPlayerInfo
"
)
{
console
.
log
(
'
SERVER_allPlayerInfo:
'
+
JSON
.
stringify
(
item
.
data
.
playerData
));
console
.
log
(
item
.
data
.
playerData
.
forEach
(
player
=>
{
"
SERVER_allPlayerInfo:
"
+
JSON
.
stringify
(
item
.
data
.
playerData
)
);
item
.
data
.
playerData
.
forEach
((
player
)
=>
{
if
(
!
this
.
allPlayerList
)
{
if
(
!
this
.
allPlayerList
)
{
this
.
allPlayerList
=
[];
this
.
allPlayerList
=
[];
}
}
if
(
!
this
.
allPlayerList
.
find
(
listPlayer
=>
listPlayer
.
uuid
==
player
.
uuid
))
{
if
(
!
this
.
allPlayerList
.
find
(
(
listPlayer
)
=>
listPlayer
.
uuid
==
player
.
uuid
)
)
{
this
.
allPlayerList
.
push
({
this
.
allPlayerList
.
push
({
uuid
:
player
.
uuid
,
uuid
:
player
.
uuid
,
name
:
player
.
name
,
name
:
player
.
name
,
color
:
player
.
color
,
color
:
player
.
color
,
headUrl
:
player
.
headUrl
headUrl
:
player
.
headUrl
,
});
});
}
}
...
@@ -510,50 +666,83 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -510,50 +666,83 @@ export default class SceneComponent extends MyCocosSceneComponent {
player
.
headUrl
,
player
.
headUrl
,
player
.
uuid
player
.
uuid
);
);
})
});
}
else
if
(
item
.
data
.
type
==
'
SERVER_updateStatus
'
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_updateStatus
"
)
{
console
.
log
(
'
SERVER_updateStatus:
'
+
JSON
.
stringify
(
item
.
data
.
status
));
await
asyncDelay
(
3
);
console
.
log
(
"
SERVER_updateStatus:
"
+
JSON
.
stringify
(
item
.
data
.
status
)
);
this
.
updateStatus
(
item
.
data
.
status
);
this
.
updateStatus
(
item
.
data
.
status
);
}
else
if
(
item
.
data
.
type
==
'
SERVER_playerRoll
'
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerRoll
"
)
{
console
.
log
(
'
SERVER_playerRoll:
'
+
JSON
.
stringify
(
item
.
data
));
console
.
log
(
"
SERVER_playerRoll:
"
+
JSON
.
stringify
(
item
.
data
));
const
status
=
this
.
_status
;
const
status
=
this
.
_status
;
console
.
log
(
"
汪汪汪 647
"
);
status
.
letter
=
item
.
data
.
letter
;
status
.
letter
=
item
.
data
.
letter
;
const
idx
=
[
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
].
findIndex
(
letter
=>
letter
==
status
.
letter
);
console
.
log
(
"
status.letter =
"
+
status
.
letter
);
console
.
log
(
"
item.data.letter =
"
+
item
.
data
.
letter
);
const
idx
=
[
"
A
"
,
"
B
"
,
"
C
"
,
"
D
"
,
"
E
"
,
"
F
"
].
findIndex
(
(
letter
)
=>
letter
==
status
.
letter
);
const
pieceRed
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceRed
"
);
const
pieceBlue
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceBlue
"
);
pieceRed
[
"
cantMove
"
]
=
true
;
pieceBlue
[
"
cantMove
"
]
=
true
;
this
.
stopBlinkTheDice
();
console
.
log
(
"
status1 =
"
+
JSON
.
stringify
(
status
));
await
this
.
rollTheDice
(
idx
);
await
this
.
rollTheDice
(
idx
);
pieceRed
[
"
cantMove
"
]
=
false
;
pieceBlue
[
"
cantMove
"
]
=
false
;
console
.
log
(
"
status2 =
"
+
JSON
.
stringify
(
status
));
console
.
log
(
"
this._status =
"
+
JSON
.
stringify
(
this
.
_status
));
this
.
updateStatus
(
status
);
this
.
updateStatus
(
status
);
}
else
if
(
item
.
data
.
type
==
'
SERVER_playerRight
'
)
{
console
.
log
(
"
status =
"
+
JSON
.
stringify
(
status
));
console
.
log
(
'
SERVER_playerRight:
'
+
JSON
.
stringify
(
item
.
data
));
console
.
log
(
"
this._status =
"
+
JSON
.
stringify
(
this
.
_status
));
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerRight
"
)
{
console
.
log
(
"
SERVER_playerRight:
"
+
JSON
.
stringify
(
item
.
data
));
console
.
log
(
"
this._status =
"
+
JSON
.
stringify
(
this
.
_status
));
const
rightBlock
=
this
.
getRightBlock
();
const
rightBlock
=
this
.
getRightBlock
();
console
.
log
(
rightBlock
);
const
idx
=
this
.
getNextRightIdx
();
const
idx
=
this
.
getNextRightIdx
();
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
console
.
log
(
idx
);
this
.
_status
.
letter
=
''
;
await
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
this
.
_status
.
letter
=
""
;
console
.
log
(
"
汪汪汪672
"
);
this
.
changeSide
();
this
.
changeSide
();
this
.
updateStatus
();
this
.
updateStatus
();
}
else
if
(
item
.
data
.
type
==
'
SERVER_playerWrong
'
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWrong
"
)
{
console
.
log
(
'
SERVER_playerWrong:
'
+
JSON
.
stringify
(
item
.
data
));
console
.
log
(
"
SERVER_playerWrong:
"
+
JSON
.
stringify
(
item
.
data
));
const
node
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
this
.
_status
.
current
}
`
);
const
node
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
this
.
_status
.
current
}
`
);
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
await
this
.
pieceGoBack
(
node
);
await
this
.
pieceGoBack
(
node
);
}
else
{
}
else
{
this
.
rollPieceOnce
(
node
);
this
.
rollPieceOnce
(
node
);
}
}
node
[
'
cantMove
'
]
=
false
;
node
[
"
cantMove
"
]
=
false
;
this
.
_status
.
letter
=
''
;
console
.
log
(
"
汪汪汪 691
"
);
this
.
_status
.
letter
=
""
;
this
.
changeSide
();
this
.
changeSide
();
this
.
updateStatus
();
this
.
updateStatus
();
}
else
if
(
item
.
data
.
type
==
'
SERVER_playerWin
'
)
{
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerWin
"
)
{
console
.
log
(
'
SERVER_playerWin:
'
+
JSON
.
stringify
(
item
.
data
));
console
.
log
(
"
SERVER_playerWin:
"
+
JSON
.
stringify
(
item
.
data
));
const
node
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
this
.
_status
.
current
}
`
);
const
node
=
cc
.
find
(
const
playerMe
=
this
.
allPlayerList
.
find
(
player
=>
player
.
uuid
==
this
.
playerId
);
`Canvas/bg/chessBoard/piece
${
this
.
_status
.
current
}
`
);
const
playerMe
=
this
.
allPlayerList
.
find
(
(
player
)
=>
player
.
uuid
==
this
.
playerId
);
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
idx
=
board
.
children
.
length
;
const
idx
=
board
.
children
.
length
;
const
rightBlock
=
board
.
children
[
idx
-
1
];
const
rightBlock
=
board
.
children
[
idx
-
1
];
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
await
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
if
(
playerMe
.
color
==
this
.
_status
.
current
)
{
this
.
showWin
();
this
.
showWin
();
}
else
{
}
else
{
...
@@ -565,30 +754,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -565,30 +754,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
showWin
()
{
showWin
()
{
const
bg
=
cc
.
find
(
'
Canvas/endBg
'
);
cc
.
find
(
"
Canvas/endBg
"
).
active
=
true
;
cc
.
tween
(
bg
)
const
bg
=
cc
.
find
(
"
Canvas/endBg/bg
"
);
.
to
(
1
,
{
opacity
:
255
})
cc
.
tween
(
bg
).
to
(
1
,
{
opacity
:
100
}).
start
();
.
start
();
const
loss
=
cc
.
find
(
"
Canvas/endBg/labelBg/labelLoss
"
);
const
loss
=
cc
.
find
(
'
Canvas/endBg/bg/bg/labelLoss
'
);
loss
.
active
=
false
;
loss
.
active
=
false
;
this
.
playLocalAudio
(
'
胜利
'
);
this
.
playLocalAudio
(
"
胜利
"
);
}
}
showLoss
()
{
showLoss
()
{
const
bg
=
cc
.
find
(
'
Canvas/endBg
'
);
cc
.
find
(
"
Canvas/endBg
"
).
active
=
true
;
cc
.
tween
(
bg
)
const
bg
=
cc
.
find
(
"
Canvas/endBg/bg
"
);
.
to
(
1
,
{
opacity
:
255
})
cc
.
tween
(
bg
).
to
(
1
,
{
opacity
:
100
}).
start
();
.
start
();
const
win
=
cc
.
find
(
"
Canvas/endBg/labelBg/labelWin
"
);
const
win
=
cc
.
find
(
'
Canvas/endBg/bg/bg/labelWin
'
);
win
.
active
=
false
;
win
.
active
=
false
;
this
.
playLocalAudio
(
'
失败
'
);
this
.
playLocalAudio
(
"
失败
"
);
}
}
loadPlayerHeadImage
()
{
loadPlayerHeadImage
()
{
const
red
=
cc
.
find
(
'
Canvas/bg/Lifered/faceRed
'
);
const
red
=
cc
.
find
(
"
Canvas/bg/Lifered/faceRed
"
);
const
blue
=
cc
.
find
(
'
Canvas/bg/Lifeblue/faceBlue
'
);
const
blue
=
cc
.
find
(
"
Canvas/bg/Lifeblue/faceBlue
"
);
this
.
allPlayerList
.
forEach
(
player
=>
{
this
.
allPlayerList
.
forEach
((
player
)
=>
{
this
.
getSpriteFrimeByUrl
(
player
.
headUrl
,
(
sf
)
=>
{
this
.
getSpriteFrimeByUrl
(
player
.
headUrl
,
(
sf
)
=>
{
if
(
player
.
color
==
'
Red
'
)
{
if
(
player
.
color
==
"
Red
"
)
{
red
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
red
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
}
else
{
}
else
{
blue
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
blue
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
...
@@ -600,28 +787,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -600,28 +787,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
async
movePiece
(
letter
,
color
)
{
async
movePiece
(
letter
,
color
)
{
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
pieceNode
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
)
const
pieceNode
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
);
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
color
];
const
startIdx
=
this
.
_status
[
color
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
const
prograssbar
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask/prograssbar`
);
const
prograssbar
=
cc
.
find
(
const
mask
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask`
);
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask/prograssbar`
);
const
mask
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask`
);
const
targetHeight
=
(
i
/
board
.
children
.
length
)
*
prograssbar
.
height
;
const
targetHeight
=
(
i
/
board
.
children
.
length
)
*
prograssbar
.
height
;
cc
.
tween
(
mask
)
cc
.
tween
(
mask
)
.
to
(
1
,
{
height
:
targetHeight
},
{
easing
:
'
cubicInOut
'
})
.
to
(
1
,
{
height
:
targetHeight
},
{
easing
:
"
cubicInOut
"
})
.
start
();
.
start
();
await
asyncTweenTo
(
pieceNode
,
1
,
{
await
asyncTweenTo
(
pieceNode
,
1
,
{
x
:
targetNode
.
x
+
offsetX
[
color
],
x
:
targetNode
.
x
+
offsetX
[
color
],
y
:
targetNode
.
y
+
offsetY
[
color
]
y
:
targetNode
.
y
+
offsetY
[
color
],
},
{
easing
:
'
cubicInOut
'
});
},
{
easing
:
"
cubicInOut
"
}
);
if
(
itemData
.
letter
.
toLowerCase
()
==
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
letter
.
toLowerCase
())
{
this
.
_status
[
color
]
=
i
;
this
.
_status
[
color
]
=
i
;
console
.
log
(
"
汪汪汪 784
"
);
return
;
return
;
}
}
}
}
...
@@ -633,15 +831,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -633,15 +831,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
rollTheDice
(
num
)
{
rollTheDice
(
num
)
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/dice
'
);
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
if
(
dice
[
'
cantRoll
'
])
{
if
(
dice
[
"
cantRoll
"
])
{
return
;
return
;
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
targetAngle
=
Math
.
ceil
(
dice
.
angle
/
360
+
1
)
*
360
;
const
targetAngle
=
Math
.
ceil
(
dice
.
angle
/
360
+
1
)
*
360
;
const
time
=
(
targetAngle
-
360
-
dice
.
angle
)
/
360
;
const
time
=
(
targetAngle
-
360
-
dice
.
angle
)
/
360
;
dice
[
'
cantRoll
'
]
=
true
;
dice
[
"
cantRoll
"
]
=
true
;
cc
.
tween
(
dice
)
cc
.
tween
(
dice
)
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicIn
"
})
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicIn
"
})
...
@@ -650,10 +848,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -650,10 +848,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
/
6
*
num
,
{
angle
:
60
*
num
})
.
by
((
1
/
6
)
*
num
,
{
angle
:
60
*
num
})
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicOut
"
})
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicOut
"
})
.
call
(()
=>
{
.
call
(()
=>
{
dice
[
'
cantRoll
'
]
=
false
;
dice
[
"
cantRoll
"
]
=
false
;
resolve
(
null
);
resolve
(
null
);
})
})
.
start
();
.
start
();
...
@@ -661,13 +859,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -661,13 +859,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`audioClips/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
const
audio
=
cc
.
find
(
`audioClips/
${
audioName
}
`
)
.
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
id
=
cc
.
audioEngine
.
playEffect
(
audio
.
clip
,
false
);
const
id
=
cc
.
audioEngine
.
playEffect
(
audio
.
clip
,
false
);
cc
.
audioEngine
.
setFinishCallback
(
id
,
()
=>
{
cc
.
audioEngine
.
setFinishCallback
(
id
,
()
=>
{
resolve
(
id
);
resolve
(
id
);
});
});
})
});
}
}
// 生命周期
// 生命周期
...
...
assets/op_16/script/AI.ts
View file @
912c2a58
...
@@ -7,8 +7,8 @@ export class AI {
...
@@ -7,8 +7,8 @@ export class AI {
_status
=
{
_status
=
{
Red
:
0
,
Red
:
0
,
Blue
:
0
,
Blue
:
0
,
letter
:
''
,
letter
:
""
,
current
:
'
Blue
'
current
:
"
Blue
"
,
};
};
constructor
(
networkHelper
:
NetworkHelper
,
playerData
:
any
)
{
constructor
(
networkHelper
:
NetworkHelper
,
playerData
:
any
)
{
...
@@ -17,44 +17,47 @@ export class AI {
...
@@ -17,44 +17,47 @@ export class AI {
}
}
async
onFrameEvent
(
event
)
{
async
onFrameEvent
(
event
)
{
console
.
log
(
'
AI get event:
'
+
JSON
.
stringify
(
event
));
console
.
log
(
"
AI get event:
"
+
JSON
.
stringify
(
event
));
if
(
event
.
type
==
'
SERVER_updateStatus
'
)
{
if
(
event
.
type
==
"
SERVER_updateStatus
"
)
{
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
event
.
status
));
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
event
.
status
));
}
else
if
(
event
.
type
==
'
SERVER_playerRoll
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerRoll
"
)
{
console
.
log
(
'
汪汪汪0
'
);
this
.
_status
.
letter
=
event
.
letter
;
this
.
_status
.
letter
=
event
.
letter
;
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
await
asyncDelay
(
Math
.
random
()
*
3
+
1
1
);
await
asyncDelay
(
Math
.
random
()
*
3
+
1
2
);
}
}
}
else
if
(
event
.
type
==
'
SERVER_playerRight
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerRight
"
)
{
this
.
_status
.
letter
=
''
;
console
.
log
(
'
汪汪汪1
'
);
this
.
_status
.
letter
=
""
;
this
.
_status
[
event
.
color
]
=
event
.
idx
;
this
.
_status
[
event
.
color
]
=
event
.
idx
;
this
.
changeSide
();
this
.
changeSide
();
}
else
if
(
event
.
type
==
'
SERVER_playerWrong
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerWrong
"
)
{
this
.
_status
.
letter
=
''
;
console
.
log
(
'
汪汪汪2
'
);
this
.
_status
.
letter
=
""
;
this
.
changeSide
();
this
.
changeSide
();
}
}
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
await
asyncDelay
(
Math
.
random
()
*
3
+
2
);
await
asyncDelay
(
Math
.
random
()
*
3
+
4
);
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
roll
'
,
type
:
"
roll
"
,
uuid
:
this
.
playerData
.
uuid
uuid
:
this
.
playerData
.
uuid
,
});
});
}
else
{
}
else
{
const
idx
=
this
.
getNextRightIdx
();
const
idx
=
this
.
getNextRightIdx
();
if
(
Math
.
random
()
>
0.5
)
{
if
(
Math
.
random
()
<
0.9
)
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
right
'
,
type
:
"
right
"
,
idx
:
idx
,
idx
:
idx
,
uuid
:
this
.
playerData
.
uuid
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
color
:
this
.
playerData
.
color
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
wrong
'
,
type
:
"
wrong
"
,
uuid
:
this
.
playerData
.
uuid
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
color
:
this
.
playerData
.
color
,
});
});
}
}
}
}
...
@@ -62,19 +65,19 @@ export class AI {
...
@@ -62,19 +65,19 @@ export class AI {
}
}
changeSide
()
{
changeSide
()
{
if
(
this
.
_status
.
current
==
'
Red
'
)
{
if
(
this
.
_status
.
current
==
"
Red
"
)
{
this
.
_status
.
current
=
'
Blue
'
;
this
.
_status
.
current
=
"
Blue
"
;
}
else
{
}
else
{
this
.
_status
.
current
=
'
Red
'
;
this
.
_status
.
current
=
"
Red
"
;
}
}
}
}
getNextRightIdx
()
{
getNextRightIdx
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
return
i
;
return
i
;
}
}
...
...
assets/op_16/script/LoadingLayer.ts
View file @
912c2a58
...
@@ -97,6 +97,7 @@ export default class SceneComponent extends cc.Component {
...
@@ -97,6 +97,7 @@ export default class SceneComponent extends cc.Component {
cc
.
find
(
'
right
'
,
this
.
node
).
addChild
(
headNode
);
cc
.
find
(
'
right
'
,
this
.
node
).
addChild
(
headNode
);
const
vs
=
cc
.
find
(
'
vs
'
,
this
.
node
);
const
vs
=
cc
.
find
(
'
vs
'
,
this
.
node
);
asyncPlayDragonBoneAnimation
(
vs
,
'
normal
'
,
1
);
asyncPlayDragonBoneAnimation
(
vs
,
'
normal
'
,
1
);
this
.
playLocalAudio
(
'
match
'
);
}
}
const
rate
=
Math
.
min
(
1
,
this
.
_playerList
.
length
/
this
.
_maxPlayerNum
);
const
rate
=
Math
.
min
(
1
,
this
.
_playerList
.
length
/
this
.
_maxPlayerNum
);
...
@@ -231,6 +232,25 @@ export default class SceneComponent extends cc.Component {
...
@@ -231,6 +232,25 @@ export default class SceneComponent extends cc.Component {
}
}
});
});
}
}
playLocalAudio
(
name
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
stopCurrentPlayedAudio
();
const
audioNode
=
cc
.
find
(
`res/
${
name
}
`
,
this
.
node
);
if
(
!
audioNode
)
{
resolve
(
null
);
return
;
}
const
audioClip
=
audioNode
.
getComponent
(
cc
.
AudioSource
).
clip
;
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
currentPlayedAudioId
=
audioId
;
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
resolve
(
null
);
});
});
}
_timeoutIds
=
[];
_timeoutIds
=
[];
_intervalIds
=
[];
_intervalIds
=
[];
// 生命周期
// 生命周期
...
...
assets/op_16/script/NetworkHelper.ts
View file @
912c2a58
import
{
Base64
}
from
"
js-base64
"
;
import
{
Base64
}
from
"
js-base64
"
;
export
class
NetworkHelper
{
export
class
NetworkHelper
{
_eventListeners
:
any
=
{};
_eventListeners
:
any
=
{};
ctor
()
{
}
ctor
()
{}
on
(
eventName
,
func
)
{
on
(
eventName
,
func
)
{
this
.
_eventListeners
[
eventName
]
=
func
;
this
.
_eventListeners
[
eventName
]
=
func
;
}
}
async
init
(
roomType
:
string
,
maxPlayers
:
number
)
{
async
init
(
roomType
:
string
,
maxPlayers
:
number
)
{
this
.
initRoom
();
try
{
try
{
return
await
this
.
joinRoom
(
roomType
,
maxPlayers
);
}
catch
(
e
)
{
await
this
.
initListener
();
this
.
initRoom
();
this
.
initRoom
();
await
this
.
initListener
();
return
await
this
.
joinRoom
(
roomType
,
maxPlayers
);
return
await
this
.
joinRoom
(
roomType
,
maxPlayers
);
}
catch
(
e
)
{
// return null;
}
}
}
}
...
@@ -28,6 +25,7 @@ export class NetworkHelper {
...
@@ -28,6 +25,7 @@ export class NetworkHelper {
async
stopGame
()
{
async
stopGame
()
{
await
this
.
stopFrameSync
();
await
this
.
stopFrameSync
();
await
this
.
closeRoom
();
await
this
.
leaveRoom
();
await
this
.
leaveRoom
();
}
}
...
@@ -35,7 +33,14 @@ export class NetworkHelper {
...
@@ -35,7 +33,14 @@ export class NetworkHelper {
return
this
.
room
.
roomInfo
;
return
this
.
room
.
roomInfo
;
}
}
listenerInited
=
false
;
initListener
()
{
initListener
()
{
if
(
this
.
listenerInited
)
{
return
;
}
// MGOBE.Listener;
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
gameId
=
"
obg-i4ql53h1
"
;
//替换为控制台上的 游戏 ID
const
gameId
=
"
obg-i4ql53h1
"
;
//替换为控制台上的 游戏 ID
const
openId
=
"
openid_op_16
"
+
Math
.
random
();
const
openId
=
"
openid_op_16
"
+
Math
.
random
();
...
@@ -44,50 +49,58 @@ export class NetworkHelper {
...
@@ -44,50 +49,58 @@ export class NetworkHelper {
gameId
:
gameId
,
gameId
:
gameId
,
openId
:
openId
,
openId
:
openId
,
createSignature
:
(
callback
)
=>
{
createSignature
:
(
callback
)
=>
{
this
.
callNetworkApiGet
(
'
http://staging-teach.ireadabc.com
'
,
'
/api/oxford/game/v1/config
'
,
{
this
.
callNetworkApiGet
(
"
http://staging-teach.ireadabc.com
"
,
"
/api/oxford/game/v1/config
"
,
{
gameid
:
gameId
,
gameid
:
gameId
,
openid
:
openId
,
openid
:
openId
,
},
(
data
)
=>
{
},
(
data
)
=>
{
callback
(
JSON
.
parse
(
data
));
callback
(
JSON
.
parse
(
data
));
});
}
}
);
},
};
};
const
serverUrl
=
"
i4ql53h1.wxlagame.com
"
;
//替换为控制台上的 域名
const
serverUrl
=
"
i4ql53h1.wxlagame.com
"
;
//替换为控制台上的 域名
const
config
=
{
const
config
=
{
url
:
serverUrl
,
url
:
serverUrl
,
reconnectMaxTimes
:
5
,
reconnectMaxTimes
:
3
,
reconnectInterval
:
1000
,
reconnectInterval
:
1000
,
resendInterval
:
1000
,
resendInterval
:
1000
,
resendTimeout
:
10
000
,
resendTimeout
:
5
000
,
cacertNativeUrl
:
""
cacertNativeUrl
:
""
,
};
};
MGOBE
.
DebuggerLog
.
enable
=
false
;
MGOBE
.
DebuggerLog
.
enable
=
false
;
// 如果是原生平台,则加载 Cert 证书,否则会提示 WSS 错误
// 如果是原生平台,则加载 Cert 证书,否则会提示 WSS 错误
if
(
cc
.
sys
.
isNative
)
{
if
(
cc
.
sys
.
isNative
)
{
let
cacertFile
;
let
cacertFile
;
const
cacertNode
=
cc
.
find
(
'
cacertNode
'
);
const
cacertNode
=
cc
.
find
(
"
cacertNode
"
);
if
(
cacertNode
)
{
if
(
cacertNode
)
{
cacertFile
=
cacertNode
.
getComponent
(
'
cacert
'
).
cacertFile
;
cacertFile
=
cacertNode
.
getComponent
(
"
cacert
"
).
cacertFile
;
}
}
if
(
!
cacertFile
)
{
if
(
!
cacertFile
)
{
console
.
log
(
'
没有cacertFile!!!
'
);
console
.
log
(
"
没有cacertFile!!!
"
);
}
}
config
.
cacertNativeUrl
=
cc
.
loader
.
md5Pipe
&&
cc
.
ENGINE_VERSION
<
"
2.4.0
"
?
config
.
cacertNativeUrl
=
cc
.
loader
.
md5Pipe
.
transformURL
(
cacertFile
.
nativeUrl
)
:
cc
.
loader
.
md5Pipe
&&
cc
.
ENGINE_VERSION
<
"
2.4.0
"
cacertFile
.
nativeUrl
;
?
cc
.
loader
.
md5Pipe
.
transformURL
(
cacertFile
.
nativeUrl
)
:
cacertFile
.
nativeUrl
;
}
}
MGOBE
.
Listener
.
init
(
gameInfo
,
config
,
event
=>
{
console
.
log
(
"
initListener
"
);
MGOBE
.
Listener
.
init
(
gameInfo
,
config
,
(
event
)
=>
{
console
.
log
(
JSON
.
stringify
(
event
));
console
.
log
(
JSON
.
stringify
(
event
));
if
(
event
.
code
!==
0
)
{
if
(
event
.
code
!==
0
)
{
console
.
log
(
"
初始化失败:
"
+
event
.
code
);
console
.
log
(
"
初始化失败:
"
+
event
.
code
);
reject
();
reject
();
return
;
return
;
}
}
this
.
listenerInited
=
true
;
console
.
log
(
"
初始化成功
"
);
console
.
log
(
"
初始化成功
"
);
resolve
(
null
);
resolve
(
null
);
});
});
...
@@ -101,14 +114,16 @@ export class NetworkHelper {
...
@@ -101,14 +114,16 @@ export class NetworkHelper {
this
.
room
.
onJoinRoom
=
this
.
onJoinRoom
.
bind
(
this
);
this
.
room
.
onJoinRoom
=
this
.
onJoinRoom
.
bind
(
this
);
this
.
room
.
onLeaveRoom
=
this
.
onLeaveRoom
.
bind
(
this
);
this
.
room
.
onLeaveRoom
=
this
.
onLeaveRoom
.
bind
(
this
);
this
.
room
.
onRecvFromClient
=
this
.
onRecvFromClient
.
bind
(
this
);
this
.
room
.
onRecvFromClient
=
this
.
onRecvFromClient
.
bind
(
this
);
this
.
room
.
onChangePlayerNetworkState
=
this
.
onChangePlayerNetworkState
.
bind
(
this
);
this
.
room
.
onRecvFrame
=
this
.
onRecvFrame
.
bind
(
this
);
this
.
room
.
onRecvFrame
=
this
.
onRecvFrame
.
bind
(
this
);
this
.
room
.
onStartFrameSync
=
this
.
onStartFrameSync
.
bind
(
this
);
this
.
room
.
onStartFrameSync
=
this
.
onStartFrameSync
.
bind
(
this
);
this
.
room
.
onStopFrameSync
=
this
.
onStopFrameSync
.
bind
(
this
);
this
.
room
.
onStopFrameSync
=
this
.
onStopFrameSync
.
bind
(
this
);
this
.
room
.
onRecvFromGameSvr
=
this
.
onRecvFromGameSvr
.
bind
(
this
);
this
.
room
.
onRecvFromGameSvr
=
this
.
onRecvFromGameSvr
.
bind
(
this
);
console
.
log
(
'
this.room =
'
+
JSON
.
stringify
(
this
.
room
.
roomInfo
));
console
.
log
(
"
this.room =
"
+
JSON
.
stringify
(
this
.
room
.
roomInfo
));
}
}
joinRoom
(
roomType
:
string
,
maxPlayers
:
number
,
customData
:
string
=
''
)
{
joinRoom
(
roomType
:
string
,
maxPlayers
:
number
,
customData
:
string
=
""
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
playerName
=
"
Tom
"
+
Math
.
random
();
const
playerName
=
"
Tom
"
+
Math
.
random
();
const
playerInfo
=
{
const
playerInfo
=
{
...
@@ -120,27 +135,44 @@ export class NetworkHelper {
...
@@ -120,27 +135,44 @@ export class NetworkHelper {
const
matchRoomPara
=
{
const
matchRoomPara
=
{
playerInfo
,
playerInfo
,
maxPlayers
:
maxPlayers
,
maxPlayers
:
maxPlayers
,
roomType
:
roomType
roomType
:
roomType
,
};
};
this
.
room
.
matchRoom
(
matchRoomPara
,
event
=>
{
this
.
room
.
matchRoom
(
matchRoomPara
,
async
(
event
)
=>
{
// console.log(JSON.stringify(event))
// console.log(JSON.stringify(event))
if
(
event
.
code
===
0
)
{
if
(
event
.
code
!==
0
)
{
cc
.
log
(
"
匹配成功:
"
+
event
.
data
.
roomInfo
.
id
);
const
player
=
event
.
data
.
roomInfo
.
playerList
.
find
(
player
=>
player
.
name
==
playerName
);
resolve
(
player
.
id
);
}
else
{
cc
.
log
(
"
匹配失败
"
);
cc
.
log
(
"
匹配失败
"
);
reject
(
event
);
reject
(
event
);
return
;
}
const
roomInfo
=
event
.
data
.
roomInfo
;
cc
.
log
(
"
匹配成功:
"
+
roomInfo
.
id
);
const
player
=
roomInfo
.
playerList
.
find
(
(
player
)
=>
player
.
name
==
playerName
);
if
(
roomInfo
.
owner
==
player
.
id
)
{
console
.
log
(
"
房主:
"
+
player
.
id
);
resolve
(
player
.
id
);
return
;
}
}
if
(
roomInfo
.
playerList
.
length
==
1
)
{
console
.
log
(
"
空房间
"
);
await
this
.
leaveRoom
();
await
this
.
closeRoom
();
resolve
(
null
);
return
;
}
resolve
(
player
.
id
);
});
});
});
});
}
}
leaveRoom
()
{
leaveRoom
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
room
.
leaveRoom
({},
event
=>
{
this
.
room
.
leaveRoom
({},
(
event
)
=>
{
console
.
log
(
JSON
.
stringify
(
event
))
console
.
log
(
JSON
.
stringify
(
event
))
;
if
(
event
.
code
===
0
)
{
if
(
event
.
code
===
0
)
{
console
.
log
(
"
退房成功
"
+
this
.
room
.
roomInfo
.
id
);
console
.
log
(
"
退房成功
"
+
this
.
room
.
roomInfo
.
id
);
// this.room.initRoom();
// this.room.initRoom();
...
@@ -152,10 +184,24 @@ export class NetworkHelper {
...
@@ -152,10 +184,24 @@ export class NetworkHelper {
});
});
}
}
dismissRoom
()
{
const
roomInfo
=
this
.
room
.
roomInfo
;
const
player
=
roomInfo
.
playerList
.
find
(
(
player
)
=>
player
.
name
==
playerName
);
if
(
roomInfo
.
owner
==
player
.
id
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
room
.
dismissRoom
({},
(
res
)
=>
{
console
.
log
(
"
房间已解散
"
);
});
});
}
}
closeRoom
()
{
closeRoom
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
room
.
changeRoom
({
isForbidJoin
:
true
},
(
event
)
=>
{
this
.
room
.
changeRoom
({
isForbidJoin
:
true
},
(
event
)
=>
{
console
.
log
(
'
关门
'
)
console
.
log
(
"
关门
"
);
// console.log(JSON.stringify(event))
// console.log(JSON.stringify(event))
resolve
(
null
);
resolve
(
null
);
});
});
...
@@ -166,15 +212,15 @@ export class NetworkHelper {
...
@@ -166,15 +212,15 @@ export class NetworkHelper {
const
sendToClientPara
=
{
const
sendToClientPara
=
{
recvType
:
MGOBE
.
ENUM
.
RecvType
.
ROOM_ALL
,
recvType
:
MGOBE
.
ENUM
.
RecvType
.
ROOM_ALL
,
recvPlayerList
:
[],
recvPlayerList
:
[],
msg
:
"
hello
"
+
Math
.
random
()
msg
:
"
hello
"
+
Math
.
random
()
,
};
};
this
.
room
.
sendToClient
(
sendToClientPara
,
event
=>
console
.
log
(
event
));
this
.
room
.
sendToClient
(
sendToClientPara
,
(
event
)
=>
console
.
log
(
event
));
}
}
startFrameSync
()
{
startFrameSync
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
room
.
startFrameSync
({},
event
=>
{
this
.
room
.
startFrameSync
({},
(
event
)
=>
{
console
.
log
(
JSON
.
stringify
(
event
))
console
.
log
(
JSON
.
stringify
(
event
))
;
if
(
event
.
code
===
0
)
{
if
(
event
.
code
===
0
)
{
cc
.
log
(
"
开始帧同步成功,请到控制台查看具体帧同步信息
"
);
cc
.
log
(
"
开始帧同步成功,请到控制台查看具体帧同步信息
"
);
resolve
(
null
);
resolve
(
null
);
...
@@ -191,8 +237,8 @@ export class NetworkHelper {
...
@@ -191,8 +237,8 @@ export class NetworkHelper {
resolve
(
null
);
resolve
(
null
);
return
;
return
;
}
}
this
.
room
.
stopFrameSync
({},
event
=>
{
this
.
room
.
stopFrameSync
({},
(
event
)
=>
{
console
.
log
(
JSON
.
stringify
(
event
))
console
.
log
(
JSON
.
stringify
(
event
))
;
if
(
event
.
code
===
0
)
{
if
(
event
.
code
===
0
)
{
console
.
log
(
"
停止帧同步成功
"
);
console
.
log
(
"
停止帧同步成功
"
);
resolve
(
null
);
resolve
(
null
);
...
@@ -207,69 +253,94 @@ export class NetworkHelper {
...
@@ -207,69 +253,94 @@ export class NetworkHelper {
sendToServer
()
{
sendToServer
()
{
const
sendToGameServerPara
=
{
const
sendToGameServerPara
=
{
data
:
{
data
:
{
cmd
:
1
cmd
:
1
,
}
}
,
};
};
this
.
room
.
sendToGameSvr
(
sendToGameServerPara
,
event
=>
console
.
log
(
event
));
this
.
room
.
sendToGameSvr
(
sendToGameServerPara
,
(
event
)
=>
console
.
log
(
event
)
);
}
}
sendFrame
(
data
:
any
)
{
sendFrame
(
data
:
any
)
{
this
.
room
.
sendFrame
({
data
},
err
=>
{
this
.
room
.
sendFrame
({
data
},
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
"
err
"
,
err
)
console
.
log
(
"
err
"
,
err
)
;
}
}
});
});
}
}
onJoinRoom
(
event
)
{
onJoinRoom
(
event
)
{
if
(
this
.
_eventListeners
[
'
playerJoin
'
])
{
if
(
this
.
_eventListeners
[
"
playerJoin
"
])
{
this
.
_eventListeners
[
'
playerJoin
'
](
event
);
this
.
_eventListeners
[
"
playerJoin
"
](
event
);
}
}
console
.
log
(
"
新玩家加入
"
,
event
.
data
.
joinPlayerId
);
console
.
log
(
"
新玩家加入
"
,
event
.
data
.
joinPlayerId
);
}
}
onLeaveRoom
(
event
)
{
onLeaveRoom
(
event
)
{
if
(
this
.
_eventListeners
[
'
playerLeave
'
])
{
console
.
log
(
"
onLeaveRoom
"
);
this
.
_eventListeners
[
'
playerLeave
'
](
event
);
if
(
this
.
_eventListeners
[
"
playerLeave
"
])
{
this
.
_eventListeners
[
"
playerLeave
"
](
event
);
}
}
console
.
log
(
"
玩家退出
"
,
event
.
data
.
leavePlayerId
);
console
.
log
(
"
玩家退出
"
,
event
.
data
.
leavePlayerId
);
}
}
onRecvFromClient
()
{
}
onRecvFromClient
()
{}
onChangePlayerNetworkState
(
event
)
{
console
.
log
(
"
玩家网络变化:
"
+
JSON
.
stringify
(
event
));
const
changePlayer
=
event
.
data
.
roomInfo
.
playerList
.
find
(
(
player
)
=>
player
.
id
==
event
.
data
.
changePlayerId
);
if
(
changePlayer
.
commonNetworkState
==
MGOBE
.
types
.
NetworkState
.
COMMON_OFFLINE
||
changePlayer
.
relayNetworkState
==
MGOBE
.
types
.
NetworkState
.
RELAY_OFFLINE
)
{
if
(
this
.
_eventListeners
[
"
playerOffLine
"
])
{
this
.
_eventListeners
[
"
playerOffLine
"
](
event
);
}
cc
.
log
(
"
掉线了
"
);
}
else
{
// resolve(player.id);
}
}
onRecvFrame
(
event
)
{
onRecvFrame
(
event
)
{
if
(
this
.
_eventListeners
[
'
frameEvent
'
])
{
if
(
this
.
_eventListeners
[
"
frameEvent
"
])
{
this
.
_eventListeners
[
'
frameEvent
'
](
event
);
this
.
_eventListeners
[
"
frameEvent
"
](
event
);
}
}
}
}
onStartFrameSync
(
event
)
{
onStartFrameSync
(
event
)
{
if
(
this
.
_eventListeners
[
'
gameStart
'
])
{
if
(
this
.
_eventListeners
[
"
gameStart
"
])
{
this
.
_eventListeners
[
'
gameStart
'
](
event
);
this
.
_eventListeners
[
"
gameStart
"
](
event
);
}
}
}
}
onStopFrameSync
(
event
)
{
}
onStopFrameSync
(
event
)
{}
onRecvFromGameSvr
()
{
}
onRecvFromGameSvr
()
{}
async
onDestroy
()
{
async
onDestroy
()
{
try
{
try
{
console
.
log
(
'
onDestroy1
'
)
console
.
log
(
"
onDestroy1
"
);
this
.
dismissRoom
();
MGOBE
.
Listener
.
clear
();
MGOBE
.
Listener
.
clear
();
await
this
.
stopGame
();
this
.
stopFrameSync
();
console
.
log
(
'
onDestroy2
'
)
this
.
closeRoom
();
this
.
leaveRoom
();
console
.
log
(
"
onDestroy2
"
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
JSON
.
stringify
(
e
));
console
.
log
(
JSON
.
stringify
(
e
));
}
}
}
}
log
(
str
)
{
log
(
str
)
{
const
node
=
cc
.
find
(
'
middleLayer
'
);
const
node
=
cc
.
find
(
"
middleLayer
"
);
if
(
node
)
{
if
(
node
)
{
node
.
getComponent
(
'
middleLayer
'
).
log
(
str
);
node
.
getComponent
(
"
middleLayer
"
).
log
(
str
);
}
else
{
}
else
{
cc
.
log
(
str
);
cc
.
log
(
str
);
}
}
}
}
callNetworkApiGet
(
baseUrl
,
uri
,
data
,
callBack
)
{
callNetworkApiGet
(
baseUrl
,
uri
,
data
,
callBack
)
{
let
queryStr
=
'
?
'
;
let
queryStr
=
"
?
"
;
const
params
=
[];
const
params
=
[];
for
(
const
key
in
data
)
{
for
(
const
key
in
data
)
{
if
(
Object
.
hasOwnProperty
.
call
(
data
,
key
))
{
if
(
Object
.
hasOwnProperty
.
call
(
data
,
key
))
{
...
@@ -279,13 +350,24 @@ export class NetworkHelper {
...
@@ -279,13 +350,24 @@ export class NetworkHelper {
queryStr
+=
params
.
join
(
"
&
"
);
queryStr
+=
params
.
join
(
"
&
"
);
const
xhr
=
new
XMLHttpRequest
();
const
xhr
=
new
XMLHttpRequest
();
xhr
.
onreadystatechange
=
()
=>
{
xhr
.
onreadystatechange
=
()
=>
{
if
(
xhr
.
readyState
==
4
&&
(
xhr
.
status
>=
200
&&
xhr
.
status
<
400
)
)
{
if
(
xhr
.
readyState
==
4
&&
xhr
.
status
>=
200
&&
xhr
.
status
<
400
)
{
callBack
(
xhr
.
responseText
);
callBack
(
xhr
.
responseText
);
}
}
};
};
const
url
=
`
${
baseUrl
}${
uri
}${
queryStr
}
`
;
const
url
=
`
${
baseUrl
}${
uri
}${
queryStr
}
`
;
console
.
log
(
'
url =
'
+
url
);
console
.
log
(
"
url =
"
+
url
);
xhr
.
open
(
'
GET
'
,
url
,
true
);
xhr
.
open
(
"
GET
"
,
url
,
true
);
xhr
.
send
();
xhr
.
send
();
}
}
}
}
export
function
asyncDelay
(
time
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
tween
(
cc
.
find
(
"
Canvas
"
))
.
delay
(
time
)
.
call
(()
=>
{
resolve
();
})
.
start
();
});
}
assets/op_16/script/Server.ts
View file @
912c2a58
...
@@ -7,16 +7,25 @@ export class GameServer {
...
@@ -7,16 +7,25 @@ export class GameServer {
playerMaxNumber
=
0
;
playerMaxNumber
=
0
;
networkHelper
:
NetworkHelper
=
null
;
networkHelper
:
NetworkHelper
=
null
;
nameList
=
[
nameList
=
[
'
Chris
'
,
'
Benny
'
,
'
Leslie
'
,
'
Devin
'
,
'
Sam
'
,
"
Chris
"
,
'
Kerry
'
,
'
Joey
'
,
'
Hailey
'
,
'
Fred
'
,
'
Arrow
'
,
"
Benny
"
,
'
Tony
'
,
'
Michael
'
,
"
Leslie
"
,
"
Devin
"
,
"
Sam
"
,
"
Kerry
"
,
"
Joey
"
,
"
Hailey
"
,
"
Fred
"
,
"
Arrow
"
,
"
Tony
"
,
"
Michael
"
,
];
];
headUrls
=
[
headUrls
=
[
'
http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png
'
,
"
http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f596e586a31ac2813b1702557941c022.png
'
,
"
http://staging-teach.cdn.ireadabc.com/f596e586a31ac2813b1702557941c022.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f0f396c52c42239913fd94523db979fa.png
'
,
"
http://staging-teach.cdn.ireadabc.com/f0f396c52c42239913fd94523db979fa.png
"
,
'
http://staging-teach.cdn.ireadabc.com/9f2d2ef622fa33d4e2abcbdc4b40ab6a.png
'
,
"
http://staging-teach.cdn.ireadabc.com/9f2d2ef622fa33d4e2abcbdc4b40ab6a.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
'
"
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
"
,
];
];
constructor
(
playerMaxNumber
,
networkHelper
)
{
constructor
(
playerMaxNumber
,
networkHelper
)
{
...
@@ -33,19 +42,20 @@ export class GameServer {
...
@@ -33,19 +42,20 @@ export class GameServer {
}
}
async
addPlayer
(
player
)
{
async
addPlayer
(
player
)
{
console
.
log
(
'
addPlayer
'
);
console
.
log
(
"
addPlayer
"
);
this
.
playerList
.
push
({
this
.
playerList
.
push
({
name
:
this
.
nameList
.
splice
(
0
,
1
)[
0
],
name
:
this
.
nameList
.
splice
(
0
,
1
)[
0
],
uuid
:
player
.
uuid
,
uuid
:
player
.
uuid
,
color
:
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
'
Blue
'
:
'
Red
'
,
color
:
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
"
Blue
"
:
"
Red
"
,
isAI
:
player
.
isAI
,
isAI
:
player
.
isAI
,
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
]
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
]
,
});
});
await
asyncDelay
(
1
);
await
asyncDelay
(
1
);
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_allPlayerInfo
'
,
type
:
"
SERVER_allPlayerInfo
"
,
playerData
:
this
.
playerList
playerData
:
this
.
playerList
,
});
});
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
...
@@ -59,83 +69,90 @@ export class GameServer {
...
@@ -59,83 +69,90 @@ export class GameServer {
gameStatus
=
{
gameStatus
=
{
Red
:
0
,
Red
:
0
,
Blue
:
0
,
Blue
:
0
,
letter
:
''
,
letter
:
""
,
current
:
'
Blue
'
current
:
"
Blue
"
,
};
};
startGame
()
{
startGame
()
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_updateStatus
'
,
type
:
"
SERVER_updateStatus
"
,
status
:
this
.
gameStatus
status
:
this
.
gameStatus
,
});
});
}
}
onPlayerJoin
(
event
)
{
onPlayerJoin
(
event
)
{
this
.
addPlayer
({
this
.
addPlayer
({
uuid
:
event
.
data
.
joinPlayerId
,
uuid
:
event
.
data
.
joinPlayerId
,
isAI
:
false
isAI
:
false
,
});
});
}
}
_aiPlayerList
=
[];
_aiPlayerList
=
[];
startMatch
()
{
startMatch
()
{
for
(
let
i
=
0
;
i
<
this
.
playerMaxNumber
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
playerMaxNumber
;
i
++
)
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
const
count
=
this
.
playerMaxNumber
-
this
.
playerList
.
length
;
const
count
=
this
.
playerMaxNumber
-
this
.
playerList
.
length
;
if
(
count
>
0
)
{
if
(
count
>
0
)
{
const
playerInfo
=
{
const
playerInfo
=
{
uuid
:
'
ai_
'
+
i
,
uuid
:
"
ai_
"
+
i
,
isAI
:
true
,
isAI
:
true
,
color
:
'
Red
'
color
:
"
Red
"
,
}
};
this
.
_aiPlayerList
.
push
(
new
AI
(
this
.
networkHelper
,
playerInfo
));
this
.
_aiPlayerList
.
push
(
new
AI
(
this
.
networkHelper
,
playerInfo
));
this
.
addPlayer
(
playerInfo
);
this
.
addPlayer
(
playerInfo
);
}
}
},
RandomInt
(
10000
,
15000
)));
},
RandomInt
(
10000
,
15000
))
);
}
}
}
}
onFrameEvent
(
data
)
{
onFrameEvent
(
data
)
{
if
(
data
.
type
==
'
roll
'
)
{
if
(
this
.
gameStatus
.
gameOver
)
{
return
;
}
if
(
data
.
type
==
"
roll
"
)
{
const
letterList
=
this
.
getLetterList
();
const
letterList
=
this
.
getLetterList
();
if
(
letterList
.
length
>
0
)
{
if
(
letterList
.
length
>
0
)
{
const
letter
=
letterList
[
RandomInt
(
letterList
.
length
)];
const
letter
=
letterList
[
RandomInt
(
letterList
.
length
)];
this
.
gameStatus
.
letter
=
letter
;
this
.
gameStatus
.
letter
=
letter
;
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerRoll
'
,
type
:
"
SERVER_playerRoll
"
,
letter
:
letter
letter
:
letter
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWin
'
,
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
color
:
this
.
gameStatus
.
current
,
});
});
this
.
gameStatus
.
gameOver
=
true
;
}
}
}
else
if
(
data
.
type
==
'
right
'
)
{
}
else
if
(
data
.
type
==
"
right
"
)
{
this
.
gameStatus
[
data
.
color
]
=
data
.
idx
;
this
.
gameStatus
[
data
.
color
]
=
data
.
idx
;
const
letterList
=
this
.
getLetterList
();
const
letterList
=
this
.
getLetterList
();
console
.
log
(
'
letterList =
'
+
JSON
.
stringify
(
letterList
));
console
.
log
(
"
letterList =
"
+
JSON
.
stringify
(
letterList
));
if
(
letterList
.
length
>
0
)
{
if
(
letterList
.
length
>
0
)
{
this
.
changeSide
();
this
.
changeSide
();
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerRight
'
,
type
:
"
SERVER_playerRight
"
,
idx
:
data
.
idx
,
idx
:
data
.
idx
,
uuid
:
data
.
uuid
,
uuid
:
data
.
uuid
,
color
:
data
.
color
color
:
data
.
color
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWin
'
,
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
color
:
this
.
gameStatus
.
current
,
});
});
this
.
gameStatus
.
gameOver
=
true
;
}
}
}
else
if
(
data
.
type
==
'
wrong
'
)
{
}
else
if
(
data
.
type
==
"
wrong
"
)
{
console
.
log
(
'
data =
'
+
JSON
.
stringify
(
data
));
console
.
log
(
"
data =
"
+
JSON
.
stringify
(
data
));
// this.gameStatus[data.color] = data.idx;
// this.gameStatus[data.color] = data.idx;
this
.
changeSide
();
this
.
changeSide
();
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWrong
'
,
type
:
"
SERVER_playerWrong
"
,
uuid
:
data
.
uuid
,
uuid
:
data
.
uuid
,
color
:
data
.
color
color
:
data
.
color
,
});
});
}
else
{
}
else
{
this
.
_aiPlayerList
.
forEach
((
ai
:
AI
)
=>
{
this
.
_aiPlayerList
.
forEach
((
ai
:
AI
)
=>
{
...
@@ -145,19 +162,19 @@ export class GameServer {
...
@@ -145,19 +162,19 @@ export class GameServer {
}
}
getLetterList
()
{
getLetterList
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
color
=
this
.
gameStatus
.
current
;
const
color
=
this
.
gameStatus
.
current
;
console
.
log
(
"
color =
"
+
color
);
console
.
log
(
"
color =
"
+
color
);
console
.
log
(
'
this.gameStatus =
'
+
JSON
.
stringify
(
this
.
gameStatus
));
console
.
log
(
"
this.gameStatus =
"
+
JSON
.
stringify
(
this
.
gameStatus
));
const
startIdx
=
this
.
gameStatus
[
color
];
const
startIdx
=
this
.
gameStatus
[
color
];
console
.
log
(
'
startIdx =
'
+
startIdx
);
console
.
log
(
"
startIdx =
"
+
startIdx
);
const
letterList
=
[];
const
letterList
=
[];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
const
nodeLetter
=
itemData
.
letter
.
toUpperCase
();
const
nodeLetter
=
itemData
.
letter
.
toUpperCase
();
if
(
!
letterList
.
find
(
letter
=>
letter
==
nodeLetter
))
{
if
(
!
letterList
.
find
(
(
letter
)
=>
letter
==
nodeLetter
))
{
letterList
.
push
(
nodeLetter
);
letterList
.
push
(
nodeLetter
);
}
}
}
}
...
@@ -165,29 +182,27 @@ export class GameServer {
...
@@ -165,29 +182,27 @@ export class GameServer {
}
}
changeSide
()
{
changeSide
()
{
if
(
this
.
gameStatus
.
current
==
'
Red
'
)
{
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
current
=
'
Blue
'
;
this
.
gameStatus
.
current
=
"
Blue
"
;
}
else
{
}
else
{
this
.
gameStatus
.
current
=
'
Red
'
;
this
.
gameStatus
.
current
=
"
Red
"
;
}
}
}
}
startAI
()
{
startAI
()
{
this
.
playerList
this
.
playerList
.
filter
(
player
=>
player
.
isAI
==
true
)
.
filter
((
player
)
=>
player
.
isAI
==
true
)
.
forEach
(
player
=>
{
.
forEach
((
player
)
=>
{});
});
}
}
_timeoutIds
=
null
;
_timeoutIds
=
null
;
_intervalIds
=
null
;
_intervalIds
=
null
;
// 生命周期
// 生命周期
onDestroy
()
{
onDestroy
()
{
this
.
_timeoutIds
.
forEach
(
id
=>
{
this
.
_timeoutIds
.
forEach
(
(
id
)
=>
{
clearTimeout
(
id
);
clearTimeout
(
id
);
});
});
this
.
_intervalIds
.
forEach
(
id
=>
{
this
.
_intervalIds
.
forEach
(
(
id
)
=>
{
clearInterval
(
id
);
clearInterval
(
id
);
});
});
}
}
...
...
assets/op_16/textures/yourturn.png
0 → 100644
View file @
912c2a58
30.3 KB
assets/op_16/textures/yourturn.png.meta
0 → 100644
View file @
912c2a58
{
"ver": "2.3.5",
"uuid": "e1c1011c-37ad-47ab-b75c-0528fb58912e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 584,
"height": 235,
"platformSettings": {},
"subMetas": {
"yourturn": {
"ver": "1.0.4",
"uuid": "eeb8a1d1-4858-4241-8733-38b1cff4c7cf",
"rawTextureUuid": "e1c1011c-37ad-47ab-b75c-0528fb58912e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 584,
"height": 235,
"rawWidth": 584,
"rawHeight": 235,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
package-lock.json
View file @
912c2a58
...
@@ -616,6 +616,11 @@
...
@@ -616,6 +616,11 @@
"mime-types"
:
"~2.1.24"
"mime-types"
:
"~2.1.24"
}
}
},
},
"typescript"
:
{
"version"
:
"4.5.5"
,
"resolved"
:
"https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz"
,
"integrity"
:
"sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA=="
},
"unpipe"
:
{
"unpipe"
:
{
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz"
,
"resolved"
:
"https://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz"
,
...
...
package.json
View file @
912c2a58
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
"
crypto-js
"
:
"
^4.1.1
"
,
"
crypto-js
"
:
"
^4.1.1
"
,
"
express
"
:
"
^4.17.1
"
,
"
express
"
:
"
^4.17.1
"
,
"
js-base64
"
:
"
^3.7.2
"
,
"
js-base64
"
:
"
^3.7.2
"
,
"
typescript
"
:
"
^4.5.5
"
,
"
uuid
"
:
"
^8.3.2
"
"
uuid
"
:
"
^8.3.2
"
}
}
}
}
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