diff --git a/assets/_Game/Materials/mat_buff.mtl b/assets/_Game/Materials/mat_buff.mtl new file mode 100644 index 0000000..4fcdbdf --- /dev/null +++ b/assets/_Game/Materials/mat_buff.mtl @@ -0,0 +1,37 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "d1346436-ac96-4271-b863-1f4fdead95b0", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + {} + ], + "_states": [ + { + "stage": 200, + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + } + ], + "_props": [ + { + "tintColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + } + } + ] +} \ No newline at end of file diff --git a/assets/_Game/Materials/mat_buff.mtl.meta b/assets/_Game/Materials/mat_buff.mtl.meta new file mode 100644 index 0000000..94362e3 --- /dev/null +++ b/assets/_Game/Materials/mat_buff.mtl.meta @@ -0,0 +1 @@ +{"ver":"1.0.20","importer":"material","imported":true,"uuid":"08b0dafd-3f2c-4d0f-a9ec-edf75ca0a191","files":[".json"],"subMetas":{},"userData":{}} diff --git a/assets/_Game/Prefabs/Ball.prefab b/assets/_Game/Prefabs/Ball.prefab index 1dbc8f1..c907499 100644 --- a/assets/_Game/Prefabs/Ball.prefab +++ b/assets/_Game/Prefabs/Ball.prefab @@ -1082,7 +1082,7 @@ "_density": 1, "_sensor": false, "_friction": 2, - "_restitution": 0.5, + "_restitution": 0.2, "_offset": { "__type__": "cc.Vec2", "x": 0, @@ -1144,7 +1144,7 @@ "__uuid__": "e4f226d3-8b68-42b8-8bf0-490b8d5765c4", "__expectedType__": "cc.Prefab" }, - "_maxSpeed": 100, + "_maxSpeed": 70, "_rigidBody": { "__id__": 75 }, diff --git a/assets/_Game/Prefabs/Buff Particle.prefab b/assets/_Game/Prefabs/Buff Particle.prefab new file mode 100644 index 0000000..6e6f34a --- /dev/null +++ b/assets/_Game/Prefabs/Buff Particle.prefab @@ -0,0 +1,758 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "Buff Particle", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "persistent": false + }, + { + "__type__": "cc.Node", + "_name": "Buff Particle", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 4 + }, + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 61 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -1384, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 25, + "y": 25, + "z": 1 + }, + "_mobility": 0, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UIMeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f2H1iPRKtGVaUJQ0ZMk4hY" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5fjDdutO9HkqZsxXhpribt" + }, + { + "__type__": "cc.ParticleSystem", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 7 + }, + "_materials": [ + { + "__uuid__": "08b0dafd-3f2c-4d0f-a9ec-edf75ca0a191", + "__expectedType__": "cc.Material" + }, + null + ], + "_visFlags": 0, + "startColor": { + "__id__": 8 + }, + "scaleSpace": 1, + "startSize3D": true, + "startSizeX": { + "__id__": 9 + }, + "startSize": { + "__id__": 9 + }, + "startSizeY": { + "__id__": 10 + }, + "startSizeZ": { + "__id__": 11 + }, + "startSpeed": { + "__id__": 12 + }, + "startRotation3D": false, + "startRotationX": { + "__id__": 13 + }, + "startRotationY": { + "__id__": 14 + }, + "startRotationZ": { + "__id__": 15 + }, + "startRotation": { + "__id__": 15 + }, + "startDelay": { + "__id__": 16 + }, + "startLifetime": { + "__id__": 17 + }, + "duration": 5, + "loop": true, + "simulationSpeed": 1, + "playOnAwake": false, + "gravityModifier": { + "__id__": 18 + }, + "rateOverTime": { + "__id__": 19 + }, + "rateOverDistance": { + "__id__": 20 + }, + "bursts": [], + "_renderCulling": false, + "_cullingMode": 0, + "_aabbHalfX": 0, + "_aabbHalfY": 0, + "_aabbHalfZ": 0, + "_dataCulling": false, + "enableCulling": false, + "_colorOverLifetimeModule": { + "__id__": 21 + }, + "_shapeModule": { + "__id__": 23 + }, + "_sizeOvertimeModule": { + "__id__": 25 + }, + "_velocityOvertimeModule": { + "__id__": 30 + }, + "_forceOvertimeModule": { + "__id__": 35 + }, + "_limitVelocityOvertimeModule": { + "__id__": 39 + }, + "_rotationOvertimeModule": { + "__id__": 44 + }, + "_textureAnimationModule": { + "__id__": 48 + }, + "_noiseModule": { + "__id__": 52 + }, + "_trailModule": { + "__id__": 53 + }, + "renderer": { + "__id__": 60 + }, + "_prewarm": false, + "_capacity": 100, + "_simulationSpace": 1, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b60TP4ZStBtZthYfiXRT3Q" + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 204, + "b": 0, + "a": 50 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0.5, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 3, + "constantMin": 1, + "constantMax": 10, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 1, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 2, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": -20, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 50, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.ColorOvertimeModule", + "_enable": false, + "color": { + "__id__": 22 + } + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + } + }, + { + "__type__": "cc.ShapeModule", + "_enable": true, + "_shapeType": 0, + "shapeType": 0, + "emitFrom": 3, + "alignToDirection": false, + "randomDirectionAmount": 0, + "sphericalDirectionAmount": 0, + "randomPositionAmount": 0, + "radius": 1, + "radiusThickness": 1, + "arcMode": 0, + "arcSpread": 0, + "arcSpeed": { + "__id__": 24 + }, + "length": 5, + "boxThickness": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_position": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_rotation": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_scale": { + "__type__": "cc.Vec3", + "x": 80, + "y": 1, + "z": 1 + }, + "_arc": 6.283185307179586, + "_angle": 0.4363323129985824 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 1, + "multiplier": 1 + }, + { + "__type__": "cc.SizeOvertimeModule", + "_enable": false, + "separateAxes": false, + "size": { + "__id__": 26 + }, + "x": { + "__id__": 27 + }, + "y": { + "__id__": 28 + }, + "z": { + "__id__": 29 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.VelocityOvertimeModule", + "_enable": false, + "x": { + "__id__": 31 + }, + "y": { + "__id__": 32 + }, + "z": { + "__id__": 33 + }, + "speedModifier": { + "__id__": 34 + }, + "space": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 1, + "multiplier": 1 + }, + { + "__type__": "cc.ForceOvertimeModule", + "_enable": false, + "x": { + "__id__": 36 + }, + "y": { + "__id__": 37 + }, + "z": { + "__id__": 38 + }, + "space": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.LimitVelocityOvertimeModule", + "_enable": false, + "limitX": { + "__id__": 40 + }, + "limitY": { + "__id__": 41 + }, + "limitZ": { + "__id__": 42 + }, + "limit": { + "__id__": 43 + }, + "dampen": 3, + "separateAxes": false, + "space": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.RotationOvertimeModule", + "_enable": false, + "_separateAxes": false, + "x": { + "__id__": 45 + }, + "y": { + "__id__": 46 + }, + "z": { + "__id__": 47 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.TextureAnimationModule", + "_enable": false, + "_numTilesX": 0, + "numTilesX": 0, + "_numTilesY": 0, + "numTilesY": 0, + "_mode": 0, + "animation": 0, + "frameOverTime": { + "__id__": 49 + }, + "startFrame": { + "__id__": 51 + }, + "cycleCount": 0, + "_flipU": 0, + "_flipV": 0, + "_uvChannelMask": -1, + "randomRow": false, + "rowIndex": 0 + }, + { + "__type__": "cc.CurveRange", + "mode": 1, + "spline": { + "__id__": 50 + }, + "multiplier": 1 + }, + { + "__type__": "cc.RealCurve", + "_times": [ + 0, + 1 + ], + "_values": [ + { + "__type__": "cc.RealKeyframeValue", + "interpolationMode": 2, + "tangentWeightMode": 0, + "value": 1, + "rightTangent": 0, + "rightTangentWeight": 0, + "leftTangent": 0, + "leftTangentWeight": 0, + "easingMethod": 0, + "__editorExtras__": null + }, + { + "__type__": "cc.RealKeyframeValue", + "interpolationMode": 2, + "tangentWeightMode": 0, + "value": 1, + "rightTangent": 0, + "rightTangentWeight": 0, + "leftTangent": 0, + "leftTangentWeight": 0, + "easingMethod": 0, + "__editorExtras__": null + } + ], + "preExtrapolation": 1, + "postExtrapolation": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 0, + "multiplier": 1 + }, + { + "__type__": "cc.NoiseModule", + "_enable": false, + "_strengthX": 10, + "_strengthY": 10, + "_strengthZ": 10, + "_noiseSpeedX": 0, + "_noiseSpeedY": 0, + "_noiseSpeedZ": 0, + "_noiseFrequency": 1, + "_remapX": 0, + "_remapY": 0, + "_remapZ": 0, + "_octaves": 1, + "_octaveMultiplier": 0.5, + "_octaveScale": 2 + }, + { + "__type__": "cc.TrailModule", + "_enable": false, + "mode": 0, + "lifeTime": { + "__id__": 54 + }, + "_minParticleDistance": 0.1, + "existWithParticles": true, + "textureMode": 0, + "widthFromParticle": false, + "widthRatio": { + "__id__": 55 + }, + "colorFromParticle": false, + "colorOverTrail": { + "__id__": 56 + }, + "colorOvertime": { + "__id__": 57 + }, + "_space": 0, + "_particleSystem": { + "__id__": 6 + } + }, + { + "__type__": "cc.CurveRange", + "mode": 3, + "constantMin": 0, + "constantMax": 0.15, + "multiplier": 1 + }, + { + "__type__": "cc.CurveRange", + "mode": 0, + "constant": 10, + "multiplier": 50 + }, + { + "__type__": "cc.GradientRange", + "_mode": 0, + "color": { + "__type__": "cc.Color", + "r": 255, + "g": 250, + "b": 134, + "a": 221 + } + }, + { + "__type__": "cc.GradientRange", + "_mode": 1, + "gradient": { + "__id__": 58 + } + }, + { + "__type__": "cc.Gradient", + "colorKeys": [], + "alphaKeys": [ + { + "__id__": 59 + } + ], + "mode": 0 + }, + { + "__type__": "cc.AlphaKey", + "alpha": 255, + "time": 0 + }, + { + "__type__": "cc.ParticleSystemRenderer", + "_renderMode": 0, + "_velocityScale": 1, + "_lengthScale": 1, + "_mesh": null, + "_cpuMaterial": { + "__uuid__": "08b0dafd-3f2c-4d0f-a9ec-edf75ca0a191", + "__expectedType__": "cc.Material" + }, + "_gpuMaterial": null, + "_mainTexture": null, + "_useGPU": false, + "_alignSpace": 2 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "d6MYHCymBFRbEj0OPlLt9v", + "instance": null, + "targetOverrides": null + } +] \ No newline at end of file diff --git a/assets/_Game/Prefabs/Buff Particle.prefab.meta b/assets/_Game/Prefabs/Buff Particle.prefab.meta new file mode 100644 index 0000000..d932834 --- /dev/null +++ b/assets/_Game/Prefabs/Buff Particle.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.43", + "importer": "prefab", + "imported": true, + "uuid": "c7549312-ab7b-4974-8863-1a55c119c34f", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "Buff Particle" + } +} diff --git a/assets/_Game/Scenes/EndLessScene.scene b/assets/_Game/Scenes/EndLessScene.scene index 440eaff..848d3c1 100644 --- a/assets/_Game/Scenes/EndLessScene.scene +++ b/assets/_Game/Scenes/EndLessScene.scene @@ -25,7 +25,7 @@ "_active": true, "_components": [], "_prefab": { - "__id__": 517 + "__id__": 538 }, "_lpos": { "__type__": "cc.Vec3", @@ -56,7 +56,7 @@ }, "autoReleaseAssets": false, "_globals": { - "__id__": 518 + "__id__": 541 }, "_id": "82e6ef2e-3f9c-4d4e-ab02-dc963e925b88" }, @@ -3002,13 +3002,13 @@ }, { "__type__": "cc.Vec2", - "x": -206.8, - "y": -86.4 + "x": -273.8, + "y": -234.9 }, { "__type__": "cc.Vec2", - "x": 72.5, - "y": -214 + "x": 3.6, + "y": -366.7 }, { "__type__": "cc.Vec2", @@ -3434,13 +3434,13 @@ }, { "__type__": "cc.Vec2", - "x": -71.9, - "y": -212.6 + "x": -8.3, + "y": -351.6 }, { "__type__": "cc.Vec2", - "x": 207.8, - "y": -85.2 + "x": 269.3, + "y": -221.2 }, { "__type__": "cc.Vec2", @@ -5607,7 +5607,7 @@ "_density": 1, "_sensor": false, "_friction": 2, - "_restitution": 0.5, + "_restitution": 0, "_offset": { "__type__": "cc.Vec2", "x": 0, @@ -5646,128 +5646,123 @@ }, { "__type__": "cc.Vec2", - "x": -253.4, - "y": -34.6 + "x": -258.3, + "y": -48.5 }, { "__type__": "cc.Vec2", - "x": -282.129, - "y": -147.8817434944238 + "x": -273.7, + "y": -119.8 }, { "__type__": "cc.Vec2", - "x": -272, - "y": -148.7 + "x": -273.2, + "y": -147.6 }, { "__type__": "cc.Vec2", - "x": -255.9, - "y": -86.7 + "x": -257.8, + "y": -72.5 }, { "__type__": "cc.Vec2", - "x": -240.9, - "y": -40.7 + "x": -240.7, + "y": -31.8 }, { "__type__": "cc.Vec2", - "x": -219.7, - "y": -1 + "x": -221.9, + "y": 2.5 }, { "__type__": "cc.Vec2", - "x": -194.8, - "y": 33.9 + "x": -195, + "y": 38.4 }, { "__type__": "cc.Vec2", - "x": -161.1, - "y": 63.4 + "x": -163.8, + "y": 68.6 }, { "__type__": "cc.Vec2", - "x": -123.1, - "y": 86.3 - }, - { - "__type__": "cc.Vec2", - "x": -78.3, - "y": 105.9 + "x": -124.5, + "y": 94.4 }, { "__type__": "cc.Vec2", "x": -32.3, - "y": 110.5 + "y": 120.8 }, { "__type__": "cc.Vec2", - "x": 35.5, - "y": 111.4 + "x": 35.7, + "y": 122.6 }, { "__type__": "cc.Vec2", - "x": 64.6, - "y": 107.3 + "x": 65, + "y": 116.6 }, { "__type__": "cc.Vec2", - "x": 127.4, - "y": 85.4 + "x": 127.6, + "y": 93.9 }, { "__type__": "cc.Vec2", - "x": 164.9, - "y": 61.4 + "x": 166, + "y": 68.7 }, { "__type__": "cc.Vec2", - "x": 197.7, - "y": 31.6 + "x": 200, + "y": 39.9 }, { "__type__": "cc.Vec2", - "x": 224, - "y": -5.7 + "x": 225.4, + "y": 5.2 }, { "__type__": "cc.Vec2", - "x": 246.9, - "y": -47.2 + "x": 245.3, + "y": -31.4 }, { "__type__": "cc.Vec2", - "x": 259.3, - "y": -84.4 + "x": 262.8, + "y": -74.4 }, { "__type__": "cc.Vec2", - "x": 272.4, - "y": -124.4 + "x": 274.4, + "y": -119.9 }, { "__type__": "cc.Vec2", - "x": 274.1, - "y": -153.4 + "x": 274.5, + "y": -149.6 }, { "__type__": "cc.Vec2", - "x": 280.03138661710034, - "y": -154.17458364312267 + "x": 278.9, + "y": -148.3 }, { "__type__": "cc.Vec2", - "x": 277.6, - "y": -103.2 + "x": 279.6, + "y": -117.1 }, { "__type__": "cc.Vec2", - "x": 258.5, - "y": -46.8 + "x": 260.4, + "y": -55.7 }, { "__type__": "cc.Vec2", - "x": 225.49343866171006, - "y": 24.122553903345732 + "x": 225.5, + "y": 20.5 }, { "__type__": "cc.Vec2", @@ -5805,38 +5800,38 @@ "_points": [ { "__type__": "cc.Vec2", - "x": 119.7, - "y": 17.9 + "x": 118.1, + "y": 14.2 }, { "__type__": "cc.Vec2", - "x": 57.2, - "y": 35.3 + "x": 57.8, + "y": 32.8 }, { "__type__": "cc.Vec2", - "x": -48.9, - "y": 35.5 + "x": -48, + "y": 32.4 }, { "__type__": "cc.Vec2", - "x": -115.3, - "y": 18.8 + "x": -110.9, + "y": 14.7 }, { "__type__": "cc.Vec2", - "x": -151.4, - "y": -21.1 + "x": -145.2, + "y": -25.5 }, { "__type__": "cc.Vec2", - "x": -167.6, - "y": -55.6 + "x": -163.2, + "y": -65.3 }, { "__type__": "cc.Vec2", - "x": -173.2, - "y": -91.3 + "x": -169.8, + "y": -93.8 }, { "__type__": "cc.Vec2", @@ -5910,13 +5905,13 @@ }, { "__type__": "cc.Vec2", - "x": 174.9, - "y": -65.8 + "x": 170.5, + "y": -66.7 }, { "__type__": "cc.Vec2", - "x": 155.7, - "y": -20.2 + "x": 152.6, + "y": -25.2 } ], "_id": "63CkUrxYBKv5H+yTE4bV0U" @@ -6627,10 +6622,10 @@ "__prefab": null, "tag": 0, "_group": 32, - "_density": 1, + "_density": 1.5, "_sensor": false, "_friction": 2, - "_restitution": 1.5, + "_restitution": 1, "_offset": { "__type__": "cc.Vec2", "x": 0, @@ -8711,7 +8706,7 @@ "_patrolPoint2": { "__id__": 224 }, - "_speed": 100, + "_speed": 50, "_requireGoal": 9, "_curveY": false, "_patrolCurve": { @@ -11558,7 +11553,7 @@ }, "_size": { "__type__": "cc.Size", - "width": 289.2, + "width": 600, "height": 131 }, "_id": "98zDTZnlhAOYrrE1sIfU+t" @@ -17762,7 +17757,7 @@ "y": -1200, "z": 0 }, - "_balls": 3, + "_ballsInit": 3, "_startSound": { "__uuid__": "6452248b-259c-4844-b0e1-70f47d69955e", "__expectedType__": "cc.AudioClip" @@ -17916,18 +17911,21 @@ "_children": [ { "__id__": 475 + }, + { + "__id__": 523 } ], "_active": true, "_components": [ { - "__id__": 514 + "__id__": 535 }, { - "__id__": 515 + "__id__": 536 }, { - "__id__": 516 + "__id__": 537 } ], "_prefab": null, @@ -17981,19 +17979,22 @@ "__id__": 488 }, { - "__id__": 497 + "__id__": 492 + }, + { + "__id__": 501 } ], "_active": true, "_components": [ { - "__id__": 511 + "__id__": 520 }, { - "__id__": 512 + "__id__": 521 }, { - "__id__": 513 + "__id__": 522 } ], "_prefab": null, @@ -18440,6 +18441,144 @@ "_lockFlags": 0, "_id": "31Fx2973dAt4puJYDiv8Pp" }, + { + "__type__": "cc.Node", + "_name": "Timer", + "_objFlags": 0, + "_parent": { + "__id__": 475 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 489 + }, + { + "__id__": 490 + }, + { + "__id__": 491 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 490, + "y": 907, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "67r7OdNshLcre6ayPVZQXM" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 488 + }, + "_enabled": true, + "__prefab": null, + "_contentSize": { + "__type__": "cc.Size", + "width": 389.26, + "height": 126 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_id": "aaOHbgUfNOOLyY/i3dpKo3" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 488 + }, + "_enabled": true, + "__prefab": null, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "00:00:00", + "_horizontalAlign": 2, + "_verticalAlign": 1, + "_actualFontSize": 100, + "_fontSize": 100, + "_fontFamily": "Arial", + "_lineHeight": 100, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "9eDkBPfeFAN5w/ou1UXmvK" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 488 + }, + "_enabled": true, + "__prefab": null, + "_alignFlags": 33, + "_target": null, + "_left": 0, + "_right": 50, + "_top": 200, + "_bottom": -76.00000000000001, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 252, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "b3QhWFDLdOCo+k1xKJccsP" + }, { "__type__": "cc.Node", "_name": "StartPanel", @@ -18449,10 +18588,60 @@ }, "_children": [ { - "__id__": 489 + "__id__": 493 } ], "_active": false, + "_components": [ + { + "__id__": 498 + }, + { + "__id__": 499 + }, + { + "__id__": 500 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "2cjr2qZLBDcK89R4kFuVvO" + }, + { + "__type__": "cc.Node", + "_name": "StartButton", + "_objFlags": 0, + "_parent": { + "__id__": 492 + }, + "_children": [], + "_active": true, "_components": [ { "__id__": 494 @@ -18492,56 +18681,6 @@ "y": 0, "z": 0 }, - "_id": "2cjr2qZLBDcK89R4kFuVvO" - }, - { - "__type__": "cc.Node", - "_name": "StartButton", - "_objFlags": 0, - "_parent": { - "__id__": 488 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 490 - }, - { - "__id__": 491 - }, - { - "__id__": 492 - } - ], - "_prefab": null, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 33554432, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, "_id": "e8XiYaBZFP9JAI3TvQoyfu" }, { @@ -18549,7 +18688,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 489 + "__id__": 493 }, "_enabled": true, "__prefab": null, @@ -18570,7 +18709,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 489 + "__id__": 493 }, "_enabled": true, "__prefab": null, @@ -18608,13 +18747,13 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 489 + "__id__": 493 }, "_enabled": true, "__prefab": null, "clickEvents": [ { - "__id__": 493 + "__id__": 497 } ], "_interactable": true, @@ -18666,7 +18805,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 489 + "__id__": 493 }, "_id": "b5HEsyyjZJ8Yb2u2q1fD82" }, @@ -18685,7 +18824,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 488 + "__id__": 492 }, "_enabled": true, "__prefab": null, @@ -18706,7 +18845,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 488 + "__id__": 492 }, "_enabled": true, "__prefab": null, @@ -18744,7 +18883,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 488 + "__id__": 492 }, "_enabled": true, "__prefab": null, @@ -18777,22 +18916,25 @@ }, "_children": [ { - "__id__": 498 + "__id__": 502 }, { - "__id__": 503 + "__id__": 507 + }, + { + "__id__": 512 } ], "_active": false, "_components": [ { - "__id__": 508 + "__id__": 517 }, { - "__id__": 509 + "__id__": 518 }, { - "__id__": 510 + "__id__": 519 } ], "_prefab": null, @@ -18830,19 +18972,19 @@ "_name": "RestartButton", "_objFlags": 0, "_parent": { - "__id__": 497 + "__id__": 501 }, "_children": [], "_active": true, "_components": [ { - "__id__": 499 + "__id__": 503 }, { - "__id__": 500 + "__id__": 504 }, { - "__id__": 501 + "__id__": 505 } ], "_prefab": null, @@ -18880,7 +19022,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 498 + "__id__": 502 }, "_enabled": true, "__prefab": null, @@ -18901,7 +19043,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 498 + "__id__": 502 }, "_enabled": true, "__prefab": null, @@ -18939,13 +19081,13 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 498 + "__id__": 502 }, "_enabled": true, "__prefab": null, "clickEvents": [ { - "__id__": 502 + "__id__": 506 } ], "_interactable": true, @@ -18997,7 +19139,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 498 + "__id__": 502 }, "_id": "a8Mg86ufxIhZPm+HYCnlf2" }, @@ -19016,22 +19158,22 @@ "_name": "Result", "_objFlags": 0, "_parent": { - "__id__": 497 + "__id__": 501 }, "_children": [], "_active": true, "_components": [ { - "__id__": 504 + "__id__": 508 }, { - "__id__": 505 + "__id__": 509 }, { - "__id__": 506 + "__id__": 510 }, { - "__id__": 507 + "__id__": 511 } ], "_prefab": null, @@ -19069,7 +19211,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 503 + "__id__": 507 }, "_enabled": true, "__prefab": null, @@ -19090,7 +19232,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 503 + "__id__": 507 }, "_enabled": true, "__prefab": null, @@ -19128,7 +19270,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 503 + "__id__": 507 }, "_enabled": true, "__prefab": null, @@ -19157,7 +19299,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 503 + "__id__": 507 }, "_enabled": true, "__prefab": null, @@ -19171,12 +19313,172 @@ "_width": 4, "_id": "6bX0nhgJZBgpzlb0TvnHvw" }, + { + "__type__": "cc.Node", + "_name": "Timer", + "_objFlags": 0, + "_parent": { + "__id__": 501 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 513 + }, + { + "__id__": 514 + }, + { + "__id__": 515 + }, + { + "__id__": 516 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 258.726, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "cbRYxjcYlKyK5RuiIILEDH" + }, { "__type__": "cc.UITransform", "_name": "", "_objFlags": 0, "node": { - "__id__": 497 + "__id__": 512 + }, + "_enabled": true, + "__prefab": null, + "_contentSize": { + "__type__": "cc.Size", + "width": 408.29, + "height": 134 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "3ctMCfMNxCgbfB+vYxOIz3" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 512 + }, + "_enabled": true, + "__prefab": null, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "00:00:00", + "_horizontalAlign": 2, + "_verticalAlign": 1, + "_actualFontSize": 100, + "_fontSize": 100, + "_fontFamily": "Arial", + "_lineHeight": 100, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": true, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "04vVYPL7REqKPnBCTG0JQI" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 512 + }, + "_enabled": true, + "__prefab": null, + "_alignFlags": 18, + "_target": null, + "_left": 0, + "_right": 50, + "_top": 200, + "_bottom": -76.00000000000001, + "_horizontalCenter": 0, + "_verticalCenter": 258.726, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 252, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "75XfQEq7xK7q1uxB1f3Qv3" + }, + { + "__type__": "cc.LabelOutline", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 512 + }, + "_enabled": true, + "__prefab": null, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_width": 4, + "_id": "25d9gljfFFqZbvizsch6F+" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 501 }, "_enabled": true, "__prefab": null, @@ -19197,7 +19499,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 497 + "__id__": 501 }, "_enabled": true, "__prefab": null, @@ -19235,7 +19537,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 497 + "__id__": 501 }, "_enabled": true, "__prefab": null, @@ -19328,16 +19630,172 @@ "__id__": 486 }, "_resultLabel": { - "__id__": 505 + "__id__": 509 }, + "_buffFx": null, "_startPanel": { - "__id__": 488 + "__id__": 492 }, "_overPanel": { - "__id__": 497 + "__id__": 501 + }, + "_timeLabe": { + "__id__": 490 + }, + "_timeResult": { + "__id__": 514 }, "_id": "449hzGcyZL+Lsj/r1gnEMe" }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 474 + }, + "_prefab": { + "__id__": 524 + }, + "__editorExtras__": {} + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 523 + }, + "asset": { + "__uuid__": "c7549312-ab7b-4974-8863-1a55c119c34f", + "__expectedType__": "cc.Prefab" + }, + "fileId": "d6MYHCymBFRbEj0OPlLt9v", + "instance": { + "__id__": 525 + }, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "571ZGjYsFNYb+wuKERqsTk", + "prefabRootNode": null, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 526 + }, + { + "__id__": 528 + }, + { + "__id__": 529 + }, + { + "__id__": 530 + }, + { + "__id__": 531 + }, + { + "__id__": 533 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 527 + }, + "propertyPath": [ + "_name" + ], + "value": "Buff Particle" + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "d6MYHCymBFRbEj0OPlLt9v" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 527 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": -1400, + "z": 10 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 527 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 527 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 532 + }, + "propertyPath": [ + "_enabled" + ], + "value": false + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "1fn6gSQXtGgIjZIz2U6eta" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 534 + }, + "propertyPath": [ + "_enabled" + ], + "value": true + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "88kcSeLaNCI62fQBgRBS9L" + ] + }, { "__type__": "cc.UITransform", "_name": "", @@ -19409,27 +19867,58 @@ "asset": null, "fileId": "4c16bf85-f009-4abe-b793-f3a1924392e4", "instance": null, - "targetOverrides": [] + "targetOverrides": [ + { + "__id__": 539 + } + ], + "nestedPrefabInstanceRoots": [ + { + "__id__": 523 + } + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 522 + }, + "sourceInfo": null, + "propertyPath": [ + "_buffFx" + ], + "target": { + "__id__": 523 + }, + "targetInfo": { + "__id__": 540 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "b60TP4ZStBtZthYfiXRT3Q" + ] }, { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 519 + "__id__": 542 }, "shadows": { - "__id__": 520 + "__id__": 543 }, "_skybox": { - "__id__": 521 + "__id__": 544 }, "fog": { - "__id__": 522 + "__id__": 545 }, "octree": { - "__id__": 523 + "__id__": 546 }, "lightProbeInfo": { - "__id__": 524 + "__id__": 547 }, "bakedWithStationaryMainLight": false, "bakedWithHighpLightmap": false diff --git a/assets/_Game/Scripts/GamePlay/Enemy.ts b/assets/_Game/Scripts/GamePlay/Enemy.ts index adb1df8..32302f1 100644 --- a/assets/_Game/Scripts/GamePlay/Enemy.ts +++ b/assets/_Game/Scripts/GamePlay/Enemy.ts @@ -15,6 +15,7 @@ import { import { EventManger } from '../Manager/EventManger'; import GameEvent from '../Events/GameEvent'; import ScoreType from '../Enum/ScoreType'; +import GameState from '../Enum/GameState'; const { ccclass, property } = _decorator; @ccclass('Enemy') @@ -47,16 +48,25 @@ export class Enemy extends Component { protected onLoad(): void { EventManger.instance.on(GameEvent.Score, this.onScore, this); + EventManger.instance.on(GameEvent.GameStateChange, this.onGameStateChange, this); + this._collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); } - protected async start() { + protected start(): void { + this.init(); + } + + protected async init() { this._collider.node.setWorldPosition(this._patrolPoint1.worldPosition); const pos = this._patrolPoint1.getWorldPosition(); this.x = pos.x; this.y = pos.y; this._distance = Math.abs(this._patrolPoint2.worldPosition.x - this.x); this._direction = this._patrolPoint1.worldPosition.x < this._patrolPoint2.worldPosition.x ? 1 : -1; + this._processDistance = 0; + this._currentGoal = 0; + this._isActive = false; this._collider.node.active = false; } @@ -115,4 +125,16 @@ export class Enemy extends Component { } } } + + private onGameStateChange(state: GameState) { + switch (state) { + case GameState.Init: + break; + case GameState.Playing: + break; + case GameState.GameOver: + this.init(); + break; + } + } } diff --git a/assets/_Game/Scripts/Manager/GameManager.ts b/assets/_Game/Scripts/Manager/GameManager.ts index 94a3078..06066b9 100644 --- a/assets/_Game/Scripts/Manager/GameManager.ts +++ b/assets/_Game/Scripts/Manager/GameManager.ts @@ -10,6 +10,7 @@ import { Director, director, AudioClip, + Label, } from 'cc'; import ObjectPool from '../Pool/ObjectPool'; import { Ball } from '../GamePlay/Ball'; @@ -39,7 +40,7 @@ export class GameManager extends Component { @property({ visible: true }) private _ballSpawnPosition: Vec3; @property({ type: CCInteger, visible: true }) - private _balls = 3; + private readonly _ballsInit = 3; @property({ type: AudioClip, visible: true }) private _startSound: AudioClip; @property({ type: AudioClip, visible: true }) @@ -48,10 +49,12 @@ export class GameManager extends Component { private _ballPool: ObjectPool; private _FloatingScorePool: ObjectPool; private _gameState: GameState; + private _balls: number; public get balls() { - return this._balls; + return this._ballsInit; } + private _score = 0; private _isMultiBall = false; private _currentBallInGame = 0; @@ -143,6 +146,7 @@ export class GameManager extends Component { } public async play() { + this._balls = this._ballsInit; SoundManager.instance.playBGM(this._backgroundMusic, 0.5); this.changeGameState(GameState.Playing); await Utilities.delay(1000); @@ -150,7 +154,7 @@ export class GameManager extends Component { } public async restart() { - this._balls = 3; + this._balls = this._ballsInit; this._score = 0; this._currentBallInGame = 0; this._isMultiBall = false; diff --git a/assets/_Game/Scripts/Manager/SoundManager.ts b/assets/_Game/Scripts/Manager/SoundManager.ts index 72867f9..207c2a5 100644 --- a/assets/_Game/Scripts/Manager/SoundManager.ts +++ b/assets/_Game/Scripts/Manager/SoundManager.ts @@ -83,9 +83,15 @@ export class SoundManager extends Component { public playSfx(audioClip: AudioClip, volume = 1, loop = false) { let soundSource = this._audioSourcesSfx[audioClip.uuid]; + if (soundSource) { soundSource.volume = volume; soundSource.source.loop = loop; + if (loop) return; + if (soundSource.source.playing) { + soundSource.source.playOneShot(audioClip, this.isMute ? 0 : volume); + return; + } soundSource.play(); return; } diff --git a/assets/_Game/Scripts/Manager/SoundSource.ts b/assets/_Game/Scripts/Manager/SoundSource.ts new file mode 100644 index 0000000..1ab0e8c --- /dev/null +++ b/assets/_Game/Scripts/Manager/SoundSource.ts @@ -0,0 +1,35 @@ +import { AudioClip, AudioSource, Pool } from 'cc'; +import Utilities from '../Utilities'; + +export class SoundSource { + private _pool: Pool; + public volume = 1; + public mute = false; + public clip: AudioClip; + private _currentAudioSource: AudioSource; + + constructor() { + this._pool = new Pool( + () => { + const source = new AudioSource(); + source.playOnAwake = false; + return source; + }, + 10, + (obj) => obj.destroy(), + ); + } + + public async play() { + this._currentAudioSource = this._pool.alloc(); + this._currentAudioSource.volume = this.mute ? 0 : this.volume; + _currentAudioSource.clip = this.clip; + _currentAudioSource.play(); + await Utilities.waitUntil(() => !source.playing); + this._pool.free(source); + } + + public stop() { + this._currentAudioSource.stop(); + } +} diff --git a/assets/_Game/Scripts/Manager/SoundSource.ts.meta b/assets/_Game/Scripts/Manager/SoundSource.ts.meta new file mode 100644 index 0000000..8b4cd19 --- /dev/null +++ b/assets/_Game/Scripts/Manager/SoundSource.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "9f4eb11d-f1a9-42b3-a388-5c9e48c87851", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/_Game/Scripts/Manager/SpawnObjectManager.ts b/assets/_Game/Scripts/Manager/SpawnObjectManager.ts index 33f19ac..9a920ee 100644 --- a/assets/_Game/Scripts/Manager/SpawnObjectManager.ts +++ b/assets/_Game/Scripts/Manager/SpawnObjectManager.ts @@ -3,6 +3,8 @@ import ObjectPool from '../Pool/ObjectPool'; import { ScoreObject } from '../Environments/ScoreObject'; import { EventManger } from './EventManger'; import GameEvent from '../Events/GameEvent'; +import GameState from '../Enum/GameState'; +import Utilities from '../Utilities'; const { ccclass, property } = _decorator; @ccclass('SpawnObjectManager') @@ -23,11 +25,13 @@ export class SpawnObjectManager extends Component { private _pools: ObjectPool[] = []; private _usedPoints: { [key: string]: Node } = {}; + private _playing = false; private _timer = 0; protected onLoad(): void { SpawnObjectManager._instance = this; EventManger.instance.on(GameEvent.ScoreObjectRelease, this.onObjectRelease, this); + EventManger.instance.on(GameEvent.GameStateChange, this.onGameStateChange, this); for (let i = 0; i < this._objects.length; i++) { const prefab = this._objects[i]; @@ -35,13 +39,8 @@ export class SpawnObjectManager extends Component { } } - protected start(): void { - for (let i = 0; i < randomRangeInt(5, 10); i++) { - this.spawn(); - } - } - protected update(dt: number): void { + if (!this._playing) return; this._timer += dt; if (this._timer >= this._spawnTime) { this._timer = 0; @@ -63,4 +62,21 @@ export class SpawnObjectManager extends Component { private onObjectRelease(obj: Node) { delete this._usedPoints[obj.uuid]; } + + private onGameStateChange(state: GameState) { + switch (state) { + case GameState.Init: + break; + case GameState.Playing: + this._playing = true; + for (let i = 0; i < randomRangeInt(5, 10); i++) { + this.spawn(); + } + break; + case GameState.GameOver: + this._playing = false; + this._pools.forEach((pool) => pool.releaseAll()); + break; + } + } } diff --git a/assets/_Game/Scripts/Pool/ObjectPool.ts b/assets/_Game/Scripts/Pool/ObjectPool.ts index 309a34b..01841b3 100644 --- a/assets/_Game/Scripts/Pool/ObjectPool.ts +++ b/assets/_Game/Scripts/Pool/ObjectPool.ts @@ -2,14 +2,18 @@ import { Component, Node, Prefab, director, instantiate } from 'cc'; import IPoolable from './IPoolable'; export default class ObjectPool { - private _inactives: Node[] = []; + private _inactive: Node[] = []; private _actives: Node[] = []; private _prefab: Prefab; private _expandable; private _poolHandlerComp: new () => any; + private get all() { + return [...this._actives, ...this._inactive]; + } + public get countInactive() { - return this._inactives.length; + return this._inactive.length; } public get countActive() { @@ -27,7 +31,7 @@ export default class ObjectPool { for (let i = 0; i < size; ++i) { let obj = instantiate(this._prefab); // create node instance obj.removeFromParent(); - this._inactives.push(obj); + this._inactive.push(obj); ObjectPool._poolLookUp[obj.uuid] = this; } } @@ -44,9 +48,9 @@ export default class ObjectPool { public get(parent?: Node, classConstructor?: new () => T): T | Node { let obj: Node = null; let p = parent || director.getScene(); - if (this._inactives.length > 0) { + if (this._inactive.length > 0) { // Pop the last object in pool - obj = this._inactives.pop(); + obj = this._inactive.pop(); } else if (this._expandable) { // if not enough node in the pool, we call cc.instantiate to create node obj = instantiate(this._prefab); @@ -74,10 +78,11 @@ export default class ObjectPool { public release(obj: T | Node): void { let node = obj instanceof Node ? obj : obj.node; const index = this._actives.indexOf(node); + //check obj is belongs to pool if (index === -1) return; this._actives.splice(index, 1); - this._inactives.push(node); + this._inactive.push(node); // Invoke pool handler const handler = this._poolHandlerComp ? node.getComponent(this._poolHandlerComp) : null; @@ -89,8 +94,8 @@ export default class ObjectPool { } public clear() { - this._inactives.forEach((obj) => obj.destroy()); - this._inactives = []; + this.all.forEach((obj) => obj.destroy()); + this._inactive = []; this._actives = []; Object.keys(ObjectPool._poolLookUp).forEach((key) => { if (ObjectPool._poolLookUp[key] === this) { @@ -98,4 +103,8 @@ export default class ObjectPool { } }); } + + public releaseAll() { + this.all.forEach((obj) => this.release(obj)); + } } diff --git a/assets/_Game/Scripts/UI/UIController.ts b/assets/_Game/Scripts/UI/UIController.ts index 39fa0df..6b3cded 100644 --- a/assets/_Game/Scripts/UI/UIController.ts +++ b/assets/_Game/Scripts/UI/UIController.ts @@ -1,4 +1,4 @@ -import { _decorator, Component, Label, Node, tween } from 'cc'; +import { _decorator, Component, Label, Node, ParticleSystem, tween } from 'cc'; import { EventManger } from '../Manager/EventManger'; import GameEvent from '../Events/GameEvent'; import ScoreType from '../Enum/ScoreType'; @@ -17,18 +17,34 @@ export class UIController extends Component { private _goalLabel: Label; @property({ type: Label, visible: true }) private _resultLabel: Label; + @property({ type: ParticleSystem, visible: true }) + private _buffFx: ParticleSystem; @property({ type: Node, visible: true }) private _startPanel: Node; @property({ type: Node, visible: true }) private _overPanel: Node; + @property({ type: Label, visible: true }) + private _timeLabe: Label; + @property({ type: Label, visible: true }) + private _timeResult: Label; + private _timer = 0; + private _playing = false; protected onLoad(): void { EventManger.instance.on(GameEvent.Score, this.onScore, this); EventManger.instance.on(GameEvent.BallOut, this.onBallOut, this); EventManger.instance.on(GameEvent.GameStateChange, this.onGameStateChange, this); + EventManger.instance.on(GameEvent.MultiBall, this.onMultiBall, this); this._goalLabel.string = ''; } + protected update(dt: number): void { + if (this._playing) { + this._timer += dt; + this._timeLabe.string = this.secondsToTime(this._timer); + } + } + private async onScore(score: number, type: ScoreType) { this._scoreLabel.string = `Score: ${score}`; if (type == ScoreType.Goal) { @@ -51,15 +67,38 @@ export class UIController extends Component { this._startPanel.active = true; break; case GameState.Playing: + this._playing = true; this._scoreLabel.string = 'Score: 0'; this._ballLabel.string = `Ball: ${GameManager.instance.balls}`; this._startPanel.active = false; this._overPanel.active = false; break; case GameState.GameOver: + this._playing = false; this._overPanel.active = true; this._resultLabel.string = this._scoreLabel.string; + this._timeResult.string = this._timeLabe.string; + this._timer = 0; break; } } + + private onMultiBall(active: boolean) { + if (active) this._buffFx.play(); + else this._buffFx.stop(); + } + + private secondsToTime(second: number) { + const h = Math.floor(second / 3600) + .toString() + .padStart(2, '0'), + m = Math.floor((second % 3600) / 60) + .toString() + .padStart(2, '0'), + s = Math.floor(second % 60) + .toString() + .padStart(2, '0'); + + return h + ':' + m + ':' + s; + } }