Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DropAndMergeTheNumber
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Nguyễn Quang Sáng
DropAndMergeTheNumber
Commits
630b55b0
Commit
630b55b0
authored
Oct 04, 2023
by
Nguyễn Quang Sáng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
04/10/23 commit
parent
58ede0d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
238 additions
and
874 deletions
+238
-874
gameplay.fire
assets/Scenes/gameplay.fire
+172
-822
GameController.ts
assets/Scripts/Controllers/GameController.ts
+38
-50
BlockData.ts
assets/Scripts/Data/BlockData.ts
+27
-0
Block.ts
assets/Scripts/Objects/Block.ts
+1
-2
No files found.
assets/Scenes/gameplay.fire
View file @
630b55b0
...
@@ -84,22 +84,25 @@
...
@@ -84,22 +84,25 @@
"__id__": 55
"__id__": 55
},
},
{
{
"__id__":
87
"__id__":
72
},
},
{
{
"__id__": 8
"__id__": 8
},
},
{
{
"__id__": 41
"__id__": 41
},
{
"__id__": 84
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
99
"__id__":
86
},
},
{
{
"__id__":
100
"__id__":
87
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -526,7 +529,7 @@
...
@@ -526,7 +529,7 @@
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0,
0,
-
183.087
,
-
224.784
,
0,
0,
0,
0,
0,
0,
...
@@ -2408,7 +2411,7 @@
...
@@ -2408,7 +2411,7 @@
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0,
0,
2
83.135
,
2
41.438
,
0,
0,
0,
0,
0,
0,
...
@@ -3053,24 +3056,6 @@
...
@@ -3053,24 +3056,6 @@
},
},
{
{
"__id__": 70
"__id__": 70
},
{
"__id__": 72
},
{
"__id__": 74
},
{
"__id__": 76
},
{
"__id__": 78
},
{
"__id__": 80
},
{
"__id__": 82
}
}
],
],
"_active": true,
"_active": true,
...
@@ -3123,100 +3108,6 @@
...
@@ -3123,100 +3108,6 @@
"groupIndex": 0,
"groupIndex": 0,
"_id": "17p2XK/FJB9LjuqIXx8s7V"
"_id": "17p2XK/FJB9LjuqIXx8s7V"
},
},
{
"__type__": "cc.Node",
"_name": "BG",
"_objFlags": 0,
"_parent": {
"__id__": 55
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 57
}
],
"_prefab": null,
"_opacity": 200,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 640,
"height": 180
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
500,
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": "2eKGie6F1KGorSy3XPz6PL"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 56
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "f06e40bc-cc5a-4ced-a739-503a3d09363f"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "f69JF2OsFP2Z/9JMgelBeO"
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "ButtonPause",
"_name": "ButtonPause",
...
@@ -3228,7 +3119,7 @@
...
@@ -3228,7 +3119,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 5
9
"__id__": 5
7
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3284,7 +3175,7 @@
...
@@ -3284,7 +3175,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 5
8
"__id__": 5
6
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3322,7 +3213,7 @@
...
@@ -3322,7 +3213,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
61
"__id__":
59
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3378,7 +3269,7 @@
...
@@ -3378,7 +3269,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
60
"__id__":
58
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3416,7 +3307,7 @@
...
@@ -3416,7 +3307,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 6
3
"__id__": 6
1
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3472,7 +3363,7 @@
...
@@ -3472,7 +3363,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 6
2
"__id__": 6
0
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3510,7 +3401,7 @@
...
@@ -3510,7 +3401,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 6
5
"__id__": 6
3
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3566,7 +3457,7 @@
...
@@ -3566,7 +3457,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 6
4
"__id__": 6
2
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3605,7 +3496,7 @@
...
@@ -3605,7 +3496,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 6
7
"__id__": 6
5
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3661,7 +3552,7 @@
...
@@ -3661,7 +3552,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 6
6
"__id__": 6
4
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3699,7 +3590,7 @@
...
@@ -3699,7 +3590,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 6
9
"__id__": 6
7
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3755,7 +3646,7 @@
...
@@ -3755,7 +3646,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 6
8
"__id__": 6
6
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3794,7 +3685,7 @@
...
@@ -3794,7 +3685,7 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
71
"__id__":
69
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3850,7 +3741,7 @@
...
@@ -3850,7 +3741,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
70
"__id__":
68
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3879,7 +3770,7 @@
...
@@ -3879,7 +3770,7 @@
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "Coin",
"_name": "Coin
Label
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 55
"__id__": 55
...
@@ -3888,22 +3779,22 @@
...
@@ -3888,22 +3779,22 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 7
3
"__id__": 7
1
}
}
],
],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
"__type__": "cc.Color",
"__type__": "cc.Color",
"r":
255
,
"r":
139
,
"g":
255
,
"g":
148
,
"b": 2
55
,
"b": 2
00
,
"a": 255
"a": 255
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
49
,
"width":
34.25
,
"height":
50
"height":
37.8
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -3914,7 +3805,7 @@
...
@@ -3914,7 +3805,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
1
27.43
2,
1
95.22
2,
482,
482,
0,
0,
0,
0,
...
@@ -3937,14 +3828,14 @@
...
@@ -3937,14 +3828,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
4ctaJXeRBBKJ3KyTqTnKVB
"
"_id": "
f2qNuXKCdKkb5Qf2GU73aA
"
},
},
{
{
"__type__": "cc.
Sprite
",
"__type__": "cc.
Label
",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 7
2
"__id__": 7
0
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -3954,50 +3845,69 @@
...
@@ -3954,50 +3845,69 @@
],
],
"_srcBlendFactor": 770,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_dstBlendFactor": 771,
"_spriteFrame": {
"_string": "20",
"__uuid__": "720e0100-c499-4026-be6d-7c5f0b9c4661"
"_N$string": "20",
},
"_fontSize": 30,
"_type": 0,
"_lineHeight": 30,
"_sizeMode": 1,
"_enableWrapText": true,
"_fillType": 0,
"_N$file": {
"_fillCenter": {
"__uuid__": "6f0d4d99-b207-4755-9233-a2544dc7a038"
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
},
"_fillStart": 0,
"_isSystemFontUsed": false,
"_fillRange": 0,
"_spacingX": 0,
"_isTrimmedMode": true,
"_batchAsBitmap": false,
"_atlas": null,
"_styleFlags": 0,
"_id": "6dLde2dhhIf4dyEU3Ya/7A"
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "6cWiJoWiJIpo8mOSt5AQIK"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
Plus
",
"_name": "
BGStartBar
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
55
"__id__":
2
},
},
"_children": [],
"_children": [
{
"__id__": 73
},
{
"__id__": 75
},
{
"__id__": 77
},
{
"__id__": 79
},
{
"__id__": 81
}
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
75
"__id__":
83
}
}
],
],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
"__type__": "cc.Color",
"__type__": "cc.Color",
"r":
0
,
"r":
255
,
"g": 255,
"g": 255,
"b":
94
,
"b":
255
,
"a": 255
"a": 255
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
3
0,
"width":
55
0,
"height":
3
0
"height":
10
0
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -4008,8 +3918,8 @@
...
@@ -4008,8 +3918,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
141.355
,
0
,
469.585
,
146.786
,
0,
0,
0,
0,
0,
0,
...
@@ -4031,514 +3941,35 @@
...
@@ -4031,514 +3941,35 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "49wfClXhxPM5Z8iY0S0RAW"
"_id": "75rheVHKRPfq4fowOjQRpm"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 74
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a7b930b1-c853-41c8-99b7-7dc0ae10aa48"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "72T8tKz6RIw7+b6xPmKdCL"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
CoinLabel
",
"_name": "
StartPoint
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
55
"__id__":
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 7
7
"__id__": 7
4
}
}
],
],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
"__type__": "cc.Color",
"__type__": "cc.Color",
"r": 139,
"r": 255,
"g": 148,
"g": 255,
"b": 200,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 34.25,
"height": 37.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
195.222,
482,
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": "f2qNuXKCdKkb5Qf2GU73aA"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 76
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "20",
"_N$string": "20",
"_fontSize": 30,
"_lineHeight": 30,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "6f0d4d99-b207-4755-9233-a2544dc7a038"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "6cWiJoWiJIpo8mOSt5AQIK"
},
{
"__type__": "cc.Node",
"_name": "ButtonShop",
"_objFlags": 0,
"_parent": {
"__id__": 55
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 79
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 76,
"height": 76
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
263.326,
482,
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": "18W8vbnNFA+r8s2QhGACuj"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 78
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "170b0a6b-0a15-4579-9ac0-52ee45b163bc"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "4d6iiF2BtBnqFfVGd55qF8"
},
{
"__type__": "cc.Node",
"_name": "Cart",
"_objFlags": 0,
"_parent": {
"__id__": 55
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 81
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 43,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
263.326,
482,
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": "c3VYEZ24lOGI2BDIbwHoyn"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 80
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "e652632c-c6e6-4fd2-a278-4c209da80438"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "a7H69u6LJGyq2JuJCJSZL1"
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 55
},
"_children": [
{
"__id__": 83
},
{
"__id__": 85
}
],
"_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": "95oS2nxNxOXY4u7oeZBt5p"
},
{
"__type__": "cc.Node",
"_name": "Score",
"_objFlags": 0,
"_parent": {
"__id__": 82
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 84
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 139,
"g": 148,
"b": 200,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 54.01,
"height": 18.9
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-124.882,
525.812,
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": "d62LqWlB1LNIevtQdUQrIf"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 83
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "SCORE",
"_N$string": "SCORE",
"_fontSize": 15,
"_lineHeight": 15,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "9bde507c-0766-4844-ae73-02962a0559d3"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "ebZwIW0fNB94HKWm1cgV7T"
},
{
"__type__": "cc.Node",
"_name": "Highest",
"_objFlags": 0,
"_parent": {
"__id__": 82
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 86
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 139,
"g": 148,
"b": 200,
"a": 255
"a": 255
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
68.46
,
"width":
50
,
"height":
18.9
"height":
38
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -4549,8 +3980,8 @@
...
@@ -4549,8 +3980,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
19.877
,
0
,
525.812
,
0
,
0,
0,
0,
0,
0,
0,
...
@@ -4572,14 +4003,14 @@
...
@@ -4572,14 +4003,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
f9JwvPasxN74U+iWnfc9wn
"
"_id": "
7aYzhPbphHs6vCbVlfcv6/
"
},
},
{
{
"__type__": "cc.
Label
",
"__type__": "cc.
Sprite
",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
85
"__id__":
73
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -4589,116 +4020,35 @@
...
@@ -4589,116 +4020,35 @@
],
],
"_srcBlendFactor": 770,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_dstBlendFactor": 771,
"_string": "HIGHEST",
"_spriteFrame": {
"_N$string": "HIGHEST",
"__uuid__": "198639e5-9950-4d01-b8c5-732441df6eab"
"_fontSize": 15,
"_lineHeight": 15,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "9bde507c-0766-4844-ae73-02962a0559d3"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "7fG5vqOOdDZL6hrawB9UK4"
},
{
"__type__": "cc.Node",
"_name": "BGStartBar",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 88
},
{
"__id__": 90
},
{
"__id__": 92
},
{
"__id__": 94
},
{
"__id__": 96
}
],
"_active": true,
"_components": [
{
"__id__": 98
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 550,
"height": 100
},
},
"_anchorPoint": {
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
188.483,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"x": 0,
"y": 0,
"y": 0
"z": 0
},
},
"_skewX": 0,
"_fillStart": 0,
"_skewY": 0,
"_fillRange": 0,
"_is3DNode": false,
"_isTrimmedMode": true,
"_groupIndex": 0,
"_atlas": null,
"groupIndex": 0,
"_id": "90PlneBCZP3ryp74WYDNXc"
"_id": "75rheVHKRPfq4fowOjQRpm"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "StartPoint",
"_name": "StartPoint",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
87
"__id__":
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
89
"__id__":
76
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -4724,7 +4074,7 @@
...
@@ -4724,7 +4074,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0
,
-101.164
,
0,
0,
0,
0,
0,
0,
...
@@ -4747,14 +4097,14 @@
...
@@ -4747,14 +4097,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
7aYzhPbphHs6vCbVlfcv6/
"
"_id": "
e8qRdmjY5LEpdJLoA3yLei
"
},
},
{
{
"__type__": "cc.Sprite",
"__type__": "cc.Sprite",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
88
"__id__":
75
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -4779,20 +4129,20 @@
...
@@ -4779,20 +4129,20 @@
"_fillRange": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "
90PlneBCZP3ryp74WYDNXc
"
"_id": "
2a2MnjpRVILpGetjUs/ZmN
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "StartPoint",
"_name": "StartPoint",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
87
"__id__":
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
91
"__id__":
78
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -4818,7 +4168,7 @@
...
@@ -4818,7 +4168,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
-
101.164
,
-
209.478
,
0,
0,
0,
0,
0,
0,
...
@@ -4841,14 +4191,14 @@
...
@@ -4841,14 +4191,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
e8qRdmjY5LEpdJLoA3yLei
"
"_id": "
04tLuyTNpI3pfWuRyF81um
"
},
},
{
{
"__type__": "cc.Sprite",
"__type__": "cc.Sprite",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
90
"__id__":
77
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -4873,20 +4223,20 @@
...
@@ -4873,20 +4223,20 @@
"_fillRange": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "
2a2MnjpRVILpGetjUs/ZmN
"
"_id": "
6dLjpfb+xIWJ5pakXgu/A+
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "StartPoint",
"_name": "StartPoint",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
87
"__id__":
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
93
"__id__":
80
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -4912,7 +4262,7 @@
...
@@ -4912,7 +4262,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
-209.478
,
107.554
,
0,
0,
0,
0,
0,
0,
...
@@ -4935,14 +4285,14 @@
...
@@ -4935,14 +4285,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
04tLuyTNpI3pfWuRyF81um
"
"_id": "
b4BMgDOlVMuKpwmqzvlREp
"
},
},
{
{
"__type__": "cc.Sprite",
"__type__": "cc.Sprite",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
92
"__id__":
79
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -4967,20 +4317,20 @@
...
@@ -4967,20 +4317,20 @@
"_fillRange": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "
6dLjpfb+xIWJ5pakXgu/A+
"
"_id": "
abgCRCkoNInLPvEijBx9Gg
"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "StartPoint",
"_name": "StartPoint",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
87
"__id__":
72
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
95
"__id__":
82
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -5006,7 +4356,7 @@
...
@@ -5006,7 +4356,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
107.554
,
213.589
,
0,
0,
0,
0,
0,
0,
...
@@ -5029,14 +4379,14 @@
...
@@ -5029,14 +4379,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
b4BMgDOlVMuKpwmqzvlREp
"
"_id": "
7erdK6yYBBwoEYQILaxax4
"
},
},
{
{
"__type__": "cc.Sprite",
"__type__": "cc.Sprite",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
94
"__id__":
81
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5061,35 +4411,67 @@
...
@@ -5061,35 +4411,67 @@
"_fillRange": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "abgCRCkoNInLPvEijBx9Gg"
"_id": "63naLwjBBDN4xWnUAgXvmI"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 72
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "72614e26-8584-481b-be35-1a58541bca6e"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "ffT/lwHsxIW6+GwJhXeFXP"
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
StartPoint
",
"_name": "
Cover
",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
87
"__id__":
2
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__":
97
"__id__":
85
}
}
],
],
"_prefab": null,
"_prefab": null,
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
"__type__": "cc.Color",
"__type__": "cc.Color",
"r":
255
,
"r":
48
,
"g":
255
,
"g":
54
,
"b":
255
,
"b":
77
,
"a": 255
"a": 255
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width": 50,
"width": 5
5
0,
"height":
38
"height":
106
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -5100,8 +4482,8 @@
...
@@ -5100,8 +4482,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
213.589,
0,
0,
241.438,
0,
0,
0,
0,
0,
0,
...
@@ -5123,14 +4505,14 @@
...
@@ -5123,14 +4505,14 @@
"_is3DNode": false,
"_is3DNode": false,
"_groupIndex": 0,
"_groupIndex": 0,
"groupIndex": 0,
"groupIndex": 0,
"_id": "
7erdK6yYBBwoEYQILaxax4
"
"_id": "
ddj4q73t1KLqyxHuQe7axp
"
},
},
{
{
"__type__": "cc.Sprite",
"__type__": "cc.Sprite",
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__":
96
"__id__":
84
},
},
"_enabled": true,
"_enabled": true,
"_materials": [
"_materials": [
...
@@ -5141,7 +4523,7 @@
...
@@ -5141,7 +4523,7 @@
"_srcBlendFactor": 770,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_dstBlendFactor": 771,
"_spriteFrame": {
"_spriteFrame": {
"__uuid__": "
198639e5-9950-4d01-b8c5-732441df6eab
"
"__uuid__": "
a23235d1-15db-4b95-8439-a2e005bfff91
"
},
},
"_type": 0,
"_type": 0,
"_sizeMode": 0,
"_sizeMode": 0,
...
@@ -5155,39 +4537,7 @@
...
@@ -5155,39 +4537,7 @@
"_fillRange": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "63naLwjBBDN4xWnUAgXvmI"
"_id": "59KccFhWlDjr/WchgSfqAb"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 87
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "72614e26-8584-481b-be35-1a58541bca6e"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "ffT/lwHsxIW6+GwJhXeFXP"
},
},
{
{
"__type__": "cc.Canvas",
"__type__": "cc.Canvas",
...
...
assets/Scripts/Controllers/GameController.ts
View file @
630b55b0
...
@@ -22,12 +22,13 @@ export default class GameController extends cc.Component {
...
@@ -22,12 +22,13 @@ export default class GameController extends cc.Component {
cellTarget
:
cc
.
Node
=
null
;
cellTarget
:
cc
.
Node
=
null
;
spawnColumn
:
number
=
Utils
.
random
(
0
,
4
);
spawnColumn
:
number
=
Utils
.
random
(
0
,
4
);
cachedBlocksToMerge
:
Array
<
cc
.
Node
>
=
null
;
cachedBlocksToMerge
:
Array
<
cc
.
Node
>
=
null
;
currentBlockRow
:
number
=
0
;
currentBlockCol
:
number
=
0
;
protected
onLoad
():
void
{
protected
onLoad
():
void
{
GameController
.
instance
=
this
;
GameController
.
instance
=
this
;
this
.
spawnBlock
(
0
);
this
.
spawnBlock
(
this
.
blocksData
.
generateNumber
());
this
.
regEvents
();
}
}
regEvents
()
{
regEvents
()
{
...
@@ -40,6 +41,16 @@ export default class GameController extends cc.Component {
...
@@ -40,6 +41,16 @@ export default class GameController extends cc.Component {
});
});
}
}
offEvents
()
{
let
childrens
=
this
.
board
.
children
;
childrens
.
forEach
((
child
)
=>
{
child
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchDown
,
this
);
child
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
child
.
off
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
);
child
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
});
}
spawnBlock
(
index
:
number
)
{
spawnBlock
(
index
:
number
)
{
if
(
this
.
blocksData
.
blockData
.
length
>
0
)
{
if
(
this
.
blocksData
.
blockData
.
length
>
0
)
{
const
hasNonZero
=
this
.
blocksData
.
blockData
[
0
].
some
((
e
)
=>
e
!==
0
);
const
hasNonZero
=
this
.
blocksData
.
blockData
[
0
].
some
((
e
)
=>
e
!==
0
);
...
@@ -50,6 +61,8 @@ export default class GameController extends cc.Component {
...
@@ -50,6 +61,8 @@ export default class GameController extends cc.Component {
this
.
currentBlock
.
getComponent
(
Block
).
setSpriteBlock
(
index
);
this
.
currentBlock
.
getComponent
(
Block
).
setSpriteBlock
(
index
);
this
.
currentBlock
.
getComponent
(
Block
).
isPlace
=
false
;
this
.
currentBlock
.
getComponent
(
Block
).
isPlace
=
false
;
this
.
spawnBlockPos
=
this
.
currentBlock
.
parent
.
getPosition
();
this
.
spawnBlockPos
=
this
.
currentBlock
.
parent
.
getPosition
();
this
.
regEvents
();
}
}
onTouchDown
(
event
:
cc
.
Event
.
EventTouch
)
{
onTouchDown
(
event
:
cc
.
Event
.
EventTouch
)
{
...
@@ -94,6 +107,8 @@ export default class GameController extends cc.Component {
...
@@ -94,6 +107,8 @@ export default class GameController extends cc.Component {
this
.
spawnColumn
=
this
.
dropColumn
;
this
.
spawnColumn
=
this
.
dropColumn
;
this
.
currentBlock
.
getComponent
(
Block
).
currentBlockColumn
=
this
.
dropColumn
;
this
.
currentBlock
.
getComponent
(
Block
).
currentBlockColumn
=
this
.
dropColumn
;
this
.
onDropBlock
(
this
.
dropColumn
);
this
.
onDropBlock
(
this
.
dropColumn
);
this
.
offEvents
();
}
}
onDropBlock
(
col
:
number
)
{
onDropBlock
(
col
:
number
)
{
...
@@ -130,9 +145,8 @@ export default class GameController extends cc.Component {
...
@@ -130,9 +145,8 @@ export default class GameController extends cc.Component {
}
}
}
}
}
}
checkMergeability
(
row
:
number
,
col
:
number
)
{
checkMergeability
(
row
:
number
,
col
:
number
)
{
console
.
log
(
this
.
board
.
children
);
console
.
log
(
this
.
blocksData
.
blockData
);
const
mergedValue
=
this
.
currentBlock
.
getComponent
(
Block
).
value
;
const
mergedValue
=
this
.
currentBlock
.
getComponent
(
Block
).
value
;
const
neighbors
=
[
const
neighbors
=
[
...
@@ -182,7 +196,7 @@ export default class GameController extends cc.Component {
...
@@ -182,7 +196,7 @@ export default class GameController extends cc.Component {
this
.
currentBlock
.
getComponent
(
Block
).
isPlace
=
true
;
this
.
currentBlock
.
getComponent
(
Block
).
isPlace
=
true
;
this
.
touched
=
false
;
this
.
touched
=
false
;
this
.
spawnBlock
(
0
);
this
.
spawnBlock
(
this
.
blocksData
.
generateNumber
()
);
}
}
}
}
...
@@ -225,15 +239,14 @@ export default class GameController extends cc.Component {
...
@@ -225,15 +239,14 @@ export default class GameController extends cc.Component {
}
}
this
.
cachedBlocksToMerge
=
blocksToMerge
;
this
.
cachedBlocksToMerge
=
blocksToMerge
;
this
.
mergeBlock
(
nodeIndex
);
this
.
mergeBlock
(
nodeIndex
);
}
}
mergeBlock
(
nodeIndex
:
number
)
{
mergeBlock
(
nodeIndex
:
number
)
{
let
blocksToMergeCount
=
this
.
cachedBlocksToMerge
.
length
+
1
;
let
blocksToMergeCount
=
this
.
cachedBlocksToMerge
.
length
+
1
;
const
cellToMerge
=
this
.
board
.
children
[
nodeIndex
];
const
cellToMerge
=
this
.
board
.
children
[
nodeIndex
];
const
new
Row
=
Math
.
floor
(
nodeIndex
/
5
);
this
.
currentBlock
Row
=
Math
.
floor
(
nodeIndex
/
5
);
const
new
Col
=
nodeIndex
%
5
;
this
.
currentBlock
Col
=
nodeIndex
%
5
;
let
newValue
=
0
;
let
newValue
=
0
;
if
(
blocksToMergeCount
<=
2
||
blocksToMergeCount
>
3
)
{
if
(
blocksToMergeCount
<=
2
||
blocksToMergeCount
>
3
)
{
...
@@ -257,7 +270,12 @@ export default class GameController extends cc.Component {
...
@@ -257,7 +270,12 @@ export default class GameController extends cc.Component {
cellToMerge
.
removeAllChildren
();
cellToMerge
.
removeAllChildren
();
cellToMerge
.
addChild
(
this
.
currentBlock
);
cellToMerge
.
addChild
(
this
.
currentBlock
);
this
.
blocksData
.
setBlockValue
(
newRow
,
newCol
,
newValue
);
this
.
blocksData
.
setBlockValue
(
this
.
currentBlockRow
,
this
.
currentBlockCol
,
newValue
);
this
.
mergeMotion
(
this
.
mergeMotion
(
cellToMerge
,
cellToMerge
,
this
.
currentBlock
.
getComponent
(
Block
).
value
,
this
.
currentBlock
.
getComponent
(
Block
).
value
,
...
@@ -266,6 +284,8 @@ export default class GameController extends cc.Component {
...
@@ -266,6 +284,8 @@ export default class GameController extends cc.Component {
}
}
mergeMotion
(
cellToMerge
:
cc
.
Node
,
value
:
number
,
index
:
number
)
{
mergeMotion
(
cellToMerge
:
cc
.
Node
,
value
:
number
,
index
:
number
)
{
let
hasCheckedEmptyCell
=
false
;
for
(
let
i
=
0
;
i
<
this
.
cachedBlocksToMerge
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
cachedBlocksToMerge
.
length
;
i
++
)
{
const
block
=
this
.
cachedBlocksToMerge
[
i
];
const
block
=
this
.
cachedBlocksToMerge
[
i
];
...
@@ -275,6 +295,7 @@ export default class GameController extends cc.Component {
...
@@ -275,6 +295,7 @@ export default class GameController extends cc.Component {
this
.
blockPrefab
.
data
.
getComponent
(
Block
).
listSpriteBlocks
[
this
.
blockPrefab
.
data
.
getComponent
(
Block
).
listSpriteBlocks
[
Math
.
log
(
value
)
/
Math
.
log
(
2
)
-
1
Math
.
log
(
value
)
/
Math
.
log
(
2
)
-
1
];
];
block
.
parent
.
addChild
(
nodeClone
);
block
.
parent
.
addChild
(
nodeClone
);
const
globalPos
=
cellToMerge
.
convertToWorldSpaceAR
(
cc
.
Vec2
.
ZERO
);
const
globalPos
=
cellToMerge
.
convertToWorldSpaceAR
(
cc
.
Vec2
.
ZERO
);
...
@@ -284,9 +305,14 @@ export default class GameController extends cc.Component {
...
@@ -284,9 +305,14 @@ export default class GameController extends cc.Component {
.
to
(
0.3
,
{
position
:
new
cc
.
Vec3
(
localPos
.
x
,
localPos
.
y
,
0
)
})
.
to
(
0.3
,
{
position
:
new
cc
.
Vec3
(
localPos
.
x
,
localPos
.
y
,
0
)
})
.
call
(()
=>
{
.
call
(()
=>
{
nodeClone
.
destroy
();
nodeClone
.
destroy
();
nodeClone
.
parent
.
removeAllChildren
();
cellToMerge
.
children
[
0
].
getComponent
(
Block
).
setSpriteBlock
(
index
);
cellToMerge
.
children
[
0
].
getComponent
(
Block
).
setSpriteBlock
(
index
);
this
.
cachedBlocksToMerge
.
length
=
0
;
this
.
cachedBlocksToMerge
.
length
=
0
;
this
.
checkEmptyCell
();
if
(
!
hasCheckedEmptyCell
)
{
this
.
checkEmptyCell
();
hasCheckedEmptyCell
=
true
;
}
})
})
.
start
();
.
start
();
}
}
...
@@ -298,11 +324,8 @@ export default class GameController extends cc.Component {
...
@@ -298,11 +324,8 @@ export default class GameController extends cc.Component {
const
numCols
=
data
[
0
].
length
;
const
numCols
=
data
[
0
].
length
;
let
newRow
=
0
;
let
newRow
=
0
;
let
newCol
=
0
;
let
newCol
=
0
;
let
currentRow
=
0
;
let
currentCol
=
0
;
// detected empty cell
// detected empty cell
for
(
let
col
=
0
;
col
<
numCols
;
col
++
)
{
for
(
let
col
=
0
;
col
<
numCols
;
col
++
)
{
for
(
let
row
=
numRows
-
2
;
row
>=
0
;
row
--
)
{
for
(
let
row
=
numRows
-
2
;
row
>=
0
;
row
--
)
{
if
(
data
[
row
][
col
]
!==
0
)
{
if
(
data
[
row
][
col
]
!==
0
)
{
...
@@ -327,43 +350,8 @@ export default class GameController extends cc.Component {
...
@@ -327,43 +350,8 @@ export default class GameController extends cc.Component {
}
}
// no empty cell detected
// no empty cell detected
if
(
newRow
==
0
&&
newCol
==
0
)
{
if
(
newRow
==
0
&&
newCol
==
0
)
{
let
maxAdjacentValueCount
=
0
;
return
this
.
checkMergeability
(
this
.
currentBlockRow
,
this
.
currentBlockCol
);
for
(
let
col
=
0
;
col
<
numCols
;
col
++
)
{
for
(
let
row
=
0
;
row
<
numRows
;
row
++
)
{
const
currentValue
=
data
[
row
][
col
];
if
(
currentValue
!==
0
)
{
let
adjacentValueCount
=
0
;
if
(
col
>
0
&&
data
[
row
][
col
-
1
]
==
currentValue
)
{
adjacentValueCount
++
;
}
if
(
col
<
numCols
-
1
&&
data
[
row
][
col
+
1
]
==
currentValue
)
{
adjacentValueCount
++
;
}
if
(
row
<
numRows
-
1
&&
data
[
row
+
1
][
col
]
==
currentValue
)
{
adjacentValueCount
++
;
}
if
(
adjacentValueCount
>
maxAdjacentValueCount
)
{
maxAdjacentValueCount
=
adjacentValueCount
;
currentRow
=
row
;
currentCol
=
col
;
}
}
}
}
this
.
currentBlock
.
getComponent
(
Block
).
isPlace
=
true
;
this
.
touched
=
false
;
this
.
spawnBlock
(
0
);
if
(
currentRow
==
0
&&
currentCol
==
0
)
return
;
this
.
checkMergeability
(
currentRow
,
currentCol
);
}
}
}
}
...
@@ -384,7 +372,7 @@ export default class GameController extends cc.Component {
...
@@ -384,7 +372,7 @@ export default class GameController extends cc.Component {
if
(
value
!==
0
)
{
if
(
value
!==
0
)
{
const
newValueNode
=
this
.
createValueNode
(
value
);
const
newValueNode
=
this
.
createValueNode
(
value
);
cell
.
addChild
(
newValueNode
);
cell
.
addChild
(
newValueNode
);
if
(
cell
.
children
.
length
>
1
)
cell
.
children
.
s
lice
(
-
1
);
if
(
cell
.
children
.
length
>
1
)
cell
.
children
.
s
hift
(
);
}
}
}
}
}
}
...
...
assets/Scripts/Data/BlockData.ts
View file @
630b55b0
import
Utils
from
"../Tools/Utils"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
@
ccclass
...
@@ -35,4 +37,29 @@ export default class BlockData extends cc.Component {
...
@@ -35,4 +37,29 @@ export default class BlockData extends cc.Component {
this
.
blockData
[
row
][
col
]
=
value
;
this
.
blockData
[
row
][
col
]
=
value
;
}
}
}
}
generateNumber
():
number
{
if
(
this
.
blockData
.
length
==
0
)
return
Utils
.
random
(
0
,
4
);
const
smallNumberProbability
=
0.7
;
const
largeNumberProbability
=
0.3
;
let
randomNumber
=
0
;
const
randomValue
=
Math
.
random
();
if
(
randomValue
<
smallNumberProbability
)
{
const
smallNumbers
=
[
2
,
4
,
8
,
16
,
32
];
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
smallNumbers
.
length
);
randomNumber
=
smallNumbers
[
randomIndex
];
}
else
if
(
randomValue
<
smallNumberProbability
+
largeNumberProbability
)
{
const
largeNumbers
=
[
64
,
128
,
256
,
512
];
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
largeNumbers
.
length
);
randomNumber
=
largeNumbers
[
randomIndex
];
}
else
{
const
averageNumbers
=
[
16
,
32
,
64
];
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
averageNumbers
.
length
);
randomNumber
=
averageNumbers
[
randomIndex
];
}
return
Math
.
log
(
randomNumber
)
/
Math
.
log
(
2
)
-
1
;
}
}
}
assets/Scripts/Objects/Block.ts
View file @
630b55b0
...
@@ -28,9 +28,8 @@ export default class Block extends cc.Component {
...
@@ -28,9 +28,8 @@ export default class Block extends cc.Component {
this
.
currentBlockRow
,
this
.
currentBlockRow
,
this
.
currentBlockColumn
this
.
currentBlockColumn
);
);
GameController
.
instance
.
spawnBlock
(
0
);
}
}
this
.
node
.
y
-=
dt
*
1
5
0
;
this
.
node
.
y
-=
dt
*
1
0
0
;
}
}
setSpriteBlock
(
index
:
number
)
{
setSpriteBlock
(
index
:
number
)
{
...
...
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