Browse Source

增加游戏结束预制体

mojunshou 8 months ago
parent
commit
7b33a973ec

+ 10 - 10
assets/bundle/common/prefab/setting.prefab

@@ -1761,7 +1761,7 @@
         "__id__": 77
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 85
@@ -2142,7 +2142,7 @@
         "__id__": 93
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 101
@@ -2537,7 +2537,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -181.864,
-      "y": -82.317,
+      "y": 24.025,
       "z": 0
     },
     "_lrot": {
@@ -2719,7 +2719,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 73.703,
-      "y": -82.317,
+      "y": 24.025,
       "z": 0
     },
     "_lrot": {
@@ -2914,7 +2914,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -96.103,
-      "y": -84.301,
+      "y": 27.27,
       "z": 0
     },
     "_lrot": {
@@ -3143,7 +3143,7 @@
         "__id__": 133
       }
     ],
-    "_active": false,
+    "_active": true,
     "_components": [
       {
         "__id__": 139
@@ -4198,7 +4198,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 150.815,
-      "y": -84.301,
+      "y": 27.27,
       "z": 0
     },
     "_lrot": {
@@ -6174,7 +6174,7 @@
       "__id__": 19
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 261
@@ -6415,7 +6415,7 @@
       "__id__": 19
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 271
@@ -6656,7 +6656,7 @@
       "__id__": 19
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 281

File diff suppressed because it is too large
+ 1697 - 0
assets/bundle/gui/eliminate/prefab/gameOver.prefab


+ 13 - 0
assets/bundle/gui/eliminate/prefab/gameOver.prefab.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.50",
+  "importer": "prefab",
+  "imported": true,
+  "uuid": "bb303a0f-b259-45d1-9883-fb2f705430cc",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {
+    "syncNodeName": "gameOver"
+  }
+}

+ 7 - 3
assets/script/game/common/config/GameEvent.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: dgflash
  * @Date: 2021-11-23 15:28:39
- * @LastEditors: dgflash
- * @LastEditTime: 2022-01-26 16:42:00
+ * @LastEditors: mojunshou 1637302775@qq.com
+ * @LastEditTime: 2025-03-27 18:31:37
  */
 
 /** 游戏事件 */
@@ -10,5 +10,9 @@ export enum GameEvent {
     /** 游戏服务器连接成功 */
     GameServerConnected = "GameServerConnected",
     /** 登陆成功 */
-    LoginSuccess = "LoginSuccess"
+    LoginSuccess = "LoginSuccess",
+    /**重新开始 */
+    RestartGame = "RestartGame",
+    /**复活 */
+    Resurrection = "Resurrection"
 }

+ 6 - 3
assets/script/game/common/config/GameUIConfig.ts

@@ -1,7 +1,7 @@
 /*
  * @Date: 2021-08-12 09:33:37
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-25 15:22:03
+ * @LastEditTime: 2025-03-27 18:36:48
  */
 import { LayerType, UIConfig } from "../../../../../extensions/oops-plugin-framework/assets/core/gui/layer/LayerManager";
 
@@ -32,7 +32,9 @@ export enum UIID {
     /** 双倍加速 */
     DoubleSpeed,
     /**提现记录 */
-    WithdrawRecord
+    WithdrawRecord,
+    /** 游戏结束 */
+    GameOver
 }
 
 /** 打开界面方式的配置数据 */
@@ -49,5 +51,6 @@ export var UIConfigData: { [key: number]: UIConfig } = {
     [UIID.WechatWithdraw]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/wechatWithdrawal" },
     [UIID.RedPacketWithdraw]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/redPacketWithdrawal" },
     [UIID.DoubleSpeed]: { layer: LayerType.PopUp, prefab: "gui/eliminate/prefab/doubleSpeed" },
-    [UIID.WithdrawRecord]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/withdrawRecord" }
+    [UIID.WithdrawRecord]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/withdrawRecord" },
+    [UIID.GameOver]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/gameOver" }
 }

+ 20 - 10
assets/script/game/eliminate/view/EliminateViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:01:09
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-27 17:49:05
+ * @LastEditTime: 2025-03-27 18:40:24
  * @Description: 消除游戏主场景
  */
 import { _decorator } from "cc";
@@ -29,6 +29,7 @@ import { randomRangeInt } from "cc";
 import { EventTouch } from "cc";
 import { Vec2 } from "cc";
 import { tween } from "cc";
+import { GameEvent } from "../../common/config/GameEvent";
 
 const { ccclass, property } = _decorator;
 
@@ -197,7 +198,6 @@ export class EliminateViewComp extends CCComp {
     private grid: CellState[][] = [];               //数组管理网格状态
     private gridBlocks: (BlockItemView | null)[][] = []; // 存储网格中的方块脚本引用
     private gridCells: Node[][] = [];
-
     // 方块数据保存数组,生成后就保存起来
     private brickList: BrickData[] = [];
 
@@ -214,14 +214,25 @@ export class EliminateViewComp extends CCComp {
     }
 
 
+    addEventList() {
+        oops.message.on(GameEvent.RestartGame, this.restartGame, this);
+        // oops.message.on(GameEvent.Resurrection, this.resurrection, this);
+    }
+
+    //增加一个新人新手引导
+    private addNewPlayerGuide() {
+        // 获取当前引导步骤
+        // const currentStep = this.getTutorialStep();
+    }
+
+
     private initComponents() {
         // this.winthdrawNode = this.node.getChildByPath("Scene/Top/btn_withdraw")!;
         // this.awardNode = this.node.getChildByPath("Scene/Top/btn_award")!;
         const toggle = this.node.getChildByPath("Scene/Bottom/btn_auto/auto_Toggle/Off")!;
         this.autoOnToggle = toggle.getComponent(Toggle)!;
-
         this.lab_speed = this.node.getChildByPath("Scene/Bottom/btn_double/lab_time")!.uiLabel;
-        this.lab_speed.string = "9999999"
+        this.lab_speed.string = "二倍速"
     }
 
 
@@ -865,6 +876,7 @@ export class EliminateViewComp extends CCComp {
                     score += this.rows * i
                 }
                 this.score += score
+                this.lab_score.string = this.score.toString();
 
                 const lastGrid = gridEliminateList[gridEliminateList.length - 1];
                 if (lastGrid?.gridNode && this.coinPrefab && this.amountLb?.node) {
@@ -1150,6 +1162,8 @@ export class EliminateViewComp extends CCComp {
     gameOver() {
         this.gameState = GameState.GAME_OVER
         this.setGameState(GameState.GAME_OVER)
+        console.log("游戏结束")
+        oops.gui.open(UIID.GameOver);
     }
 
 
@@ -1161,9 +1175,6 @@ export class EliminateViewComp extends CCComp {
         children.forEach(node => node.destroy());
     }
 
-
-
-
     private setGameState(state: GameState) {
         this.gameState = state;
         switch (state) {
@@ -1451,9 +1462,8 @@ export class EliminateViewComp extends CCComp {
     //重新开始
     private restartGame() {
         if (this.gameState === GameState.READY) return;
-
-
-
+        this.initData();
+        this.reopenGrid();
     }
 
     private reopenGrid() {

+ 27 - 0
assets/script/game/eliminate/view/GameOverView.ts

@@ -0,0 +1,27 @@
+import { _decorator } from 'cc';
+import { oops } from 'db://oops-framework/core/Oops';
+import { GameComponent } from "db://oops-framework/module/common/GameComponent";
+import { GameEvent } from '../../common/config/GameEvent';
+import { UIID } from '../../common/config/GameUIConfig';
+
+const { ccclass, property } = _decorator;
+
+/** 显示对象控制 */
+@ccclass('GameOverView')
+export class GameOverView extends GameComponent {
+    protected start() {
+        this.setButton();
+    }
+
+
+    private btn_restart() {
+        oops.message.dispatchEvent(GameEvent.RestartGame);
+        oops.gui.remove(UIID.GameOver);
+    }
+
+    private btn_resurrection() {
+
+
+
+    }
+}

+ 9 - 0
assets/script/game/eliminate/view/GameOverView.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.24",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "a861547b-3e66-4a87-85be-7c07c35912d5",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}