feat: logic physic for box 2d wasm

feature/ads-smart-display
tiendat3699 2024-05-15 14:42:31 +07:00
parent 3a531f3f2c
commit e8374d2635
18 changed files with 14136 additions and 9037 deletions

View File

@ -1,6 +1,9 @@
{ {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.sortImports": "explicit"
},
"files.exclude": { "files.exclude": {
"**/*.meta": true "**/*.meta": true
}, },

View File

@ -3,6 +3,7 @@
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "Ball", "_name": "Ball",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_native": "", "_native": "",
"data": { "data": {
"__id__": 1 "__id__": 1
@ -81,6 +82,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Graphics", "_name": "Graphics",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
@ -149,6 +151,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "shadow", "_name": "shadow",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -198,6 +201,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -225,6 +229,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -359,7 +364,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 10
} }
}, },
{ {
@ -566,6 +571,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Sprite", "_name": "Sprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -615,6 +621,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 30 "__id__": 30
}, },
@ -642,6 +649,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 30 "__id__": 30
}, },
@ -699,6 +707,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "CheeseModeSprite", "_name": "CheeseModeSprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -748,6 +757,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 36 "__id__": 36
}, },
@ -775,6 +785,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 36 "__id__": 36
}, },
@ -951,7 +962,7 @@
"propertyPath": [ "propertyPath": [
"_active" "_active"
], ],
"value": false "value": true
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
@ -1046,7 +1057,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -30, "y": -30,
"z": 0 "z": 10
} }
}, },
{ {
@ -1142,12 +1153,13 @@
"propertyPath": [ "propertyPath": [
"_active" "_active"
], ],
"value": false "value": true
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
@ -1280,6 +1292,7 @@
"__type__": "2b7c2ePr+dMuYseum/QYECs", "__type__": "2b7c2ePr+dMuYseum/QYECs",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1340,6 +1353,7 @@
"__type__": "cc.Animation", "__type__": "cc.Animation",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1368,6 +1382,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1440,6 +1455,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },

View File

@ -3,6 +3,7 @@
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "CumulativeBooster", "_name": "CumulativeBooster",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_native": "", "_native": "",
"data": { "data": {
"__id__": 1 "__id__": 1
@ -75,6 +76,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Sprite", "_name": "Sprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
@ -128,6 +130,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Particle", "_name": "Particle",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -151,7 +154,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 10
}, },
"_lrot": { "_lrot": {
"__type__": "cc.Quat", "__type__": "cc.Quat",
@ -180,6 +183,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -207,6 +211,7 @@
"__type__": "cc.ParticleSystem", "__type__": "cc.ParticleSystem",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -965,6 +970,7 @@
"__type__": "cc.UIMeshRenderer", "__type__": "cc.UIMeshRenderer",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -995,6 +1001,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
@ -1022,6 +1029,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
@ -1079,6 +1087,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1106,6 +1115,7 @@
"__type__": "366a4horc9BIpj097ERzLW3", "__type__": "366a4horc9BIpj097ERzLW3",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1123,6 +1133,7 @@
"_animation": { "_animation": {
"__id__": 82 "__id__": 82
}, },
"displayName": "CHEESE",
"time": 10, "time": 10,
"_id": "" "_id": ""
}, },
@ -1134,6 +1145,7 @@
"__type__": "cc.BoxCollider2D", "__type__": "cc.BoxCollider2D",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1167,6 +1179,7 @@
"__type__": "cc.Animation", "__type__": "cc.Animation",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1195,6 +1208,7 @@
"__type__": "cc.RigidBody2D", "__type__": "cc.RigidBody2D",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },

View File

@ -3,6 +3,7 @@
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "City_Ball", "_name": "City_Ball",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_native": "", "_native": "",
"data": { "data": {
"__id__": 1 "__id__": 1
@ -81,6 +82,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Graphics", "_name": "Graphics",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
@ -149,6 +151,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "shadow", "_name": "shadow",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -198,6 +201,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -225,6 +229,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -371,7 +376,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 10
} }
}, },
{ {
@ -619,6 +624,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Sprite", "_name": "Sprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -668,6 +674,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 34 "__id__": 34
}, },
@ -695,6 +702,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 34 "__id__": 34
}, },
@ -752,6 +760,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "CheeseModeSprite", "_name": "CheeseModeSprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -801,6 +810,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 40 "__id__": 40
}, },
@ -828,6 +838,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 40 "__id__": 40
}, },
@ -1077,7 +1088,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -30, "y": -30,
"z": 0 "z": 10
} }
}, },
{ {
@ -1148,6 +1159,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
@ -1280,6 +1292,7 @@
"__type__": "2b7c2ePr+dMuYseum/QYECs", "__type__": "2b7c2ePr+dMuYseum/QYECs",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1340,6 +1353,7 @@
"__type__": "cc.Animation", "__type__": "cc.Animation",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1368,6 +1382,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1440,6 +1455,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },

View File

@ -3,6 +3,7 @@
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "Park_Ball", "_name": "Park_Ball",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_native": "", "_native": "",
"data": { "data": {
"__id__": 1 "__id__": 1
@ -81,6 +82,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Graphics", "_name": "Graphics",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
@ -149,6 +151,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "shadow", "_name": "shadow",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -198,6 +201,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -225,6 +229,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 3 "__id__": 3
}, },
@ -374,7 +379,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 10
} }
}, },
{ {
@ -595,7 +600,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 10
} }
}, },
{ {
@ -742,6 +747,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Sprite", "_name": "Sprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -791,6 +797,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 43 "__id__": 43
}, },
@ -818,6 +825,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 43 "__id__": 43
}, },
@ -875,6 +883,7 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "CheeseModeSprite", "_name": "CheeseModeSprite",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
@ -924,6 +933,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 49 "__id__": 49
}, },
@ -951,6 +961,7 @@
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 49 "__id__": 49
}, },
@ -1206,7 +1217,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -30, "y": -30,
"z": 0 "z": 10
} }
}, },
{ {
@ -1298,6 +1309,7 @@
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 2 "__id__": 2
}, },
@ -1430,6 +1442,7 @@
"__type__": "2b7c2ePr+dMuYseum/QYECs", "__type__": "2b7c2ePr+dMuYseum/QYECs",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1490,6 +1503,7 @@
"__type__": "cc.Animation", "__type__": "cc.Animation",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1515,6 +1529,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
@ -1587,6 +1602,7 @@
"__type__": "02a884WNWtExrO21yAjQDWZ", "__type__": "02a884WNWtExrO21yAjQDWZ",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 1
}, },

File diff suppressed because it is too large Load Diff

View File

@ -7087,7 +7087,7 @@
"bullet": false, "bullet": false,
"awakeOnLoad": true, "awakeOnLoad": true,
"_group": 2, "_group": 2,
"_type": 1, "_type": 3,
"_allowSleep": true, "_allowSleep": true,
"_gravityScale": 1, "_gravityScale": 1,
"_linearDamping": 0, "_linearDamping": 0,
@ -7758,7 +7758,7 @@
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": -1500 "y": -70
}, },
"_points": [ "_points": [
{ {
@ -31761,7 +31761,7 @@
"tag": 0, "tag": 0,
"_group": 2, "_group": 2,
"_density": 1, "_density": 1,
"_sensor": false, "_sensor": true,
"_friction": 0.2, "_friction": 0.2,
"_restitution": 0, "_restitution": 0,
"_offset": { "_offset": {
@ -33779,7 +33779,7 @@
"tag": 0, "tag": 0,
"_group": 2, "_group": 2,
"_density": 1, "_density": 1,
"_sensor": false, "_sensor": true,
"_friction": 0.2, "_friction": 0.2,
"_restitution": 0, "_restitution": 0,
"_offset": { "_offset": {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip, CCString } from 'cc'; import { _decorator, Animation, AudioClip, CCFloat, CCString, Collider2D, Component, Contact2DType } from 'cc';
import ObjectPool from '../Pool/ObjectPool';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent'; import GameEvent from '../Events/GameEvent';
import IPoolable from '../Pool/IPoolable'; import { EventManger } from '../Manager/EventManger';
import Utilities from '../Utilities';
import { SoundManager } from '../Manager/SoundManager'; import { SoundManager } from '../Manager/SoundManager';
import IPoolable from '../Pool/IPoolable';
import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('BoosterBase') @ccclass('BoosterBase')
@ -17,18 +17,20 @@ export class BoosterBase extends Component implements IPoolable {
private _animation: Animation; private _animation: Animation;
@property(CCString) @property(CCString)
public readonly displayName: string = 'CHEESE'; public readonly displayName: string = 'CHEESE';
@property(CCFloat) @property(CCFloat)
protected time: number = 10; protected time: number = 10;
private _enabled: boolean = true;
protected onLoad(): void { protected onLoad(): void {
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this); this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
this._collider.enabled = false; this._enabled = false;
} }
private onContactBegin(self: Collider2D, other: Collider2D) { private onContactBegin(self: Collider2D, other: Collider2D) {
if (!this._enabled) return;
this.boosterActive(); this.boosterActive();
this._collider.enabled = false; this._enabled = false;
SoundManager.instance.playSfx(this._collectSound); SoundManager.instance.playSfx(this._collectSound);
EventManger.instance.emit(GameEvent.ObjectRelease, this.node); EventManger.instance.emit(GameEvent.ObjectRelease, this.node);
ObjectPool.release(this.node); ObjectPool.release(this.node);
@ -39,9 +41,9 @@ export class BoosterBase extends Component implements IPoolable {
async onGet() { async onGet() {
this._animation.play(); this._animation.play();
await Utilities.delay(this._animation.defaultClip.duration); await Utilities.delay(this._animation.defaultClip.duration);
this._collider.enabled = true; this._enabled = true;
} }
onRelease() { onRelease() {
this._collider.enabled = false; this._enabled = false;
} }
} }

View File

@ -1,29 +1,29 @@
import { import {
_decorator, _decorator,
AudioClip,
CCFloat,
CCInteger, CCInteger,
clamp, clamp,
clamp01,
Component, Component,
lerp, lerp,
Sprite,
Node, Node,
tween, ParticleSystem,
Prefab, Prefab,
randomRange,
Sprite,
tween,
Tween, Tween,
Vec3, Vec3,
AudioClip,
randomRange,
CCFloat,
clamp01,
ParticleSystem,
} from 'cc'; } from 'cc';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import ScoreType from '../Enum/ScoreType';
import Utilities from '../Utilities';
import { GameManager } from '../Manager/GameManager';
import BoosterType from '../Enum/BoosterType'; import BoosterType from '../Enum/BoosterType';
import ObjectPool from '../Pool/ObjectPool'; import ScoreType from '../Enum/ScoreType';
import GameEvent from '../Events/GameEvent';
import { EventManger } from '../Manager/EventManger';
import { GameManager } from '../Manager/GameManager';
import { SoundManager } from '../Manager/SoundManager'; import { SoundManager } from '../Manager/SoundManager';
import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities';
import { SequenceSound } from './SequenceSound'; import { SequenceSound } from './SequenceSound';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -145,8 +145,10 @@ export class CumulativeBar extends Component {
}, },
) )
.call(async () => { .call(async () => {
const fx = this._fxPool.get(ParticleSystem, this.node); const fx = this._fxPool.get(ParticleSystem, GameManager.instance.topContainer);
fx.node.setWorldPosition(star.worldPosition); const pos = star.getWorldPosition();
pos.z = 10;
fx.node.setWorldPosition(pos);
this._starPool.release(star); this._starPool.release(star);
SoundManager.instance.playSfx(this._collectStartSoundFx); SoundManager.instance.playSfx(this._collectStartSoundFx);
await Utilities.waitUntil(() => { await Utilities.waitUntil(() => {
@ -234,7 +236,9 @@ export class CumulativeBar extends Component {
} }
if (selectReward) { if (selectReward) {
const fx = selectReward.pool.get(ParticleSystem, GameManager.instance.topContainer); const fx = selectReward.pool.get(ParticleSystem, GameManager.instance.topContainer);
fx.node.setWorldPosition(this.node.worldPosition); const pos = this.node.getWorldPosition();
pos.z = 10;
fx.node.setWorldPosition(pos);
SoundManager.instance.playSfx(selectReward.sound); SoundManager.instance.playSfx(selectReward.sound);
await Utilities.waitUntil(() => fx.isStopped, 0.1); await Utilities.waitUntil(() => fx.isStopped, 0.1);
selectReward.pool.release(fx); selectReward.pool.release(fx);

View File

@ -1,6 +1,7 @@
import { import {
_decorator, _decorator,
Animation, Animation,
AudioClip,
CCInteger, CCInteger,
Collider2D, Collider2D,
Color, Color,
@ -8,15 +9,14 @@ import {
Contact2DType, Contact2DType,
Sprite, Sprite,
Vec3, Vec3,
AudioClip,
} from 'cc'; } from 'cc';
import GameEvent from '../Events/GameEvent';
import { EventManger } from '../Manager/EventManger';
import { GameManager } from '../Manager/GameManager'; import { GameManager } from '../Manager/GameManager';
import { SoundManager } from '../Manager/SoundManager';
import IPoolable from '../Pool/IPoolable'; import IPoolable from '../Pool/IPoolable';
import ObjectPool from '../Pool/ObjectPool'; import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities'; import Utilities from '../Utilities';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import { SoundManager } from '../Manager/SoundManager';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('ScoreObject') @ccclass('ScoreObject')
@ -40,10 +40,12 @@ export class ScoreObject extends Component implements IPoolable {
private _originColor: Color; private _originColor: Color;
private _isHit = false; private _isHit = false;
private _enabled: boolean = true;
protected onLoad(): void { protected onLoad(): void {
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this); this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
this._originColor = this._sprite.color.clone(); this._originColor = this._sprite.color.clone();
this._collider.enabled = false; this._enabled = false;
} }
protected update(dt: number): void { protected update(dt: number): void {
@ -66,9 +68,10 @@ export class ScoreObject extends Component implements IPoolable {
} }
private async onContactBegin(selfCollider: Collider2D, otherCollider: Collider2D) { private async onContactBegin(selfCollider: Collider2D, otherCollider: Collider2D) {
if (!this._enabled) return;
if (this._isHit) return; if (this._isHit) return;
if (this._hitSound) SoundManager.instance.playSfx(this._hitSound); if (this._hitSound) SoundManager.instance.playSfx(this._hitSound);
this._collider.enabled = false; this._enabled = false;
// let center = this.node.getWorldPosition(); // let center = this.node.getWorldPosition();
// let other = otherCollider.node.getWorldPosition(); // let other = otherCollider.node.getWorldPosition();
// this._flyDirection = center.subtract(other); // this._flyDirection = center.subtract(other);
@ -88,12 +91,12 @@ export class ScoreObject extends Component implements IPoolable {
public async onGet() { public async onGet() {
this._animation.play(this._animation.clips[0].name); this._animation.play(this._animation.clips[0].name);
await Utilities.delay(this._animation.clips[0].duration); await Utilities.delay(this._animation.clips[0].duration);
this._collider.enabled = true; this._enabled = true;
} }
public onRelease() { public onRelease() {
this._isHit = false; this._isHit = false;
this._collider.enabled = false; this._enabled = false;
this.node.angle = 0; this.node.angle = 0;
this.node.setScale(Vec3.ONE); this.node.setScale(Vec3.ONE);
this._sprite.color = this._originColor; this._sprite.color = this._originColor;

View File

@ -23,6 +23,9 @@ declare module 'cc' {
setPositionX(x: number): void; setPositionX(x: number): void;
setPositionY(y: number): void; setPositionY(y: number): void;
setPositionZ(z: number): void; setPositionZ(z: number): void;
setWorldPositionX(x: number): void;
setWorldPositionY(y: number): void;
setWorldPositionZ(z: number): void;
translateX(x: number, ns?: NodeSpace): void; translateX(x: number, ns?: NodeSpace): void;
translateY(y: number, ns?: NodeSpace): void; translateY(y: number, ns?: NodeSpace): void;
translateZ(z: number, ns?: NodeSpace): void; translateZ(z: number, ns?: NodeSpace): void;
@ -87,6 +90,18 @@ Node.prototype.setPositionZ = function (z: number): void {
this.position = new Vec3(this.position.x, this.position.y, z); this.position = new Vec3(this.position.x, this.position.y, z);
}; };
Node.prototype.setWorldPositionX = function (x: number): void {
this.worldPosition = new Vec3(x, this.worldPosition.y, this.worldPosition.z);
};
Node.prototype.setWorldPositionY = function (y: number): void {
this.worldPosition = new Vec3(this.worldPosition.x, y, this.worldPosition.z);
};
Node.prototype.setWorldPositionZ = function (z: number): void {
this.worldPosition = new Vec3(this.worldPosition.x, this.worldPosition.y, z);
};
Node.prototype.translateX = function (x: number, ns?: NodeSpace): void { Node.prototype.translateX = function (x: number, ns?: NodeSpace): void {
this.translate(new Vec3(x, 0), ns); this.translate(new Vec3(x, 0), ns);
}; };

View File

@ -1,5 +1,7 @@
import { import {
_decorator, _decorator,
Animation,
AudioClip,
CCInteger, CCInteger,
Collider2D, Collider2D,
Component, Component,
@ -7,17 +9,15 @@ import {
EventHandler, EventHandler,
tween, tween,
Vec2, Vec2,
Animation,
Vec3, Vec3,
AudioClip,
} from 'cc'; } from 'cc';
import TimeConfig from '../Enum/TimeConfig';
import { CameraController } from '../Environments/CameraController';
import GameEvent from '../Events/GameEvent';
import { EventManger } from '../Manager/EventManger';
import { SoundManager } from '../Manager/SoundManager';
import Utilities from '../Utilities'; import Utilities from '../Utilities';
import { Ball } from './Ball'; import { Ball } from './Ball';
import TimeConfig from '../Enum/TimeConfig';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import { CameraController } from '../Environments/CameraController';
import { SoundManager } from '../Manager/SoundManager';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('Cannon') @ccclass('Cannon')
@ -35,21 +35,24 @@ export class Cannon extends Component {
@property({ type: EventHandler, visible: true }) @property({ type: EventHandler, visible: true })
private onDone: EventHandler[] = []; private onDone: EventHandler[] = [];
private _enabled: boolean = true;
protected onLoad(): void { protected onLoad(): void {
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
EventManger.instance.on(GameEvent.BallOut, this.onBallOut, this); EventManger.instance.on(GameEvent.BallOut, this.onBallOut, this);
} }
private async onBeginContact(self: Collider2D, other: Collider2D) { private async onBeginContact(self: Collider2D, other: Collider2D) {
if (!this._enabled) return;
const ball = other.getComponent(Ball); const ball = other.getComponent(Ball);
this._collider.enabled = false; this._enabled = false;
if (ball) { if (ball) {
ball.setActiveRigi(false); ball.clearRigiState(false);
tween(ball.node).to(0.1, { worldPosition: this.node.worldPosition }).start(); tween(ball.node).to(0.1, { worldPosition: this.node.worldPosition }).start();
await Utilities.delay(TimeConfig.DelayCannonFire); await Utilities.delay(TimeConfig.DelayCannonFire);
CameraController.instance.shake(0.2); CameraController.instance.shake(0.2);
this._animation.play(); this._animation.play();
ball.setActiveRigi(true); ball.clearRigiState(true);
ball.throwBall(new Vec2(0, this._force)); ball.throwBall(new Vec2(0, this._force));
SoundManager.instance.playSfx(this._soundFx); SoundManager.instance.playSfx(this._soundFx);
await Utilities.delay(TimeConfig.DelayCannonDone); await Utilities.delay(TimeConfig.DelayCannonDone);
@ -60,7 +63,7 @@ export class Cannon extends Component {
private onBallOut() { private onBallOut() {
tween(this._collider.node) tween(this._collider.node)
.to(0.5, { scale: Vec3.ONE }, { easing: 'backOut', onComplete: () => (this._collider.enabled = true) }) .to(0.5, { scale: Vec3.ONE }, { easing: 'backOut', onComplete: () => (this._enabled = true) })
.start(); .start();
} }
} }

View File

@ -1,5 +1,6 @@
import { import {
_decorator, _decorator,
Animation,
AudioClip, AudioClip,
CCInteger, CCInteger,
Collider2D, Collider2D,
@ -7,17 +8,16 @@ import {
Contact2DType, Contact2DType,
ParticleSystem, ParticleSystem,
Prefab, Prefab,
Animation,
} from 'cc'; } from 'cc';
import { GameManager } from '../Manager/GameManager';
import Utilities from '../Utilities';
import ObjectPool from '../Pool/ObjectPool';
import { Ball } from './Ball';
import { SoundManager } from '../Manager/SoundManager';
import { CameraController } from '../Environments/CameraController';
import TimeConfig from '../Enum/TimeConfig'; import TimeConfig from '../Enum/TimeConfig';
import { EventManger } from '../Manager/EventManger'; import { CameraController } from '../Environments/CameraController';
import GameEvent from '../Events/GameEvent'; import GameEvent from '../Events/GameEvent';
import { EventManger } from '../Manager/EventManger';
import { GameManager } from '../Manager/GameManager';
import { SoundManager } from '../Manager/SoundManager';
import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities';
import { Ball } from './Ball';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('Goal') @ccclass('Goal')
@ -42,8 +42,8 @@ export class Goal extends Component {
const ball = otherCollider.getComponent(Ball); const ball = otherCollider.getComponent(Ball);
if (ball) { if (ball) {
GameManager.instance.goal(this._score, ball.node.getWorldPosition()); GameManager.instance.goal(this._score, ball.node.getWorldPosition());
ball.setActiveRigi(false); ball.clearRigiState(false);
const fx = this._goalFxPool.get(ParticleSystem, this.node); const fx = this._goalFxPool.get(ParticleSystem, GameManager.instance.topContainer);
const pos = ball.node.getWorldPosition(); const pos = ball.node.getWorldPosition();
pos.z = 10; pos.z = 10;
fx.node.setWorldPosition(pos); fx.node.setWorldPosition(pos);

View File

@ -1,11 +1,11 @@
import { _decorator, Collider2D, Component, Contact2DType, Vec2, Node, ParticleSystem, Prefab, AudioClip } from 'cc'; import { _decorator, AudioClip, Collider2D, Component, Contact2DType, Node, ParticleSystem, Prefab, Vec2 } from 'cc';
import TimeConfig from '../Enum/TimeConfig';
import { CameraController } from '../Environments/CameraController';
import { GameManager } from '../Manager/GameManager'; import { GameManager } from '../Manager/GameManager';
import { SoundManager } from '../Manager/SoundManager';
import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities'; import Utilities from '../Utilities';
import { Ball } from './Ball'; import { Ball } from './Ball';
import TimeConfig from '../Enum/TimeConfig';
import ObjectPool from '../Pool/ObjectPool';
import { CameraController } from '../Environments/CameraController';
import { SoundManager } from '../Manager/SoundManager';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('MultiBall') @ccclass('MultiBall')
@ -26,6 +26,8 @@ export class MultiBall extends Component {
private _trigged = false; private _trigged = false;
private _fxPool: ObjectPool; private _fxPool: ObjectPool;
private _enabled: boolean = true;
protected onLoad(): void { protected onLoad(): void {
this._fxPool = new ObjectPool(this._fx, 2, true); this._fxPool = new ObjectPool(this._fx, 2, true);
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
@ -34,13 +36,17 @@ export class MultiBall extends Component {
protected lateUpdate(dt: number): void { protected lateUpdate(dt: number): void {
if (this._trigged) { if (this._trigged) {
CameraController.instance.shake(0.2); CameraController.instance.shake(0.2);
this._originBall.setActiveRigi(true);
const ball1 = this._originBall; const ball1 = this._originBall;
ball1.clearRigiState(false);
const ball2 = GameManager.instance.spawnBall(false, false); const ball2 = GameManager.instance.spawnBall(false, false);
ball2.clearRigiState(false);
ball1.node.setWorldPosition(this._portRight.worldPosition); ball1.node.setWorldPosition(this._portRight.worldPosition);
ball1.clearRigiState(true);
ball1.addForce(new Vec2(20, 0)); ball1.addForce(new Vec2(20, 0));
ball2.node.setWorldPosition(this._portLeft.worldPosition); ball2.node.setWorldPosition(this._portLeft.worldPosition);
ball2.clearRigiState(true);
ball2.addForce(new Vec2(-20, 0)); ball2.addForce(new Vec2(-20, 0));
this._trigged = false; this._trigged = false;
@ -48,16 +54,18 @@ export class MultiBall extends Component {
} }
private async onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) { private async onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) {
if (!this._enabled) return;
if (this._trigged) return; if (this._trigged) return;
this._collider.enabled = false; this._enabled = false;
this._originBall = otherCollider.getComponent(Ball); this._originBall = otherCollider.getComponent(Ball);
this._originBall.setActiveRigi(false);
this._trigged = true; this._trigged = true;
const fx = this._fxPool.get(ParticleSystem, this.node); const fx = this._fxPool.get(ParticleSystem, GameManager.instance.topContainer);
fx.node.setWorldPosition(this.node.worldPosition); const pos = this.node.getWorldPosition();
pos.z = 10;
fx.node.setWorldPosition(pos);
SoundManager.instance.playSfx(this._soundFX); SoundManager.instance.playSfx(this._soundFX);
await Utilities.delay(TimeConfig.DelayMultiBall); await Utilities.delay(TimeConfig.DelayMultiBall);
this._collider.enabled = true; this._enabled = true;
await Utilities.waitUntil(() => fx.isStopped); await Utilities.waitUntil(() => fx.isStopped);
this._fxPool.release(fx); this._fxPool.release(fx);
} }

View File

@ -1,35 +1,34 @@
import { import {
_decorator, _decorator,
Animation,
AudioClip, AudioClip,
CCFloat, CCFloat,
CircleCollider2D,
Collider2D, Collider2D,
Component, Component,
Contact2DType, Contact2DType,
Director, Director,
director, director,
EventTarget, ERigidBody2DType,
IPhysics2DContact,
RigidBody2D,
Vec2,
geometry, geometry,
IPhysics2DContact,
math, math,
Vec3, Node,
ParticleSystem, ParticleSystem,
Prefab, Prefab,
CircleCollider2D, RigidBody2D,
Animation,
Sprite, Sprite,
Node, Vec2,
SpriteFrame, Vec3,
} from 'cc'; } from 'cc';
import IPoolable from '../Pool/IPoolable';
import { SoundManager } from '../Manager/SoundManager';
import PhysicsGroup from '../Enum/PhysicGroup'; import PhysicsGroup from '../Enum/PhysicGroup';
import { SequenceSound } from '../Environments/SequenceSound';
import GameEvent from '../Events/GameEvent';
import { EventManger } from '../Manager/EventManger';
import { SoundManager } from '../Manager/SoundManager';
import IPoolable from '../Pool/IPoolable';
import ObjectPool from '../Pool/ObjectPool'; import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities'; import Utilities from '../Utilities';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import { SequenceSound } from '../Environments/SequenceSound';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('Ball') @ccclass('Ball')
@ -226,18 +225,16 @@ export class Ball extends Component implements IPoolable {
this._buffParticle.play(); this._buffParticle.play();
} }
public setActiveRigi(value: boolean) { public clearRigiState(active: boolean) {
// this._rigidBody.enabled = value; this._rigidBody.type = active ? ERigidBody2DType.Dynamic : ERigidBody2DType.Kinematic;
if (!value) {
this._rigidBody.linearVelocity = Vec2.ZERO.clone(); this._rigidBody.linearVelocity = Vec2.ZERO.clone();
this._rigidBody.angularVelocity = 0; this._rigidBody.angularVelocity = 0;
} }
}
onGet() { onGet() {
this.clearRigiState(true);
this._isJumping = false; this._isJumping = false;
this._isHit = false; this._isHit = false;
this._rigidBody.enabled = true;
this._parent = this.node.getParent(); this._parent = this.node.getParent();
this._fireParticle.rateOverDistance.constant = 0; this._fireParticle.rateOverDistance.constant = 0;
this._fireParticle.rateOverTime.constant = 0; this._fireParticle.rateOverTime.constant = 0;

View File

@ -107,7 +107,7 @@
"_value": false "_value": false
}, },
"tiled-map": { "tiled-map": {
"_value": true "_value": false
}, },
"spine": { "spine": {
"_value": false "_value": false
@ -118,6 +118,9 @@
"marionette": { "marionette": {
"_value": false "_value": false
}, },
"procedural-animation": {
"_value": false
},
"custom-pipeline": { "custom-pipeline": {
"_value": false "_value": false
} }
@ -135,7 +138,6 @@
"particle-2d", "particle-2d",
"physics-2d-box2d", "physics-2d-box2d",
"profiler", "profiler",
"tiled-map",
"tween", "tween",
"ui", "ui",
"websocket" "websocket"