Browse Source

子弹自动结束

zhoupeng 1 năm trước cách đây
mục cha
commit
f4fbdca121

+ 0 - 13
airPlay/assets/Script/Collide.meta

@@ -1,13 +0,0 @@
-{
-  "ver": "1.1.3",
-  "uuid": "4024172c-00a6-4a1a-b429-83427629b13d",
-  "importer": "folder",
-  "isBundle": false,
-  "bundleName": "",
-  "priority": 1,
-  "compressionType": {},
-  "optimizeHotUpdate": {},
-  "inlineSpriteFrames": {},
-  "isRemoteBundle": {},
-  "subMetas": {}
-}

+ 37 - 0
airPlay/assets/Script/game/nest/barrage.ts

@@ -7,6 +7,7 @@ import monsterbullet from "../monster/monsterbullet";
 import bullet from "../player/bullet";
 import { ResMgr } from "../res/resMgr";
 import { ResRelease } from "../res/resRelease";
+import DelayStop from "../update/delayStop";
 import { GameSysLogic } from "../update/gameSysLogic";
 import Move from "../update/move";
 import MoveTime from "../update/moveTime";
@@ -110,6 +111,15 @@ export class Barrage extends GameSysLogic{
         moveCpt.speed = Utils.intDefault(bulletData.data.speed, 500);
         let localPos = this.layer.convertToNodeSpaceAR(worldPos);
         bulletNode.setPosition(localPos);
+
+        let endJson = Utils.strToJson(bulletData.data.end);
+        if(endJson[0]== 2) {
+            let delayCpt = bulletNode.addComponent(DelayStop)
+            delayCpt.time = endJson[1] / 100;
+            delayCpt.call = ()=>{
+                bulletNode.destroy();
+            }
+        }
     }
 
     // 直线
@@ -153,6 +163,15 @@ export class Barrage extends GameSysLogic{
             moveCpt.speed = Utils.intDefault(bulletData.data.speed, 500);
             let localPos = this.layer.convertToNodeSpaceAR(worldPos);
             bulletNode.setPosition(localPos);
+
+            let endJson = Utils.strToJson(bulletData.data.end);
+            if(endJson[0]== 2) {
+                let delayCpt = bulletNode.addComponent(DelayStop)
+                delayCpt.time = endJson[1] / 100;
+                delayCpt.call = ()=>{
+                    bulletNode.destroy();
+                }
+            }
         }
     }
 
@@ -213,6 +232,15 @@ export class Barrage extends GameSysLogic{
         }
         let localPos = this.layer.convertToNodeSpaceAR(worldPos);
         bulletNode.setPosition(localPos);
+
+        let endJson = Utils.strToJson(bulletData.data.end);
+        if(endJson[0]== 2) {
+            let delayCpt = bulletNode.addComponent(DelayStop)
+            delayCpt.time = endJson[1] / 100;
+            delayCpt.call = ()=>{
+                bulletNode.destroy();
+            }
+        }
     }
 
     // 直线炸开
@@ -300,6 +328,15 @@ export class Barrage extends GameSysLogic{
             bulletNode.addComponent(ResRelease).call = function(){
                 isOver();
             }
+
+            let endJson = Utils.strToJson(bulletData.data.end);
+            if(endJson[0]== 2) {
+                let delayCpt = bulletNode.addComponent(DelayStop)
+                delayCpt.time = endJson[1] / 100;
+                delayCpt.call = ()=>{
+                    bulletNode.destroy();
+                }
+            }
         }
     }
 

+ 15 - 0
airPlay/assets/Script/game/update/delayStop.ts

@@ -0,0 +1,15 @@
+import { GameLogic } from "./GameLogic";
+
+const {ccclass, property} = cc._decorator;
+
+@ccclass
+export default class DelayStop extends GameLogic {
+    time = 10;
+    call: Function;
+    protected gameUpdate(dt: number): void {
+        this.time -= dt;
+        if(this.time <= 0 ){
+            this.call && this.call();
+        }
+    }
+}

+ 10 - 0
airPlay/assets/Script/game/update/delayStop.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "79ff0fe5-ed84-453a-ba4b-8a9100ffc2c5",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}