瀏覽代碼

【功能】增加Combo字体,完善复活分数减半功能

mojunshou 1 年之前
父節點
當前提交
fc4542c17a

File diff suppressed because it is too large
+ 649 - 371
assets/bundle/gui/eliminate/eliminate.prefab


二進制
assets/bundle/gui/eliminate/fnt/AaHouDiHei-2.ttf


+ 12 - 0
assets/bundle/gui/eliminate/fnt/AaHouDiHei-2.ttf.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.0.1",
+  "importer": "ttf-font",
+  "imported": true,
+  "uuid": "a7ef56a3-2c1f-4428-a368-cb38b249b37c",
+  "files": [
+    ".json",
+    "AaHouDiHei-2.ttf"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

二進制
assets/bundle/gui/eliminate/texture/combo.png


+ 134 - 0
assets/bundle/gui/eliminate/texture/combo.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "a4cf5a29-9535-4744-957e-8894c549d6f7",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "a4cf5a29-9535-4744-957e-8894c549d6f7@6c48a",
+      "displayName": "combo",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "a4cf5a29-9535-4744-957e-8894c549d6f7",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "a4cf5a29-9535-4744-957e-8894c549d6f7@f9941",
+      "displayName": "combo",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 1,
+        "offsetY": 1.5,
+        "trimX": 6,
+        "trimY": 0,
+        "width": 244,
+        "height": 73,
+        "rawWidth": 254,
+        "rawHeight": 76,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -122,
+            -36.5,
+            0,
+            122,
+            -36.5,
+            0,
+            -122,
+            36.5,
+            0,
+            122,
+            36.5,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            6,
+            76,
+            250,
+            76,
+            6,
+            3,
+            250,
+            3
+          ],
+          "nuv": [
+            0.023622047244094488,
+            0.039473684210526314,
+            0.984251968503937,
+            0.039473684210526314,
+            0.023622047244094488,
+            1,
+            0.984251968503937,
+            1
+          ],
+          "minPos": [
+            -122,
+            -36.5,
+            0
+          ],
+          "maxPos": [
+            122,
+            36.5,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "a4cf5a29-9535-4744-957e-8894c549d6f7@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "a4cf5a29-9535-4744-957e-8894c549d6f7@6c48a"
+  }
+}

+ 10 - 0
assets/script/game/common/manager/ADHandler.ts

@@ -114,6 +114,16 @@ export class ADHandler {
                 smc.game.GameModel.viewType = "";
                 return;
             }
+            //如果是复活,分数减半
+            if (smc.game.GameModel.viewType === "revive_reward") {
+                const score = smc.game.GameModel.curScore;
+                smc.game.GameModel.curScore = Math.floor(score / 2);
+                oops.message.dispatchEvent(GameEvent.RestartGame);
+                smc.game.GameModel.viewType = "";
+                return;
+            }
+
+
             ServerHandler.inst.getVideorReward();
         }
     };

+ 29 - 24
assets/script/game/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-04-17 18:12:06
+ * @LastEditTime: 2025-04-17 19:26:14
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -129,6 +129,9 @@ export class EliminateViewComp extends CCComp {
     @property({ type: Node, displayName: "引导层" })
     private guideNode: Node = null!;
 
+    @property({ type: Node, displayName: "ComboNode" })
+    private comboNode: Node = null!;
+
 
     //游戏配置行列
     private rows: number = 8;       // 行数
@@ -1232,7 +1235,7 @@ export class EliminateViewComp extends CCComp {
 
     // 显示消除次数动画
     showEliminateCountAnimation(yPosition: number, eliminationCount: number) {
-        if (!this.lab_total) return;
+        if (!this.comboNode) return;
 
         // 如果需要重置计数器,先将计数归零
         if (this.shouldResetEliminateCount) {
@@ -1243,17 +1246,20 @@ export class EliminateViewComp extends CCComp {
         this.currentCombo += eliminationCount;
 
         // 复制总次数Label
-        const totalLabel = instantiate(this.lab_total.node);
-        totalLabel.active = true;
+        const comboNode = instantiate(this.comboNode);
+        comboNode.active = true;
 
         // 设置文本
-        const label = totalLabel.getComponent(Label);
+        const label = comboNode.getChildByName("lab_combo");
         if (label) {
-            label.string = `Combo${this.currentCombo}`;
+            const labelComponent = label.getComponent(Label);
+            if (labelComponent) {
+                labelComponent.string = `${this.currentCombo}`;
+            }
         }
 
         // 添加到场景中
-        this.node.addChild(totalLabel);
+        this.node.addChild(comboNode);
 
         // 计算网格区域的X轴中心位置,Y轴使用传入的消除行位置
         const centerPos = new Vec3();
@@ -1263,11 +1269,11 @@ export class EliminateViewComp extends CCComp {
             centerPos.set(worldPos.x, yPosition, worldPos.z);
         }
 
-        totalLabel.setWorldPosition(centerPos);
+        comboNode.setWorldPosition(centerPos);
 
         // 创建动画效果
         const num = this.isDoubleSpeed ? this.doubleNum : 1;
-        tween(totalLabel)
+        tween(comboNode)
             .to(0.3 / num, {
                 scale: new Vec3(1.5, 1.5, 1.5),
                 opacity: 255
@@ -1275,11 +1281,11 @@ export class EliminateViewComp extends CCComp {
             .delay(0.5 / num) // 停留更长时间
             .to(0.4 / num, {
                 scale: new Vec3(1.2, 1.2, 1.2),
-                position: new Vec3(totalLabel.position.x, totalLabel.position.y + 50, 0),
+                position: new Vec3(comboNode.position.x, comboNode.position.y + 50, 0),
                 opacity: 0
             })
             .call(() => {
-                totalLabel.destroy();
+                comboNode.destroy();
             })
             .start();
     }
@@ -1512,19 +1518,19 @@ export class EliminateViewComp extends CCComp {
         }
 
         // 保存原始位置
-        const originalPosition = this.tweenWechatNode.position;
+        const originalPosition = this.amountLb.node.worldPosition;
 
         //设置原始位置
-        this.tweenWechatNode.setPosition(originalPosition);
+        this.tweenWechatNode.setWorldPosition(originalPosition);
         // 显示节点
         this.tweenWechatNode.active = true;
 
         // 创建向上移动的动画
         tween(this.tweenWechatNode)
             .to(0.8, {
-                position: new Vec3(
+                worldPosition: new Vec3(
                     originalPosition.x,
-                    originalPosition.y + 100,
+                    originalPosition.y + 50,
                     originalPosition.z
                 ),
                 opacity: 255
@@ -1532,9 +1538,9 @@ export class EliminateViewComp extends CCComp {
             .to(0.2, { opacity: 0 })
             .call(() => {
                 //设置位置y-100
-                this.tweenWechatNode.setPosition(new Vec3(
+                this.tweenWechatNode.setWorldPosition(new Vec3(
                     originalPosition.x,
-                    originalPosition.y - 100,
+                    originalPosition.y,
                     originalPosition.z
                 ))
                 this.tweenWechatNode.active = false;
@@ -1562,27 +1568,27 @@ export class EliminateViewComp extends CCComp {
             scoreLabel.string = "+" + formattedValue;
         }
         // 保存原始位置
-        const originalPosition = this.tweenRedNode.position;
+        const originalPosition = this.awardLb.node.worldPosition;
         //设置原始位置
-        this.tweenRedNode.setPosition(originalPosition);
+        this.tweenRedNode.setWorldPosition(originalPosition);
         // 显示节点
         this.tweenRedNode.active = true;
         // 创建向上移动的动画
         const num = this.isDoubleSpeed ? this.doubleNum : 1;
         tween(this.tweenRedNode)
             .to(0.8 / num, {
-                position: new Vec3(
+                worldPosition: new Vec3(
                     originalPosition.x,
-                    originalPosition.y + 100,
+                    originalPosition.y + 50,
                     originalPosition.z
                 ),
                 opacity: 255
             })
             .to(0.2 / num, { opacity: 0 })
             .call(() => {
-                this.tweenRedNode.setPosition(new Vec3(
+                this.tweenRedNode.setWorldPosition(new Vec3(
                     originalPosition.x,
-                    originalPosition.y - 100,
+                    originalPosition.y,
                     originalPosition.z
                 ))
 
@@ -1803,7 +1809,6 @@ export class EliminateViewComp extends CCComp {
                 break;
             case GameState.GAME_OVER:
                 //打开游戏结束界面
-                this.gameState = GameState.READY
                 this.autoState = false;
                 this.adShowingFlag = false;
                 //自动按钮改为手动 

+ 1 - 6
assets/script/game/view/GameOverView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-27 18:19:53
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-17 18:53:19
+ * @LastEditTime: 2025-04-17 18:55:23
  * @Description: 游戏结束界面
  */
 import { _decorator, Label, ProgressBar } from 'cc';
@@ -21,11 +21,6 @@ const { ccclass, property } = _decorator;
 /** 显示对象控制 */
 @ccclass('GameOverView')
 export class GameOverView extends VMParent {
-    @property(Label)
-    private lab_bar: Label = null!; //分数
-
-    @property(ProgressBar)
-    private progressBar: ProgressBar = null!; //进度条
 
     data: any = {
         cd: 20,