diff --git a/assets/Game.fire b/assets/Game.fire index eb04d90..65e3191 100644 --- a/assets/Game.fire +++ b/assets/Game.fire @@ -162,7 +162,7 @@ "__type__": "cc.Vec3", "x": 0, "y": 0, - "z": 539.5338265577053 + "z": 780.2888888097792 }, "_scale": { "__type__": "cc.Vec3", @@ -1320,13 +1320,13 @@ }, "_enabled": true, "alienship1": { - "__uuid__": "26432aa1-71c9-45a0-bd88-35e669d6d66b" + "__uuid__": "cc9c71b8-6dce-463b-a0a8-99baebb6aa72" }, "alienship2": { - "__uuid__": "3d6dff29-ac6e-4b8b-8506-3f1ed9083ffc" + "__uuid__": "2a44b465-8729-484a-b0d5-8028192c3600" }, "alienship3": { - "__uuid__": "02d85ab4-7c96-4a14-9cd8-5e02c91ac383" + "__uuid__": "022c2978-0c9b-442a-89ef-f4df3dd70646" }, "_id": "77Y3BgqzhPzpdYEPdwxYS3" }, diff --git a/assets/Prefabs/alienship3.prefab b/assets/Prefabs/alienship3.prefab index 30f2726..01f1974 100644 --- a/assets/Prefabs/alienship3.prefab +++ b/assets/Prefabs/alienship3.prefab @@ -18,7 +18,7 @@ "_parent": null, "_children": [], "_active": true, - "_level": 1, + "_level": 2, "_components": [ { "__id__": 2 @@ -121,6 +121,12 @@ "yellowBullet": { "__uuid__": "1e6b2ed9-fc9b-4d1a-8f2a-7773b0428ecb" }, + "rocket": { + "__uuid__": "941946c0-687a-41ee-ba1f-ff4993adeacd" + }, + "health": { + "__uuid__": "afab2f55-c2a7-4b21-9a71-f4d566ff70bc" + }, "_id": "" }, { @@ -733,7 +739,7 @@ "asset": { "__id__": 0 }, - "fileId": "93DZ+g/9FEeKshIA/tJS3m", + "fileId": "c9zFlVfU9Pr7HzSY8BJeaQ", "sync": false } ] \ No newline at end of file diff --git a/assets/Prefabs/alienship3.prefab.meta b/assets/Prefabs/alienship3.prefab.meta index e677786..fa35220 100644 --- a/assets/Prefabs/alienship3.prefab.meta +++ b/assets/Prefabs/alienship3.prefab.meta @@ -1,6 +1,6 @@ { "ver": "1.2.1", - "uuid": "26432aa1-71c9-45a0-bd88-35e669d6d66b", + "uuid": "cc9c71b8-6dce-463b-a0a8-99baebb6aa72", "optimizationPolicy": "AUTO", "asyncLoadAssets": false, "readonly": false, diff --git a/assets/Prefabs/alienship4.prefab b/assets/Prefabs/alienship4.prefab index 2d29360..07a9de6 100644 --- a/assets/Prefabs/alienship4.prefab +++ b/assets/Prefabs/alienship4.prefab @@ -18,7 +18,7 @@ "_parent": null, "_children": [], "_active": true, - "_level": 1, + "_level": 2, "_components": [ { "__id__": 2 @@ -121,6 +121,12 @@ "yellowBullet": { "__uuid__": "1e6b2ed9-fc9b-4d1a-8f2a-7773b0428ecb" }, + "rocket": { + "__uuid__": "941946c0-687a-41ee-ba1f-ff4993adeacd" + }, + "health": { + "__uuid__": "afab2f55-c2a7-4b21-9a71-f4d566ff70bc" + }, "_id": "" }, { @@ -1098,7 +1104,7 @@ "asset": { "__id__": 0 }, - "fileId": "2ek+AbmdVAUYR1SE39v44O", + "fileId": "f9f/isXgZHr78pxJAgRYe9", "sync": false } ] \ No newline at end of file diff --git a/assets/Prefabs/alienship4.prefab.meta b/assets/Prefabs/alienship4.prefab.meta index e7c9804..38131bb 100644 --- a/assets/Prefabs/alienship4.prefab.meta +++ b/assets/Prefabs/alienship4.prefab.meta @@ -1,6 +1,6 @@ { "ver": "1.2.1", - "uuid": "3d6dff29-ac6e-4b8b-8506-3f1ed9083ffc", + "uuid": "2a44b465-8729-484a-b0d5-8028192c3600", "optimizationPolicy": "AUTO", "asyncLoadAssets": false, "readonly": false, diff --git a/assets/Prefabs/alienship5.prefab b/assets/Prefabs/alienship5.prefab index be18b5b..4afbbba 100644 --- a/assets/Prefabs/alienship5.prefab +++ b/assets/Prefabs/alienship5.prefab @@ -18,7 +18,7 @@ "_parent": null, "_children": [], "_active": true, - "_level": 1, + "_level": 2, "_components": [ { "__id__": 2 @@ -121,6 +121,12 @@ "yellowBullet": { "__uuid__": "1e6b2ed9-fc9b-4d1a-8f2a-7773b0428ecb" }, + "rocket": { + "__uuid__": "941946c0-687a-41ee-ba1f-ff4993adeacd" + }, + "health": { + "__uuid__": "afab2f55-c2a7-4b21-9a71-f4d566ff70bc" + }, "_id": "" }, { @@ -1133,7 +1139,7 @@ "asset": { "__id__": 0 }, - "fileId": "6en9Mka0pKSKby4zJcoJBv", + "fileId": "53aBGR+eRGY7mE48Fc6Wgn", "sync": false } ] \ No newline at end of file diff --git a/assets/Prefabs/alienship5.prefab.meta b/assets/Prefabs/alienship5.prefab.meta index 3a17911..19d70cb 100644 --- a/assets/Prefabs/alienship5.prefab.meta +++ b/assets/Prefabs/alienship5.prefab.meta @@ -1,6 +1,6 @@ { "ver": "1.2.1", - "uuid": "02d85ab4-7c96-4a14-9cd8-5e02c91ac383", + "uuid": "022c2978-0c9b-442a-89ef-f4df3dd70646", "optimizationPolicy": "AUTO", "asyncLoadAssets": false, "readonly": false, diff --git a/assets/Prefabs/health.prefab b/assets/Prefabs/health.prefab new file mode 100644 index 0000000..a8212f9 --- /dev/null +++ b/assets/Prefabs/health.prefab @@ -0,0 +1,259 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "health", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 48, + "height": 28 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_position": { + "__type__": "cc.Vec3", + "x": -158.356, + "y": 27.383, + "z": 0 + }, + "_scale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 0.6, + "z": 1 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 4, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "3f307ec9-399d-4075-842b-f3a3c22bee25" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -12, + "y": 14 + }, + { + "__type__": "cc.Vec2", + "x": -15, + "y": 9 + }, + { + "__type__": "cc.Vec2", + "x": -18, + "y": 9 + }, + { + "__type__": "cc.Vec2", + "x": -21, + "y": 6 + }, + { + "__type__": "cc.Vec2", + "x": -21, + "y": 4 + }, + { + "__type__": "cc.Vec2", + "x": -24, + "y": 3 + }, + { + "__type__": "cc.Vec2", + "x": -24, + "y": -3 + }, + { + "__type__": "cc.Vec2", + "x": -22, + "y": -3 + }, + { + "__type__": "cc.Vec2", + "x": -17, + "y": -9 + }, + { + "__type__": "cc.Vec2", + "x": -14, + "y": -9 + }, + { + "__type__": "cc.Vec2", + "x": -14, + "y": -12 + }, + { + "__type__": "cc.Vec2", + "x": -12, + "y": -14 + }, + { + "__type__": "cc.Vec2", + "x": 13, + "y": -14 + }, + { + "__type__": "cc.Vec2", + "x": 16, + "y": -11 + }, + { + "__type__": "cc.Vec2", + "x": 16, + "y": -9 + }, + { + "__type__": "cc.Vec2", + "x": 19, + "y": -9 + }, + { + "__type__": "cc.Vec2", + "x": 24, + "y": -4 + }, + { + "__type__": "cc.Vec2", + "x": 24, + "y": 4 + }, + { + "__type__": "cc.Vec2", + "x": 20, + "y": 8 + }, + { + "__type__": "cc.Vec2", + "x": 16, + "y": 8 + }, + { + "__type__": "cc.Vec2", + "x": 16, + "y": 11 + }, + { + "__type__": "cc.Vec2", + "x": 13, + "y": 14 + } + ], + "_id": "" + }, + { + "__type__": "4cc23PKJspLG7P/IBljP2/H", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6dVfqDhfNIdKWl08hFRkvL", + "sync": false + } +] \ No newline at end of file diff --git a/assets/Prefabs/health.prefab.meta b/assets/Prefabs/health.prefab.meta new file mode 100644 index 0000000..fe081c5 --- /dev/null +++ b/assets/Prefabs/health.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.1", + "uuid": "afab2f55-c2a7-4b21-9a71-f4d566ff70bc", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Prefabs/rocket.prefab b/assets/Prefabs/rocket.prefab new file mode 100644 index 0000000..5e20b4d --- /dev/null +++ b/assets/Prefabs/rocket.prefab @@ -0,0 +1,264 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "rocket", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 47, + "height": 29 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_position": { + "__type__": "cc.Vec3", + "x": 14.357, + "y": 21.601, + "z": 0 + }, + "_scale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 0.6, + "z": 1 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 5, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "4c53dcbf-af4f-4475-9922-6cfdbcfbd7e4" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -11.5, + "y": 14.5 + }, + { + "__type__": "cc.Vec2", + "x": -12.5, + "y": 12.5 + }, + { + "__type__": "cc.Vec2", + "x": -14.5, + "y": 12.5 + }, + { + "__type__": "cc.Vec2", + "x": -15.5, + "y": 7.5 + }, + { + "__type__": "cc.Vec2", + "x": -19.5, + "y": 7.5 + }, + { + "__type__": "cc.Vec2", + "x": -20.5, + "y": 4.5 + }, + { + "__type__": "cc.Vec2", + "x": -23.5, + "y": 2.5 + }, + { + "__type__": "cc.Vec2", + "x": -23.5, + "y": -3.5 + }, + { + "__type__": "cc.Vec2", + "x": -20.5, + "y": -5.5 + }, + { + "__type__": "cc.Vec2", + "x": -20.5, + "y": -7.5 + }, + { + "__type__": "cc.Vec2", + "x": -15.5, + "y": -9.5 + }, + { + "__type__": "cc.Vec2", + "x": -14.5, + "y": -13.5 + }, + { + "__type__": "cc.Vec2", + "x": 12.5, + "y": -14.5 + }, + { + "__type__": "cc.Vec2", + "x": 15.5, + "y": -11.5 + }, + { + "__type__": "cc.Vec2", + "x": 15.5, + "y": -9.5 + }, + { + "__type__": "cc.Vec2", + "x": 17.5, + "y": -9.5 + }, + { + "__type__": "cc.Vec2", + "x": 23.5, + "y": -3.5 + }, + { + "__type__": "cc.Vec2", + "x": 23.5, + "y": 2.5 + }, + { + "__type__": "cc.Vec2", + "x": 19.5, + "y": 5.5 + }, + { + "__type__": "cc.Vec2", + "x": 19.5, + "y": 7.5 + }, + { + "__type__": "cc.Vec2", + "x": 15.5, + "y": 7.5 + }, + { + "__type__": "cc.Vec2", + "x": 15.5, + "y": 10.5 + }, + { + "__type__": "cc.Vec2", + "x": 11.5, + "y": 14.5 + } + ], + "_id": "" + }, + { + "__type__": "4cc23PKJspLG7P/IBljP2/H", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "89l6vGXMxG6ZmqMkvQt1+Q", + "sync": false + } +] \ No newline at end of file diff --git a/assets/Prefabs/rocket.prefab.meta b/assets/Prefabs/rocket.prefab.meta new file mode 100644 index 0000000..3d1a9a6 --- /dev/null +++ b/assets/Prefabs/rocket.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.1", + "uuid": "941946c0-687a-41ee-ba1f-ff4993adeacd", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scripts/Addon.ts b/assets/Scripts/Addon.ts new file mode 100644 index 0000000..88aa6ca --- /dev/null +++ b/assets/Scripts/Addon.ts @@ -0,0 +1,39 @@ +// Learn TypeScript: +// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html +// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html +// Learn Attribute: +// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html +// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html +// Learn life-cycle callbacks: +// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html +// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html + +const {ccclass, property} = cc._decorator; + +@ccclass +export default class NewClass extends cc.Component { + + setMovements() { + var moveDown = cc.moveBy(2, cc.v2(0, -this.node.parent.getContentSize().height * 0.95)); + + this.node.runAction(cc.repeatForever(moveDown)); + } + + setScale() { + const scaleUp = cc.scaleTo(0.5, 1.25, 1); + const scaleDown = cc.scaleTo(0.5, 1, 1); + const scalePulse = cc.sequence(scaleUp, scaleDown); + this.node.runAction(cc.repeatForever(scalePulse)); + } + + onLoad () { + this.scheduleOnce(this.setMovements, 0.1); + this.scheduleOnce(this.setScale, 0.1); + } + + update (dt) { + if(this.node.position.y <= -(this.node.parent.getContentSize().height)) { + this.node.destroy(); + } + } +} diff --git a/assets/Scripts/Addon.ts.meta b/assets/Scripts/Addon.ts.meta new file mode 100644 index 0000000..0b6e1f6 --- /dev/null +++ b/assets/Scripts/Addon.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "4cc233ca-26ca-4b1b-b3ff-2019633f6fc7", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Scripts/EnemyShip.ts b/assets/Scripts/EnemyShip.ts index ea647df..bd5c57c 100644 --- a/assets/Scripts/EnemyShip.ts +++ b/assets/Scripts/EnemyShip.ts @@ -18,11 +18,18 @@ export default class NewClass extends cc.Component { moveAmountX : number = 0; RTL: boolean = false; + specialItem: string = null; + moveEnemy : cc.ActionInterval; @property(cc.Prefab) yellowBullet: cc.Prefab = null; + @property(cc.Prefab) + rocket: cc.Prefab = null; + @property(cc.Prefab) + health: cc.Prefab = null; + enemyLife: number = GameData.instance.enemyHealth; playAnimation : Boolean = true; @@ -44,7 +51,7 @@ export default class NewClass extends cc.Component { onLoad () { this.scheduleOnce(this.setMovements, 0.1); - this.schedule(this.shootBullets, GameData.instance.enemyShootingInterval, cc.macro.REPEAT_FOREVER, 0); + this.schedule(this.shootBullets, GameData.instance.playerShootingInterval * Math.max(0.25, Math.random()), cc.macro.REPEAT_FOREVER, 0); } onCollisionEnter(otherCollider, selfCollider) { if(otherCollider.name === 'greenbullet') { @@ -64,6 +71,16 @@ export default class NewClass extends cc.Component { removeExplosion() { this.node.destroy(); + if(this.specialItem === 'rocket') { + var rocket = cc.instantiate(this.rocket); + rocket.setPosition(this.node.position.x, this.node.position.y); + this.node.parent.addChild(rocket); + } + if(this.specialItem === 'health') { + var health = cc.instantiate(this.health); + health.setPosition(this.node.position.x, this.node.position.y); + this.node.parent.addChild(health); + } } start () { diff --git a/assets/Scripts/Game.ts b/assets/Scripts/Game.ts index cc14b60..90e343a 100644 --- a/assets/Scripts/Game.ts +++ b/assets/Scripts/Game.ts @@ -41,6 +41,10 @@ export default class NewClass extends cc.Component { const shipXMax = screenHalfWidth - shipMaxMove - margin; const shipX = Math.random() * (shipXMax - shipXMin) + shipXMin; + const randomNumber = Math.ceil(Math.random() * 10); + const specialItem = randomNumber%2 === 0 ? null : randomNumber%3 === 0 ? 'health' : 'rocket'; + const specialItemIndex = Math.floor(Math.random() * GameData.instance.enemySpawnInterval); + for (let i = 0; i < GameData.instance.enemySpawnInterval; i++) { this.scheduleOnce(() => { const ship = cc.instantiate(shipPrefab); @@ -50,6 +54,11 @@ export default class NewClass extends cc.Component { const shipScript = ship.getComponent('EnemyShip'); shipScript.moveAmountX = batchMoveAmountX; shipScript.RTL = RTL; + + if(i === specialItemIndex && specialItem !== null) { + shipScript.specialItem = specialItem; + } + }, i * GameData.instance.enemyMoveTime * 0.25); } } @@ -60,7 +69,7 @@ export default class NewClass extends cc.Component { } start () { - this.schedule(this.spawnShips, 5, cc.macro.REPEAT_FOREVER, 1); + this.schedule(this.spawnShips, GameData.instance.selectedLevel * 3, cc.macro.REPEAT_FOREVER, 1); } // update (dt) {} diff --git a/assets/Scripts/GameData.ts b/assets/Scripts/GameData.ts index 921f6c0..799b3fe 100644 --- a/assets/Scripts/GameData.ts +++ b/assets/Scripts/GameData.ts @@ -24,41 +24,26 @@ export default class GameData extends cc.Component { return this._instance; } - // 🔹 Shooting speed (seconds per shot) - public get enemyShootingInterval(): number { - switch (this.selectedLevel) { - case 1: return 8; - case 2: return 6; - case 3: return 4; - case 4: return 2; - default: return 8; - } - } - - // 🔹 Enemy spawn interval (seconds) - public get enemySpawnInterval(): number { - switch (this.selectedLevel) { - case 1: return 6; - case 2: return 8; - case 3: return 10; - case 4: return 12; - default: return 6; - } - } - - // 🔹 Player speed - public get enemyMoveTime(): number { - switch (this.selectedLevel) { - case 1: return 3; - case 2: return 4; - case 3: return 5; - case 4: return 6; - default: return 3; - } - } - - // 🔹 Any other level-based settings... public get enemyHealth(): number { return this.selectedLevel; } + + private levelConfig = { + 1: { shootingSpeed: 8, spawnInterval: 6, playerSpeed: 3 }, + 2: { shootingSpeed: 6, spawnInterval: 8, playerSpeed: 4 }, + 3: { shootingSpeed: 4, spawnInterval: 10, playerSpeed: 5 }, + 4: { shootingSpeed: 2, spawnInterval: 12, playerSpeed: 6 }, + }; + + public get playerShootingInterval(): number { + return this.levelConfig[this.selectedLevel].shootingSpeed; + } + + public get enemySpawnInterval(): number { + return this.levelConfig[this.selectedLevel].spawnInterval; + } + + public get enemyMoveTime(): number { + return this.levelConfig[this.selectedLevel].playerSpeed; + } } diff --git a/assets/Scripts/MoveJet.ts b/assets/Scripts/MoveJet.ts index 872e5da..c467edc 100644 --- a/assets/Scripts/MoveJet.ts +++ b/assets/Scripts/MoveJet.ts @@ -15,6 +15,7 @@ export default class NewClass extends cc.Component { private isDragging: boolean = false; private touchOffset: cc.Vec2 = cc.v2(0, 0); + private shootingInterval: number = 1; @property(cc.Prefab) greenBullet: cc.Prefab = null; @@ -30,13 +31,39 @@ export default class NewClass extends cc.Component { cc.director.loadScene('Menu'); } } + else if(otherCollider.name === 'health') { + this.playerLifes = 5; + otherCollider.node.destroy(); + } + else if(otherCollider.name === 'rocket') { + this.shootingInterval = Math.min(this.shootingInterval + 1, 3); + otherCollider.node.destroy(); + } } - shootBullets() { + + spawnBullet(offsetX: number, offsetY: number) { var bullet = cc.instantiate(this.greenBullet); - bullet.setPosition(this.node.position.x, this.node.position.y + 40); + bullet.setPosition(this.node.position.x + offsetX, this.node.position.y + offsetY); this.node.parent.addChild(bullet); } + shootBullets() { + switch (this.shootingInterval) { + case 1: + this.spawnBullet(0, 40); + break; + case 2: + this.spawnBullet(-30, 20); + this.spawnBullet(30, 20); + break; + case 3: + this.spawnBullet(0, 40); + this.spawnBullet(-30, 20); + this.spawnBullet(30, 20); + break; + } + } + onLoad() { // Enable touch on this node directly this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this); diff --git a/assets/addons.meta b/assets/addons.meta new file mode 100644 index 0000000..1592e93 --- /dev/null +++ b/assets/addons.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "f2df831b-59ae-48ef-bf79-c73b646914e6", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/assets/addons/Powerup_Health_png_processed.png b/assets/addons/Powerup_Health_png_processed.png new file mode 100644 index 0000000..578f1ca Binary files /dev/null and b/assets/addons/Powerup_Health_png_processed.png differ diff --git a/assets/addons/Powerup_Health_png_processed.png.meta b/assets/addons/Powerup_Health_png_processed.png.meta new file mode 100644 index 0000000..aae6cec --- /dev/null +++ b/assets/addons/Powerup_Health_png_processed.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "47576a33-93e4-4363-aec1-dc94f4735c2c", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Powerup_Health_png_processed": { + "ver": "1.0.4", + "uuid": "3f307ec9-399d-4075-842b-f3a3c22bee25", + "rawTextureUuid": "47576a33-93e4-4363-aec1-dc94f4735c2c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": -0.5, + "trimX": 0, + "trimY": 1, + "width": 48, + "height": 28, + "rawWidth": 48, + "rawHeight": 29, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/assets/addons/Powerup_Rockets_png_processed.png b/assets/addons/Powerup_Rockets_png_processed.png new file mode 100644 index 0000000..19ee0ca Binary files /dev/null and b/assets/addons/Powerup_Rockets_png_processed.png differ diff --git a/assets/addons/Powerup_Rockets_png_processed.png.meta b/assets/addons/Powerup_Rockets_png_processed.png.meta new file mode 100644 index 0000000..e9a8053 --- /dev/null +++ b/assets/addons/Powerup_Rockets_png_processed.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "b86733b4-4748-4f4a-ba68-b3cbb69bb3bb", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Powerup_Rockets_png_processed": { + "ver": "1.0.4", + "uuid": "4c53dcbf-af4f-4475-9922-6cfdbcfbd7e4", + "rawTextureUuid": "b86733b4-4748-4f4a-ba68-b3cbb69bb3bb", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 47, + "height": 29, + "rawWidth": 47, + "rawHeight": 29, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/settings/project.json b/settings/project.json index f319bb8..77281bf 100644 --- a/settings/project.json +++ b/settings/project.json @@ -22,12 +22,22 @@ true, false, true, + false, + true, + true + ], + [ + false, + false, + false, + true, false ], [ false, false, false, + true, false, false ] @@ -52,7 +62,8 @@ "greenBullet", "BadGuy", "player", - "New Group 6" + "ammo", + "rocket" ], "last-module-event-record-time": 1761549490300, "simulator-orientation": false, @@ -61,6 +72,5 @@ "width": 960 }, "use-customize-simulator": true, - "use-project-simulator-setting": false, - "start-scene": "current" + "use-project-simulator-setting": false } \ No newline at end of file