zhoupeng 1 rok temu
rodzic
commit
40e2e91083

+ 2 - 13
airPlay/assets/Script/Start.ts

@@ -6,6 +6,7 @@ import { UILayerNames, UILayers } from "./Core/Ui/UILayers";
 import { UIMgr } from "./Core/Ui/UIMgr";
 import bullet from "./game/bullet";
 import { ConfigMgr } from "./game/cfg/configMgr";
+import { Barrage } from "./game/nest/barrage";
 import { LevelMgr } from "./levelMgr";
 
 const {ccclass, property} = cc._decorator;
@@ -62,7 +63,7 @@ export default class Start extends cc.Component {
         LevelMgr.inst.begin();
 
         // this.testUI();
-
+        Barrage.inst.parent = this.$bulletLayer_node;
         UIMgr.inst.showUI(UIList.debug);
     }
 
@@ -74,16 +75,4 @@ export default class Start extends cc.Component {
             UIMgr.inst.hideUI(UIList.loading);
         }, 10000);
     }
-
-    createPlayerBullet(pos: cc.Vec2){
-        let bulletNode = cc.instantiate(this.bulletPrefab)
-        let bulletCpt = bulletNode.getComponent(bullet);
-        let moveCpt = bulletCpt.getMoveCpt();
-        moveCpt.dirction = cc.v2(0,1);
-        moveCpt.speed = 1000;
-
-        this.$bulletLayer_node.addChild(bulletNode);
-        bulletNode.setPosition(pos);
-    }
-
 }

+ 4 - 11
airPlay/assets/Script/game/bullet.ts

@@ -1,7 +1,7 @@
 
 import { LQCollide } from "../../Script/Collide/lq_collide_system/lq_collide";
 import { LQCollideInfoList } from "../../Script/Collide/lq_collide_system/lq_collide_config";
-import move from "./update/move";
+import Move from "./update/move";
 
 
 const {ccclass, property} = cc._decorator;
@@ -20,7 +20,6 @@ export default class bullet extends LQCollide {
 
 	/*===========================自动生成按钮事件结束==========================*/
 
-    moveCpt: move = null;
     protected onLoad(): void {
         this.$dragon_bone.playAnimation('appear', 1);
         this.$dragon_bone.addEventListener('complete', ()=>{
@@ -37,14 +36,8 @@ export default class bullet extends LQCollide {
         }
     }
 
-    getMoveCpt(): move{
-        if(!this.moveCpt) {
-            this.moveCpt = this.node.getComponent(move);
-            if(!this.moveCpt) {
-                this.moveCpt = this.node.addComponent(move);
-            }
-        }
-
-        return this.moveCpt;
+    setDirction(dir: cc.Vec2){
+        let angle = cc.v2(0,1).signAngle(dir) / Math.PI * 180;
+        this.node.angle = angle;
     }
 }

+ 18 - 0
airPlay/assets/Script/game/common/utils.ts

@@ -18,4 +18,22 @@ export namespace Utils {
         if(data == '') return 0;
         return Number(data);
     }
+
+    // 角度转弧度
+    export function radian(degree: number){
+        return degree * (Math.PI/180);
+    }
+
+    export function degree(radian: number){
+        return radian * (180/Math.PI);
+    }
+
+
+    export function getCpt<T extends cc.Component>(cpt: {new(): T}, node: cc.Node): T{
+        let moveCpt = node.getComponent(cpt);
+        if(!moveCpt) {
+            moveCpt = node.addComponent(cpt);
+        }
+        return moveCpt;
+    }
 }

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

@@ -0,0 +1,134 @@
+import bullet from "../bullet";
+import { Utils } from "../common/utils";
+import { ResMgr } from "../res/resMgr";
+import { ResRelease } from "../res/resRelease";
+import { GameSysLogic } from "../update/gameSysLogic";
+import Move from "../update/move";
+import MoveTime from "../update/moveTime";
+
+/**
+ * 1 扇形弹幕: 开始角度(相对于向上), 角度,数量
+ * 2 旋转飞行:  半径
+ * 3 直线:  开始角度
+ * 4 直线后炸开: 时间,开始角度,数量
+ */
+export class Barrage extends GameSysLogic{
+    parent: cc.Node;
+
+    private static _inst: Barrage;
+    public static get inst(): Barrage {
+        if (this._inst == null) {
+            this._inst = new Barrage();
+        }
+        return this._inst;
+    }
+    // 直线
+    async createPlayerBullet2(worldPos: cc.Vec2){
+        let bulletNode = await ResMgr.inst.loadPrefab('monster/bullet', this.parent);
+        let moveCpt = Utils.getCpt(Move, bulletNode);
+        moveCpt.dirction = cc.v2(0,1);
+        moveCpt.speed = 1000;
+        let localPos = this.parent.convertToNodeSpaceAR(worldPos);
+        bulletNode.setPosition(localPos);
+    }
+
+    async createPlayerBullet(worldPos: cc.Vec2){
+        this.createPlayerBullet4(worldPos);
+    }
+
+    // 扇形弹幕
+    async createPlayerBullet1(worldPos: cc.Vec2){
+        let num = 9;
+        let angle = 60;
+        let leftVec2 = cc.v2(0,1).rotateSelf(Utils.radian(angle/2));
+        let prefab = await ResMgr.inst.getPrefab('monster/bullet');
+
+        for (let index = 0; index < num; index++) {
+            let bulletNode = ResMgr.inst.createNode(prefab, this.parent)
+            let bulletCpt = bulletNode.getComponent(bullet);
+            let moveCpt = Utils.getCpt(Move, bulletNode);
+
+            moveCpt.dirction = leftVec2.rotate(Utils.radian(-angle / (num-1) * index));
+            moveCpt.speed = 1000;
+            bulletCpt.setDirction(moveCpt.dirction);
+            let localPos = this.parent.convertToNodeSpaceAR(worldPos);
+            bulletNode.setPosition(localPos);
+        }
+    }
+
+    async createPlayerBullet3(worldPos: cc.Vec2){
+        let time = 1;
+
+        let prefab = await ResMgr.inst.getPrefab('monster/bullet');
+        let bulletNode = ResMgr.inst.createNode(prefab, this.parent)
+
+        let moveCpt = Utils.getCpt(MoveTime, bulletNode);
+        moveCpt.dirction = cc.v2(0,1);
+        moveCpt.speed = 500;
+        moveCpt.overTime =  time;
+
+        moveCpt.call = ()=>{
+            bulletNode.destroy();
+            let num = 4;
+            let angle = 360;
+            let leftVec2 = cc.v2(1,1).normalize();
+    
+            for (let index = 0; index < num; index++) {
+                let bulletNode = ResMgr.inst.createNode(prefab, this.parent)
+                let bulletCpt = bulletNode.getComponent(bullet);
+                let moveCpt = Utils.getCpt(Move, bulletNode);
+    
+                moveCpt.dirction = leftVec2.rotate(Utils.radian(-angle / (num) * index));
+                moveCpt.speed = 500;
+                bulletCpt.setDirction(moveCpt.dirction);
+                bulletNode.setPosition(bulletNode.getPosition());
+            }
+        }
+        let localPos = this.parent.convertToNodeSpaceAR(worldPos);
+        bulletNode.setPosition(localPos);
+    }
+
+    async createPlayerBullet4(worldPos: cc.Vec2){
+        let num = 8;
+        let r = 40;
+        let leftVec2 = cc.v2(0,1)
+        let angle = 360;
+        let prefab = await ResMgr.inst.getPrefab('monster/bullet');
+
+        let node = new cc.Node('cricleBullet');
+        this.parent.addChild(node);
+
+        let moveCpt = Utils.getCpt(Move, node);
+        moveCpt.dirction = cc.v2(0,1);
+        moveCpt.speed = 500;
+        let localPos = this.parent.convertToNodeSpaceAR(worldPos);
+        node.setPosition(localPos);
+
+        let t = cc.tween(node).by(1, {angle: 360}).repeatForever().start();
+
+        let isOver = ()=>{ 
+            if(cc.isValid(node, true)){
+                if(node.childrenCount <= 0){
+                    t.stop();
+                    node.destroy();
+                }
+            }
+        }
+
+        for (let index = 0; index < num; index++) {
+            let bulletNode = ResMgr.inst.createNode(prefab, node)
+            let bulletCpt = bulletNode.getComponent(bullet);
+
+            let dirction = leftVec2.rotate(Utils.radian(-angle / (num) * index));
+            bulletNode.setPosition(dirction.mul(r));
+            bulletCpt.setDirction(dirction.rotate(Utils.radian(90)));
+
+
+            bulletNode.addComponent(ResRelease).call = function(){
+                setTimeout(() => {
+                    isOver();
+                }, 100);
+            }
+        }
+    }
+}

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

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "d732ccaf-6aeb-44c7-8b1e-21a6d2fb1fec",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 6 - 6
airPlay/assets/Script/game/nest/nestPlay.ts

@@ -77,12 +77,12 @@ export class NestPlay extends cc.Component {
     }
 
     createMonster(){
-        if(this.aniClip.length == 1) {
-            this.createMonster2();
-        }
-        else{
-            this.createMonster2();
-        }
+        this.createMonster2();
+        // if(this.aniClip.length == 1) {
+        // }
+        // else{
+        //     this.createMonster2();
+        // }
     }
 
     createMonster2(){

+ 3 - 3
airPlay/assets/Script/game/player.ts

@@ -1,6 +1,7 @@
 import { EventMgr } from "../Core/Base/EventMgr";
 import Start from "../Start";
 import { Touch_Start, Touch_Move, Touch_End } from "./eventDef";
+import { Barrage } from "./nest/barrage";
 
 import { GameLogic } from "./update/GameLogic";
 import MoveDest from "./update/moveDest";
@@ -26,7 +27,7 @@ export default class player extends GameLogic {
     // moveCpt: move = null;
     moveCpt: MoveDest = null;
     // dirction: cc.Vec2 = cc.v2(0,1);
-    bulletCD:number = 0.1;
+    bulletCD:number = 0.2;
     bulletCDTime: number = 0;
 
     airStartPos: cc.Vec2;
@@ -71,8 +72,7 @@ export default class player extends GameLogic {
         this.bulletCDTime -= dt;
         if(this.bulletCDTime <= 0){
             this.bulletCDTime = this.bulletCD;
-
-            player.PlayerAttack && Start.inst.createPlayerBullet(this.node.getPosition());
+            player.PlayerAttack && Barrage.inst.createPlayerBullet(this.node.convertToWorldSpaceAR(cc.Vec2.ZERO));
         }
     }
 

+ 19 - 0
airPlay/assets/Script/game/update/gameSysLogic.ts

@@ -0,0 +1,19 @@
+import { GameLogicMgr } from "./logic";
+
+export class GameSysLogic {
+    static _baseId = 0;
+
+    logicId = 0;
+    constructor(){
+        GameSysLogic._baseId++;
+        this.logicId = GameSysLogic._baseId;
+        GameLogicMgr.inst.addSysLogic(this);
+    }
+
+    end(){
+        GameLogicMgr.inst.removeSysLogic(this);
+    }
+
+    protected update(dt){}
+    protected updateSec(dt){}
+}

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

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "3c558fc5-66a1-4850-82e4-735259206b41",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 34 - 1
airPlay/assets/Script/game/update/logic.ts

@@ -1,8 +1,8 @@
+import { GameSysLogic } from "./gameSysLogic";
 
 
 
 export class GameLogicMgr {
-
     private static _inst: GameLogicMgr;
     public static get inst(): GameLogicMgr {
         if (this._inst == null) {
@@ -14,6 +14,8 @@ export class GameLogicMgr {
 
     isGamePause: boolean = false;
 
+    sysLogics: Map<number, GameSysLogic> = new Map();
+
     switch(){
         this.isGamePause = !this.isGamePause;
         //@ts-ignore
@@ -31,6 +33,37 @@ export class GameLogicMgr {
                 aniMgr._oldUpdate(dt);
             }
         }
+
+        cc.director.getScheduler().enableForTarget(this);
+        cc.director.getScheduler().schedule(this.update, this, 0, cc.macro.REPEAT_FOREVER, 0, false);
+        cc.director.getScheduler().schedule(this.updateSec, this, 1, cc.macro.REPEAT_FOREVER, 0, false);
+    }
+
+    update(dt){
+        if (this.isGamePause) return;
+        this.sysLogics.forEach((v)=>{
+            v['update'](dt);
+        });
+    }
+
+    updateSec(dt) {
+        if (this.isGamePause) return;
+        this.sysLogics.forEach((v)=>{
+            v['updateSec'](dt);
+        });
+    }
+
+    end(){
+        cc.director.getScheduler().unschedule(this.update,this);
+        cc.director.getScheduler().unschedule(this.updateSec,this);
+    }
+
+    addSysLogic(logic: GameSysLogic){
+        this.sysLogics.set(logic.logicId, logic);
+    }
+
+    removeSysLogic(logic: GameSysLogic){
+        this.sysLogics.delete(logic.logicId);
     }
 };
 

+ 1 - 1
airPlay/assets/Script/game/update/move.ts

@@ -3,7 +3,7 @@ import { GameLogic } from "./GameLogic";
 const {ccclass, property} = cc._decorator;
 
 @ccclass
-export default class move extends GameLogic {
+export default class Move extends GameLogic {
 
     private _speed: number = 100;
     public get speed(): number {

+ 45 - 0
airPlay/assets/Script/game/update/moveTime.ts

@@ -0,0 +1,45 @@
+import { GameLogic } from "./GameLogic";
+
+const {ccclass, property} = cc._decorator;
+
+@ccclass
+export default class MoveTime extends GameLogic {
+
+    private _speed: number = 100;
+    public get speed(): number {
+        return this._speed;
+    }
+    public set speed(value: number) {
+        this._speed = value;
+    }
+
+    private _dirction: cc.Vec2 = cc.v2(0, 0);
+    public get dirction(): cc.Vec2 {
+        return this._dirction;
+    }
+    public set dirction(value: cc.Vec2) {
+        this._dirction = value;
+    }
+
+    private _overTime: number = 0;
+    public get overTime(): number {
+        return this._overTime;
+    }
+    public set overTime(value: number) {
+        this._overTime = value;
+    }
+
+    startTime = 0;
+    call:Function = null;
+    gameUpdate(dt: number): void {
+        this.node.x += this.speed * dt * this.dirction.x;
+        this.node.y += this.speed * dt * this.dirction.y;
+
+        this.startTime += dt;
+        if(this.startTime >= this._overTime){
+            this.call && this.call();
+            this.destroy();
+        }
+    }
+
+}

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

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "8b0863bd-37dd-4482-a0ca-1a8f15adb174",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 3 - 9
airPlay/assets/Script/levelMgr.ts

@@ -6,6 +6,7 @@ import { Utils } from "./game/common/utils";
 import levelempty from "./game/level/levelempty";
 import { NestPlay } from "./game/nest/nestPlay";
 import { ResMgr } from "./game/res/resMgr";
+import { GameSysLogic } from "./game/update/gameSysLogic";
 
 /**
  * 1 关卡有多个 飞机巢穴
@@ -25,7 +26,7 @@ enum LevelState {
 /**
  * 1 切换关卡
  */
-export class LevelMgr {
+export class LevelMgr extends GameSysLogic {
 
     parent: cc.Node;
     title: cc.Label;
@@ -42,19 +43,12 @@ export class LevelMgr {
     }
 
     init(){
-        cc.director.getScheduler().enableForTarget(this);
-        cc.director.getScheduler().schedule(this.update, this, 1, cc.macro.REPEAT_FOREVER, 0, false);
     }
 
-    update(dt){
+    updateSec(dt){
         if(this.state != LevelState.playing) return;
         if(this.parent.getComponentsInChildren(LQCollide).length > 0) return;
         this.next();
-
-    }
-
-    end(){
-        cc.director.getScheduler().unschedule(this.update,this);
     }
     
     async begin(){

+ 0 - 13
airPlay/assets/game/bullet.meta

@@ -1,13 +0,0 @@
-{
-  "ver": "1.1.3",
-  "uuid": "e4c3feb3-2050-484c-82d5-d7bf39c1ffaf",
-  "importer": "folder",
-  "isBundle": false,
-  "bundleName": "",
-  "priority": 1,
-  "compressionType": {},
-  "optimizeHotUpdate": {},
-  "inlineSpriteFrames": {},
-  "isRemoteBundle": {},
-  "subMetas": {}
-}

+ 0 - 0
airPlay/assets/game/bullet/bullet.prefab → airPlay/assets/resources/monster/bullet.prefab


+ 0 - 0
airPlay/assets/game/bullet/bullet.prefab.meta → airPlay/assets/resources/monster/bullet.prefab.meta


BIN
airPlay/client-editor/excel/弹幕.xls


BIN
airPlay/client-editor/excel/怪物生成点.xls


BIN
airPlay/plugin-resource/excel/关卡.xls


+ 1 - 0
airPlay/plugin-resource/js/GameJsCfg.js

@@ -0,0 +1 @@
+module.exports = {"all":{"1":{"name":"体力上限","value":""},"2":{"name":"自然恢复1体力需要多少秒","value":""},"3":{"name":"表示玩家关卡内战机升级所需经验值","value":""},"4":{"name":"表示玩家关卡内母舰升级所需经验值","value":""},"5":{"name":"玩家战机在战场的初始位置","value":""},"6":{"name":"战机的移动速度,像素/帧","value":""},"7":{"name":"初级母舰道具奖励的ID+美术资源ID+奖励经验","value":""},"8":{"name":"中级母舰道具奖励的ID+美术资源ID+奖励经验","value":""},"9":{"name":"超级母舰道具奖励的ID+美术资源ID+奖励经验","value":""},"10":{"name":"玩家初始战机ID,对应战机表","value":""},"11":{"name":"设置为200,除以100意为爆伤结果是2倍普通伤害值","value":""},"12":{"name":"关卡内道具掉落后下坠速度,像素/帧","value":""},"13":{"name":"boss出场玩家锁血时间,除100,S","value":""},"14":{"name":"boss死亡场面冻结时间,除100,S","value":""}},"smallLevel":{"1":{"nest":"4;5"},"2":{"nest":"1;2"},"3":{"nest":"6;7"},"4":{"nest":"8;9"},"5":{"nest":10}},"nest":{"1":{"pos":"160;0","type":1,"num":1,"time":1,"delay":0,"pattern":2},"2":{"pos":"480;0","type":1,"num":1,"time":0,"delay":0,"pattern":2},"3":{"pos":"320;0","type":1,"num":1,"time":0,"delay":0,"pattern":1},"4":{"pos":"160;0","type":2,"num":1,"time":0,"delay":0,"pattern":3},"5":{"pos":"480;0","type":2,"num":1,"time":0,"delay":0,"pattern":3},"6":{"pos":"0;200","type":3,"num":4,"time":0.2,"delay":0,"pattern":1},"7":{"pos":"640;200","type":4,"num":4,"time":0.2,"delay":0,"pattern":1},"8":{"pos":"-50;900","type":5,"num":4,"time":0.2,"delay":0,"pattern":1},"9":{"pos":"690;900","type":6,"num":4,"time":0.2,"delay":0,"pattern":1},"10":{"pos":"320;0","type":7,"num":1,"time":0,"delay":0,"pattern":4}}};

+ 58 - 0
airPlay/plugin-resource/json/all.json

@@ -0,0 +1,58 @@
+{
+    "1":{
+        "name":"体力上限",
+        "value":""
+    },
+    "2":{
+        "name":"自然恢复1体力需要多少秒",
+        "value":""
+    },
+    "3":{
+        "name":"表示玩家关卡内战机升级所需经验值",
+        "value":""
+    },
+    "4":{
+        "name":"表示玩家关卡内母舰升级所需经验值",
+        "value":""
+    },
+    "5":{
+        "name":"玩家战机在战场的初始位置",
+        "value":""
+    },
+    "6":{
+        "name":"战机的移动速度,像素/帧",
+        "value":""
+    },
+    "7":{
+        "name":"初级母舰道具奖励的ID+美术资源ID+奖励经验",
+        "value":""
+    },
+    "8":{
+        "name":"中级母舰道具奖励的ID+美术资源ID+奖励经验",
+        "value":""
+    },
+    "9":{
+        "name":"超级母舰道具奖励的ID+美术资源ID+奖励经验",
+        "value":""
+    },
+    "10":{
+        "name":"玩家初始战机ID,对应战机表",
+        "value":""
+    },
+    "11":{
+        "name":"设置为200,除以100意为爆伤结果是2倍普通伤害值",
+        "value":""
+    },
+    "12":{
+        "name":"关卡内道具掉落后下坠速度,像素/帧",
+        "value":""
+    },
+    "13":{
+        "name":"boss出场玩家锁血时间,除100,S",
+        "value":""
+    },
+    "14":{
+        "name":"boss死亡场面冻结时间,除100,S",
+        "value":""
+    }
+}

+ 82 - 0
airPlay/plugin-resource/json/nest.json

@@ -0,0 +1,82 @@
+{
+    "1":{
+        "pos":"160;0",
+        "type":1,
+        "num":1,
+        "time":1,
+        "delay":0,
+        "pattern":2
+    },
+    "2":{
+        "pos":"480;0",
+        "type":1,
+        "num":1,
+        "time":0,
+        "delay":0,
+        "pattern":2
+    },
+    "3":{
+        "pos":"320;0",
+        "type":1,
+        "num":1,
+        "time":0,
+        "delay":0,
+        "pattern":1
+    },
+    "4":{
+        "pos":"160;0",
+        "type":2,
+        "num":1,
+        "time":0,
+        "delay":0,
+        "pattern":3
+    },
+    "5":{
+        "pos":"480;0",
+        "type":2,
+        "num":1,
+        "time":0,
+        "delay":0,
+        "pattern":3
+    },
+    "6":{
+        "pos":"0;200",
+        "type":3,
+        "num":4,
+        "time":0.2,
+        "delay":0,
+        "pattern":1
+    },
+    "7":{
+        "pos":"640;200",
+        "type":4,
+        "num":4,
+        "time":0.2,
+        "delay":0,
+        "pattern":1
+    },
+    "8":{
+        "pos":"-50;900",
+        "type":5,
+        "num":4,
+        "time":0.2,
+        "delay":0,
+        "pattern":1
+    },
+    "9":{
+        "pos":"690;900",
+        "type":6,
+        "num":4,
+        "time":0.2,
+        "delay":0,
+        "pattern":1
+    },
+    "10":{
+        "pos":"320;0",
+        "type":7,
+        "num":1,
+        "time":0,
+        "delay":0,
+        "pattern":4
+    }
+}

+ 17 - 0
airPlay/plugin-resource/json/smallLevel.json

@@ -0,0 +1,17 @@
+{
+    "1":{
+        "nest":"4;5"
+    },
+    "2":{
+        "nest":"1;2"
+    },
+    "3":{
+        "nest":"6;7"
+    },
+    "4":{
+        "nest":"8;9"
+    },
+    "5":{
+        "nest":10
+    }
+}

+ 1 - 1
airPlay/settings/builder.json

@@ -15,7 +15,7 @@
   "mainCompressionType": "default",
   "mainIsRemote": false,
   "optimizeHotUpdate": true,
-  "md5Cache": true,
+  "md5Cache": false,
   "nativeMd5Cache": true,
   "encryptJs": true,
   "xxteaKey": "e518ad81-22e7-4d",