feat: logic physic for box 2d wasm
parent
3a531f3f2c
commit
e8374d2635
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.sortImports": "explicit"
|
||||
},
|
||||
"files.exclude": {
|
||||
"**/*.meta": true
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"__type__": "cc.Prefab",
|
||||
"_name": "Ball",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
|
@ -81,6 +82,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Graphics",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -149,6 +151,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "shadow",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -198,6 +201,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -225,6 +229,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -359,7 +364,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -566,6 +571,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Sprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -615,6 +621,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 30
|
||||
},
|
||||
|
@ -642,6 +649,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 30
|
||||
},
|
||||
|
@ -699,6 +707,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "CheeseModeSprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -748,6 +757,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 36
|
||||
},
|
||||
|
@ -775,6 +785,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 36
|
||||
},
|
||||
|
@ -951,7 +962,7 @@
|
|||
"propertyPath": [
|
||||
"_active"
|
||||
],
|
||||
"value": false
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
|
@ -1046,7 +1057,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": -30,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1142,12 +1153,13 @@
|
|||
"propertyPath": [
|
||||
"_active"
|
||||
],
|
||||
"value": false
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -1280,6 +1292,7 @@
|
|||
"__type__": "2b7c2ePr+dMuYseum/QYECs",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1340,6 +1353,7 @@
|
|||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1368,6 +1382,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1440,6 +1455,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"__type__": "cc.Prefab",
|
||||
"_name": "CumulativeBooster",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
|
@ -75,6 +76,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Sprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -128,6 +130,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Particle",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -151,7 +154,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
"z": 10
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
|
@ -180,6 +183,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -207,6 +211,7 @@
|
|||
"__type__": "cc.ParticleSystem",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -965,6 +970,7 @@
|
|||
"__type__": "cc.UIMeshRenderer",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -995,6 +1001,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -1022,6 +1029,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -1079,6 +1087,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1106,6 +1115,7 @@
|
|||
"__type__": "366a4horc9BIpj097ERzLW3",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1123,6 +1133,7 @@
|
|||
"_animation": {
|
||||
"__id__": 82
|
||||
},
|
||||
"displayName": "CHEESE",
|
||||
"time": 10,
|
||||
"_id": ""
|
||||
},
|
||||
|
@ -1134,6 +1145,7 @@
|
|||
"__type__": "cc.BoxCollider2D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1167,6 +1179,7 @@
|
|||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1195,6 +1208,7 @@
|
|||
"__type__": "cc.RigidBody2D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"__type__": "cc.Prefab",
|
||||
"_name": "City_Ball",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
|
@ -81,6 +82,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Graphics",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -149,6 +151,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "shadow",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -198,6 +201,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -225,6 +229,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -371,7 +376,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -619,6 +624,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Sprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -668,6 +674,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 34
|
||||
},
|
||||
|
@ -695,6 +702,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 34
|
||||
},
|
||||
|
@ -752,6 +760,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "CheeseModeSprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -801,6 +810,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 40
|
||||
},
|
||||
|
@ -828,6 +838,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 40
|
||||
},
|
||||
|
@ -1077,7 +1088,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": -30,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1148,6 +1159,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -1280,6 +1292,7 @@
|
|||
"__type__": "2b7c2ePr+dMuYseum/QYECs",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1340,6 +1353,7 @@
|
|||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1368,6 +1382,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1440,6 +1455,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"__type__": "cc.Prefab",
|
||||
"_name": "Park_Ball",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
|
@ -81,6 +82,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Graphics",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -149,6 +151,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "shadow",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -198,6 +201,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -225,6 +229,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
|
@ -374,7 +379,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -595,7 +600,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -742,6 +747,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "Sprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -791,6 +797,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 43
|
||||
},
|
||||
|
@ -818,6 +825,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 43
|
||||
},
|
||||
|
@ -875,6 +883,7 @@
|
|||
"__type__": "cc.Node",
|
||||
"_name": "CheeseModeSprite",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -924,6 +933,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 49
|
||||
},
|
||||
|
@ -951,6 +961,7 @@
|
|||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 49
|
||||
},
|
||||
|
@ -1206,7 +1217,7 @@
|
|||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": -30,
|
||||
"z": 0
|
||||
"z": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1298,6 +1309,7 @@
|
|||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
|
@ -1430,6 +1442,7 @@
|
|||
"__type__": "2b7c2ePr+dMuYseum/QYECs",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1490,6 +1503,7 @@
|
|||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1515,6 +1529,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
@ -1587,6 +1602,7 @@
|
|||
"__type__": "02a884WNWtExrO21yAjQDWZ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7087,7 +7087,7 @@
|
|||
"bullet": false,
|
||||
"awakeOnLoad": true,
|
||||
"_group": 2,
|
||||
"_type": 1,
|
||||
"_type": 3,
|
||||
"_allowSleep": true,
|
||||
"_gravityScale": 1,
|
||||
"_linearDamping": 0,
|
||||
|
@ -7758,7 +7758,7 @@
|
|||
"_offset": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": -1500
|
||||
"y": -70
|
||||
},
|
||||
"_points": [
|
||||
{
|
||||
|
@ -31761,7 +31761,7 @@
|
|||
"tag": 0,
|
||||
"_group": 2,
|
||||
"_density": 1,
|
||||
"_sensor": false,
|
||||
"_sensor": true,
|
||||
"_friction": 0.2,
|
||||
"_restitution": 0,
|
||||
"_offset": {
|
||||
|
@ -33779,7 +33779,7 @@
|
|||
"tag": 0,
|
||||
"_group": 2,
|
||||
"_density": 1,
|
||||
"_sensor": false,
|
||||
"_sensor": true,
|
||||
"_friction": 0.2,
|
||||
"_restitution": 0,
|
||||
"_offset": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
|||
import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip, CCString } from 'cc';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import { _decorator, Animation, AudioClip, CCFloat, CCString, Collider2D, Component, Contact2DType } from 'cc';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
import IPoolable from '../Pool/IPoolable';
|
||||
import Utilities from '../Utilities';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import { SoundManager } from '../Manager/SoundManager';
|
||||
import IPoolable from '../Pool/IPoolable';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import Utilities from '../Utilities';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('BoosterBase')
|
||||
|
@ -17,18 +17,20 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
private _animation: Animation;
|
||||
@property(CCString)
|
||||
public readonly displayName: string = 'CHEESE';
|
||||
|
||||
@property(CCFloat)
|
||||
protected time: number = 10;
|
||||
|
||||
private _enabled: boolean = true;
|
||||
|
||||
protected onLoad(): void {
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
}
|
||||
|
||||
private onContactBegin(self: Collider2D, other: Collider2D) {
|
||||
if (!this._enabled) return;
|
||||
this.boosterActive();
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
SoundManager.instance.playSfx(this._collectSound);
|
||||
EventManger.instance.emit(GameEvent.ObjectRelease, this.node);
|
||||
ObjectPool.release(this.node);
|
||||
|
@ -39,9 +41,9 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
async onGet() {
|
||||
this._animation.play();
|
||||
await Utilities.delay(this._animation.defaultClip.duration);
|
||||
this._collider.enabled = true;
|
||||
this._enabled = true;
|
||||
}
|
||||
onRelease() {
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
import {
|
||||
_decorator,
|
||||
AudioClip,
|
||||
CCFloat,
|
||||
CCInteger,
|
||||
clamp,
|
||||
clamp01,
|
||||
Component,
|
||||
lerp,
|
||||
Sprite,
|
||||
Node,
|
||||
tween,
|
||||
ParticleSystem,
|
||||
Prefab,
|
||||
randomRange,
|
||||
Sprite,
|
||||
tween,
|
||||
Tween,
|
||||
Vec3,
|
||||
AudioClip,
|
||||
randomRange,
|
||||
CCFloat,
|
||||
clamp01,
|
||||
ParticleSystem,
|
||||
} 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 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 ObjectPool from '../Pool/ObjectPool';
|
||||
import Utilities from '../Utilities';
|
||||
import { SequenceSound } from './SequenceSound';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
@ -145,8 +145,10 @@ export class CumulativeBar extends Component {
|
|||
},
|
||||
)
|
||||
.call(async () => {
|
||||
const fx = this._fxPool.get(ParticleSystem, this.node);
|
||||
fx.node.setWorldPosition(star.worldPosition);
|
||||
const fx = this._fxPool.get(ParticleSystem, GameManager.instance.topContainer);
|
||||
const pos = star.getWorldPosition();
|
||||
pos.z = 10;
|
||||
fx.node.setWorldPosition(pos);
|
||||
this._starPool.release(star);
|
||||
SoundManager.instance.playSfx(this._collectStartSoundFx);
|
||||
await Utilities.waitUntil(() => {
|
||||
|
@ -234,7 +236,9 @@ export class CumulativeBar extends Component {
|
|||
}
|
||||
if (selectReward) {
|
||||
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);
|
||||
await Utilities.waitUntil(() => fx.isStopped, 0.1);
|
||||
selectReward.pool.release(fx);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
_decorator,
|
||||
Animation,
|
||||
AudioClip,
|
||||
CCInteger,
|
||||
Collider2D,
|
||||
Color,
|
||||
|
@ -8,15 +9,14 @@ import {
|
|||
Contact2DType,
|
||||
Sprite,
|
||||
Vec3,
|
||||
AudioClip,
|
||||
} from 'cc';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import { GameManager } from '../Manager/GameManager';
|
||||
import { SoundManager } from '../Manager/SoundManager';
|
||||
import IPoolable from '../Pool/IPoolable';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import Utilities from '../Utilities';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
import { SoundManager } from '../Manager/SoundManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ScoreObject')
|
||||
|
@ -40,10 +40,12 @@ export class ScoreObject extends Component implements IPoolable {
|
|||
private _originColor: Color;
|
||||
private _isHit = false;
|
||||
|
||||
private _enabled: boolean = true;
|
||||
|
||||
protected onLoad(): void {
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
|
||||
this._originColor = this._sprite.color.clone();
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
|
@ -66,9 +68,10 @@ export class ScoreObject extends Component implements IPoolable {
|
|||
}
|
||||
|
||||
private async onContactBegin(selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if (!this._enabled) return;
|
||||
if (this._isHit) return;
|
||||
if (this._hitSound) SoundManager.instance.playSfx(this._hitSound);
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
// let center = this.node.getWorldPosition();
|
||||
// let other = otherCollider.node.getWorldPosition();
|
||||
// this._flyDirection = center.subtract(other);
|
||||
|
@ -88,12 +91,12 @@ export class ScoreObject extends Component implements IPoolable {
|
|||
public async onGet() {
|
||||
this._animation.play(this._animation.clips[0].name);
|
||||
await Utilities.delay(this._animation.clips[0].duration);
|
||||
this._collider.enabled = true;
|
||||
this._enabled = true;
|
||||
}
|
||||
|
||||
public onRelease() {
|
||||
this._isHit = false;
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
this.node.angle = 0;
|
||||
this.node.setScale(Vec3.ONE);
|
||||
this._sprite.color = this._originColor;
|
||||
|
|
|
@ -23,6 +23,9 @@ declare module 'cc' {
|
|||
setPositionX(x: number): void;
|
||||
setPositionY(y: number): void;
|
||||
setPositionZ(z: number): void;
|
||||
setWorldPositionX(x: number): void;
|
||||
setWorldPositionY(y: number): void;
|
||||
setWorldPositionZ(z: number): void;
|
||||
translateX(x: number, ns?: NodeSpace): void;
|
||||
translateY(y: 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);
|
||||
};
|
||||
|
||||
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 {
|
||||
this.translate(new Vec3(x, 0), ns);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import {
|
||||
_decorator,
|
||||
Animation,
|
||||
AudioClip,
|
||||
CCInteger,
|
||||
Collider2D,
|
||||
Component,
|
||||
|
@ -7,17 +9,15 @@ import {
|
|||
EventHandler,
|
||||
tween,
|
||||
Vec2,
|
||||
Animation,
|
||||
Vec3,
|
||||
AudioClip,
|
||||
} 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 { 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;
|
||||
|
||||
@ccclass('Cannon')
|
||||
|
@ -35,21 +35,24 @@ export class Cannon extends Component {
|
|||
@property({ type: EventHandler, visible: true })
|
||||
private onDone: EventHandler[] = [];
|
||||
|
||||
private _enabled: boolean = true;
|
||||
|
||||
protected onLoad(): void {
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
EventManger.instance.on(GameEvent.BallOut, this.onBallOut, this);
|
||||
}
|
||||
|
||||
private async onBeginContact(self: Collider2D, other: Collider2D) {
|
||||
if (!this._enabled) return;
|
||||
const ball = other.getComponent(Ball);
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
if (ball) {
|
||||
ball.setActiveRigi(false);
|
||||
ball.clearRigiState(false);
|
||||
tween(ball.node).to(0.1, { worldPosition: this.node.worldPosition }).start();
|
||||
await Utilities.delay(TimeConfig.DelayCannonFire);
|
||||
CameraController.instance.shake(0.2);
|
||||
this._animation.play();
|
||||
ball.setActiveRigi(true);
|
||||
ball.clearRigiState(true);
|
||||
ball.throwBall(new Vec2(0, this._force));
|
||||
SoundManager.instance.playSfx(this._soundFx);
|
||||
await Utilities.delay(TimeConfig.DelayCannonDone);
|
||||
|
@ -60,7 +63,7 @@ export class Cannon extends Component {
|
|||
|
||||
private onBallOut() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
_decorator,
|
||||
Animation,
|
||||
AudioClip,
|
||||
CCInteger,
|
||||
Collider2D,
|
||||
|
@ -7,17 +8,16 @@ import {
|
|||
Contact2DType,
|
||||
ParticleSystem,
|
||||
Prefab,
|
||||
Animation,
|
||||
} 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 { EventManger } from '../Manager/EventManger';
|
||||
import { CameraController } from '../Environments/CameraController';
|
||||
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;
|
||||
|
||||
@ccclass('Goal')
|
||||
|
@ -42,8 +42,8 @@ export class Goal extends Component {
|
|||
const ball = otherCollider.getComponent(Ball);
|
||||
if (ball) {
|
||||
GameManager.instance.goal(this._score, ball.node.getWorldPosition());
|
||||
ball.setActiveRigi(false);
|
||||
const fx = this._goalFxPool.get(ParticleSystem, this.node);
|
||||
ball.clearRigiState(false);
|
||||
const fx = this._goalFxPool.get(ParticleSystem, GameManager.instance.topContainer);
|
||||
const pos = ball.node.getWorldPosition();
|
||||
pos.z = 10;
|
||||
fx.node.setWorldPosition(pos);
|
||||
|
|
|
@ -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 { SoundManager } from '../Manager/SoundManager';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import Utilities from '../Utilities';
|
||||
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;
|
||||
|
||||
@ccclass('MultiBall')
|
||||
|
@ -26,6 +26,8 @@ export class MultiBall extends Component {
|
|||
private _trigged = false;
|
||||
private _fxPool: ObjectPool;
|
||||
|
||||
private _enabled: boolean = true;
|
||||
|
||||
protected onLoad(): void {
|
||||
this._fxPool = new ObjectPool(this._fx, 2, true);
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
|
@ -34,13 +36,17 @@ export class MultiBall extends Component {
|
|||
protected lateUpdate(dt: number): void {
|
||||
if (this._trigged) {
|
||||
CameraController.instance.shake(0.2);
|
||||
this._originBall.setActiveRigi(true);
|
||||
const ball1 = this._originBall;
|
||||
ball1.clearRigiState(false);
|
||||
const ball2 = GameManager.instance.spawnBall(false, false);
|
||||
ball2.clearRigiState(false);
|
||||
|
||||
ball1.node.setWorldPosition(this._portRight.worldPosition);
|
||||
ball1.clearRigiState(true);
|
||||
ball1.addForce(new Vec2(20, 0));
|
||||
|
||||
ball2.node.setWorldPosition(this._portLeft.worldPosition);
|
||||
ball2.clearRigiState(true);
|
||||
ball2.addForce(new Vec2(-20, 0));
|
||||
|
||||
this._trigged = false;
|
||||
|
@ -48,16 +54,18 @@ export class MultiBall extends Component {
|
|||
}
|
||||
|
||||
private async onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if (!this._enabled) return;
|
||||
if (this._trigged) return;
|
||||
this._collider.enabled = false;
|
||||
this._enabled = false;
|
||||
this._originBall = otherCollider.getComponent(Ball);
|
||||
this._originBall.setActiveRigi(false);
|
||||
this._trigged = true;
|
||||
const fx = this._fxPool.get(ParticleSystem, this.node);
|
||||
fx.node.setWorldPosition(this.node.worldPosition);
|
||||
const fx = this._fxPool.get(ParticleSystem, GameManager.instance.topContainer);
|
||||
const pos = this.node.getWorldPosition();
|
||||
pos.z = 10;
|
||||
fx.node.setWorldPosition(pos);
|
||||
SoundManager.instance.playSfx(this._soundFX);
|
||||
await Utilities.delay(TimeConfig.DelayMultiBall);
|
||||
this._collider.enabled = true;
|
||||
this._enabled = true;
|
||||
await Utilities.waitUntil(() => fx.isStopped);
|
||||
this._fxPool.release(fx);
|
||||
}
|
||||
|
|
|
@ -1,35 +1,34 @@
|
|||
import {
|
||||
_decorator,
|
||||
Animation,
|
||||
AudioClip,
|
||||
CCFloat,
|
||||
CircleCollider2D,
|
||||
Collider2D,
|
||||
Component,
|
||||
Contact2DType,
|
||||
Director,
|
||||
director,
|
||||
EventTarget,
|
||||
IPhysics2DContact,
|
||||
RigidBody2D,
|
||||
Vec2,
|
||||
ERigidBody2DType,
|
||||
geometry,
|
||||
IPhysics2DContact,
|
||||
math,
|
||||
Vec3,
|
||||
Node,
|
||||
ParticleSystem,
|
||||
Prefab,
|
||||
CircleCollider2D,
|
||||
Animation,
|
||||
RigidBody2D,
|
||||
Sprite,
|
||||
Node,
|
||||
SpriteFrame,
|
||||
Vec2,
|
||||
Vec3,
|
||||
} from 'cc';
|
||||
import IPoolable from '../Pool/IPoolable';
|
||||
import { SoundManager } from '../Manager/SoundManager';
|
||||
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 Utilities from '../Utilities';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
import { SequenceSound } from '../Environments/SequenceSound';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Ball')
|
||||
|
@ -226,18 +225,16 @@ export class Ball extends Component implements IPoolable {
|
|||
this._buffParticle.play();
|
||||
}
|
||||
|
||||
public setActiveRigi(value: boolean) {
|
||||
// this._rigidBody.enabled = value;
|
||||
if (!value) {
|
||||
this._rigidBody.linearVelocity = Vec2.ZERO.clone();
|
||||
this._rigidBody.angularVelocity = 0;
|
||||
}
|
||||
public clearRigiState(active: boolean) {
|
||||
this._rigidBody.type = active ? ERigidBody2DType.Dynamic : ERigidBody2DType.Kinematic;
|
||||
this._rigidBody.linearVelocity = Vec2.ZERO.clone();
|
||||
this._rigidBody.angularVelocity = 0;
|
||||
}
|
||||
|
||||
onGet() {
|
||||
this.clearRigiState(true);
|
||||
this._isJumping = false;
|
||||
this._isHit = false;
|
||||
this._rigidBody.enabled = true;
|
||||
this._parent = this.node.getParent();
|
||||
this._fireParticle.rateOverDistance.constant = 0;
|
||||
this._fireParticle.rateOverTime.constant = 0;
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
"_value": false
|
||||
},
|
||||
"tiled-map": {
|
||||
"_value": true
|
||||
"_value": false
|
||||
},
|
||||
"spine": {
|
||||
"_value": false
|
||||
|
@ -118,6 +118,9 @@
|
|||
"marionette": {
|
||||
"_value": false
|
||||
},
|
||||
"procedural-animation": {
|
||||
"_value": false
|
||||
},
|
||||
"custom-pipeline": {
|
||||
"_value": false
|
||||
}
|
||||
|
@ -135,7 +138,6 @@
|
|||
"particle-2d",
|
||||
"physics-2d-box2d",
|
||||
"profiler",
|
||||
"tiled-map",
|
||||
"tween",
|
||||
"ui",
|
||||
"websocket"
|
||||
|
|
Loading…
Reference in New Issue