소스 검색

2025-05-27 wws 修改下一关和关卡数据

2025-05-27 wws 修改下一关和关卡数据
Kziwws 1 주 전
부모
커밋
1f6f9ee41d

+ 2 - 2
assets/prefabs/ui/gunfightShootUI.prefab

@@ -416,7 +416,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 340,
-      "y": 733.4349999999998,
+      "y": 762.235,
       "z": 0
     },
     "_lrot": {
@@ -557,7 +557,7 @@
     "_target": null,
     "_left": 0,
     "_right": 20,
-    "_top": 47.463400000000206,
+    "_top": 18.663400000000024,
     "_bottom": 0,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,

+ 1 - 15
assets/scripts/data/UserData.ts

@@ -336,24 +336,10 @@ class UserData extends Singleton {
      * 得到当前关卡下的敌人数据
      */
     public getCurLevelData(){
-        const safeIndex = Math.min(this.data.level - 1, this.levelsTable.length - 1);
+        const safeIndex = Math.min(this.data.level - 1, this.levelsTable.length -1);
         return this.levelsTable[safeIndex];
     }
 
-    /**
-     * 下一个关卡
-     */
-    public nextLevel():any{
-        let levels: Array<any> = this.levelsTable;
-        let res:any = levels.filter(e =>{
-            return e.id == this.data.level + 1;
-        });
-        if(res){
-            this.data.level = levels.findIndex(e=>e.id == res.id);
-        }
-        return res;
-    }
-
     /**
      * 保存到缓存中
      */

+ 2 - 0
assets/scripts/game/BuildEnemys.ts

@@ -54,6 +54,7 @@ export class BuildEnemys extends Component {
     public async loadLevelEnemys(){
         if(Game.I.isGameOver 
             || Game.I.isPause)return;
+        this.recycle();
         this.queueEnemys = this.readLevelEnemys();
         this.eTimeMaps.forEach((k,v) => {if(v){clearInterval(v)}});
         this.eTimeMaps.clear();
@@ -239,6 +240,7 @@ export class BuildEnemys extends Component {
         this.allEnemys.forEach(e => {e.recycle(false)});
         this.allEnemys = [];
         this.map.resetData();
+        this.enemyTypeRecords = [];
     }
 
     /**

+ 26 - 10
assets/scripts/game/Game.ts

@@ -9,6 +9,9 @@ import { BuildEnemys } from './BuildEnemys';
 import { autoBind } from '../extend/AutoBind';
 import { BaseExp } from '../core/base/BaseExp';
 import { PoolManager } from '../core/manager/PoolManager';
+import { uiMgr } from '../core/manager/UIManager';
+import { Constants } from '../data/Constants';
+import { Main } from './Main';
 const { ccclass, property } = _decorator;
 
 @ccclass('Game')
@@ -45,35 +48,48 @@ export class Game extends BaseExp {
         this.canvas.active = true;
         this.map_pos.active = true;
         //加载map
-        this.loadMap(userIns.getCurLevelData().map);
+        this.loadMap();
     }
 
     /**
      * 下一关
      */
     public nextLevel(){
-        
+        userIns.data.level += 1;
+        //加载新的map
+        this.loadMap();
+        //刷新新的任务
+        uiMgr.getPageComponent(Constants.mainUIs.main).loadData();
+        this.isGameOver = this.isPause = false;
+        //加载敌人
+        this.buildEnemys.loadLevelEnemys();
     }
 
     /**
      * 重玩
      */
     public restart(){
-        //this.loadMap(userIns.getCurLevelData().map);
+        this.isGameOver = this.isPause = false;
+        //加载敌人
+        this.buildEnemys.loadLevelEnemys();
     }
 
     /**
      * 加载map
      */
-    public loadMap(name: string){
-        if(Utils.isNull(name))return;
-        if(this.map){
-           if(this.map.name === name)return;
-           PoolManager.putNode(this.map.node);
-           this.map = null!;
+    public loadMap(){
+        const name: string = userIns.getCurLevelData().map;
+        if(Utils.isNull(name) 
+            ||(this.map && this.map.name == name)){
+            return;
         }
         Logger.log(`加载地图:${name}`);
         ResUtil.loadRes(`map/${name}`).then((map:Node)=>{
+            //把旧的地图回收
+            if(this.map){
+               PoolManager.putNode(this.map.node);
+               this.map = null!;
+            }
             map.parent = this.map_pos.parent;
             map.worldPosition = this.map_pos.worldPosition;
             this.map = map.getComponent(GMap);
@@ -82,7 +98,7 @@ export class Game extends BaseExp {
             //玩家组建
             this.player = this.map.getComponentInChildren(Player);
             //主角摄像机
-            let cameraNode: Node = Utils.findName(map, 'mainCamera');
+            const cameraNode: Node = Utils.findName(map, 'mainCamera');
             this.camera = cameraNode.getComponent(Camera);
         });
     }

+ 1 - 1
assets/scripts/game/Main.ts

@@ -103,7 +103,7 @@ export class Main extends BaseExp {
      */
     public playBtn(){
         if(Constants.isDebug && !Utils.isNull(this.editBox.string)){
-            userIns.data.level = parseInt(this.editBox.string);
+           userIns.data.level = parseInt(this.editBox.string);
         }
         this.enterAnim.play();
         this.scheduleOnce(() => {

+ 6 - 4
assets/scripts/ui/SettleUI.ts

@@ -180,18 +180,20 @@ export class SettleUI extends BaseExp {
         }else if(btnName ==='back_home_btn'){//返回首页
             uiMgr.pop(Constants.mainUIs.main);
         }else if(btnName ==='next_level_btn'){//下一关
+            const nLevel = ()=>{
+                uiMgr.hide(Constants.popUIs.settleUI,this.param.cb);
+                Game.I.nextLevel();
+            }
             //下一关判断是否触发广告
             let odds:number = Game.I.player.pData.adforceShow2;
             if(Utils.getRandomFloat(0,1) <= odds){
                 PlatformSystem.platform.showRewardVideo((f) => {
                     if(f) {//播放视频成功
-                        uiMgr.hide(Constants.popUIs.settleUI,this.param.cb);
-                        Game.I.nextLevel();
+                       nLevel();
                     }
                 });
             }else{
-                uiMgr.hide(Constants.popUIs.settleUI,this.param.cb);
-                Game.I.nextLevel();
+                nLevel();
             }
         }else if(btnName ==='video_btn'){//看视频双倍奖励
             PlatformSystem.platform.showRewardVideo((f) => {

+ 1 - 1
profiles/v2/packages/reference-image.json

@@ -3,6 +3,6 @@
   "config": {
     "images": [],
     "sceneUUID": {},
-    "scene": "10795865-5525-41fc-8bf7-0e8d6983b214"
+    "scene": "6fdfa45a-54d2-427e-9510-d0cbbbc63997"
   }
 }