|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-11 15:59:26
|
|
|
+ * @LastEditTime: 2025-04-14 15:26:29
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -24,7 +24,8 @@ enum GameState {
|
|
|
READY, // 准备中
|
|
|
PLAYING, // 游戏中
|
|
|
PAUSED, // 暂停 --看广告用
|
|
|
- GAME_OVER // 游戏结束
|
|
|
+ GAME_OVER, // 游戏结束
|
|
|
+ GAME_PASS
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -67,6 +68,7 @@ interface BrickData {
|
|
|
brickNode: Node | null,
|
|
|
brickInitPos: Vec3, // 方块初始位置
|
|
|
type: number, // 方块类型--gridColorKey
|
|
|
+ rotateNode: Node | null,
|
|
|
}
|
|
|
|
|
|
interface GridConfigData {
|
|
|
@@ -96,8 +98,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
private lab_score: Label = null!;
|
|
|
@property({ type: Label, displayName: "目标分数" })
|
|
|
private lab_taget: Label = null!;
|
|
|
- @property({ type: Label, displayName: "第几块金砖" })
|
|
|
- private lab_brick: Label = null!;
|
|
|
|
|
|
@property({ type: Prefab, displayName: "item预制体列表" })
|
|
|
private itemPrefabs: Prefab[] = [];
|
|
|
@@ -117,28 +117,29 @@ export class EliminateViewComp extends CCComp {
|
|
|
@property({ type: Label, displayName: "每次放置添加的分数" })
|
|
|
private lab_addScore: Label = null!;
|
|
|
|
|
|
-
|
|
|
@property({ type: Button, displayName: "自动按钮" })
|
|
|
private autoBtn: Button = null!;
|
|
|
- @property({ type: Button, displayName: "二倍速按钮" })
|
|
|
- private addSpeedBtn: Button = null!;
|
|
|
|
|
|
//游戏配置行列
|
|
|
private rows: number = 8; // 行数
|
|
|
private cols: number = 8; // 列数
|
|
|
private itemSize: number = 76.25; // 格子大小
|
|
|
private brickNum: number = 3; // 砖块数量
|
|
|
+ private yOffset = 0
|
|
|
+ private aniBrickMove = 0
|
|
|
+ private aniBrickRotate = 0
|
|
|
+ private aniBrickEliminate = 0
|
|
|
+
|
|
|
+ private operateFlag: boolean = false
|
|
|
+ private touchStartPos = new Vec2()
|
|
|
|
|
|
private gameState: GameState = GameState.READY;
|
|
|
private score: number = 0; //本局分数
|
|
|
private money: number = 0; //左边金钱
|
|
|
private cash: number = 0; //右边红包钱数
|
|
|
- private goldNum: number = 0; //金块数量
|
|
|
|
|
|
private targetScore: number = 0; //目标分数
|
|
|
|
|
|
- private totalNum: number = 0; //累计消除次数,断了就是又从0开始
|
|
|
-
|
|
|
private _isDoubleSpeed: boolean = false; //是否开启二倍速
|
|
|
private _doubleNum: number = 2; //除2就是开启了2倍速,除1就是关闭了2倍速
|
|
|
|
|
|
@@ -165,24 +166,23 @@ export class EliminateViewComp extends CCComp {
|
|
|
gridColorList: GridData[] = [];
|
|
|
|
|
|
brickConfig: { bricks?: any } = {} //方块配置
|
|
|
- editingFlag = false //编辑状态
|
|
|
editingData: EditingData = {
|
|
|
brickData: null,
|
|
|
gridList: [],
|
|
|
}
|
|
|
|
|
|
//旋转标记
|
|
|
- rotateFlag = false
|
|
|
- rotateBrickData: BrickData | null = null
|
|
|
+ // private rotateFlag = false
|
|
|
+ // private rotateBrickData: BrickData | null = null
|
|
|
|
|
|
// 添加新的属性来跟踪是否需要重置消除计数
|
|
|
private shouldResetEliminateCount: boolean = true;
|
|
|
|
|
|
private autoState: boolean = false; //自动状态
|
|
|
|
|
|
- private eliminateBaseScore: number = 10;
|
|
|
- private extraGridScore: number = 1;
|
|
|
- private placementBaseScore: number = 1;
|
|
|
+ private eliminateBaseScore: number = 10; //每行得多少分
|
|
|
+ private extraGridScore: number = 1; //每个格子占用几分
|
|
|
+ private placementBaseScore: number = 1; //每个格子占用几分
|
|
|
|
|
|
private totalEliminationCount: number = 0; // 总消除次数(包括行和列)
|
|
|
private currentCombo: number = 0; // 当前连击次数
|
|
|
@@ -238,8 +238,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.targetScore = 0;
|
|
|
this.money = 0;
|
|
|
this.cash = 0;
|
|
|
- this.totalNum = 0;
|
|
|
this.autoState = false;
|
|
|
+ this.operateFlag = true
|
|
|
this.shouldResetEliminateCount = true;
|
|
|
this.totalEliminationCount = 0;
|
|
|
this.currentCombo = 0;
|
|
|
@@ -253,8 +253,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
//设置数据
|
|
|
setData() {
|
|
|
this.score = smc.game.GameModel.curScore || 0;
|
|
|
- this.money = smc.account.AccountModel.gameCoin;
|
|
|
- this.cash = smc.account.AccountModel.cashCoin;
|
|
|
+ this.money = smc.account.AccountModel.wxCoin;
|
|
|
+ this.cash = smc.account.AccountModel.hbCoin;
|
|
|
this.targetScore = smc.game.GameModel.targetScore || 0;
|
|
|
this.lab_score.string = this.score.toString();
|
|
|
this.amountLb.string = this.money.toString();
|
|
|
@@ -367,9 +367,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
// 初始化方块
|
|
|
if (this.brickNode) {
|
|
|
- if (this.brickNode) {
|
|
|
- this.brickNode.children.forEach(node => { node.destroy() });
|
|
|
- }
|
|
|
+ this.brickNode.destroyAllChildren();
|
|
|
}
|
|
|
this.bricksList.length = 0
|
|
|
for (let i = 1; i <= this.brickNum; i++) {
|
|
|
@@ -377,8 +375,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
// 清除旋转数据
|
|
|
if (this.rotateNode) {
|
|
|
- this.rotateNode.children.forEach(node => { node.destroy() })
|
|
|
+ this.rotateNode.destroyAllChildren();
|
|
|
}
|
|
|
+ this.operateFlag = false
|
|
|
+ this.touchStartPos.set(Vec2.ZERO)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -511,6 +511,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
brickNode: null,
|
|
|
brickInitPos: new Vec3(),
|
|
|
type: randomIndex,
|
|
|
+ rotateNode: null,
|
|
|
}
|
|
|
this.bricksList.push(brickData)
|
|
|
// 生成方块
|
|
|
@@ -535,8 +536,12 @@ export class EliminateViewComp extends CCComp {
|
|
|
brickData.brickNode.scale_y = 0.6;
|
|
|
brickData.brickInitPos = brickData.brickNode.getWorldPosition()
|
|
|
}
|
|
|
+ if (brickData.rotateFlag) {
|
|
|
+ brickData.rotateNode = instantiate(this.rotatePrefab)
|
|
|
+ this.rotateNode.addChild(brickData.rotateNode)
|
|
|
+ brickData.rotateNode.setWorldPosition(brickNode.getWorldPosition())
|
|
|
+ }
|
|
|
this.brickAddEvent(brickData);
|
|
|
- //2508801946299286
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -619,16 +624,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
console.error("brickNode为空,无法添加事件");
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // 确保节点可交互
|
|
|
- brickNode.active = true;
|
|
|
-
|
|
|
- // 移除可能存在的旧事件监听器
|
|
|
- brickNode.off(Node.EventType.TOUCH_START);
|
|
|
- brickNode.off(Node.EventType.TOUCH_MOVE);
|
|
|
- brickNode.off(Node.EventType.TOUCH_END);
|
|
|
- brickNode.off(Node.EventType.TOUCH_CANCEL);
|
|
|
-
|
|
|
// 记录初始位置和状态
|
|
|
let startPos = new Vec3();
|
|
|
let originalParent: Node | null = null;
|
|
|
@@ -637,28 +632,25 @@ export class EliminateViewComp extends CCComp {
|
|
|
// 触摸开始事件
|
|
|
brickNode.on(Node.EventType.TOUCH_START, (event: EventTouch) => {
|
|
|
// 如果正在编辑其他方块,则忽略
|
|
|
- if (this.editingFlag) return;
|
|
|
+ if (!this.operateFlag) return;
|
|
|
|
|
|
- // 设置编辑状态
|
|
|
- this.editingFlag = true;
|
|
|
isDragging = true;
|
|
|
- this.touchStartFlag = true;
|
|
|
|
|
|
// 清空编辑中的数据
|
|
|
this.editingData.brickData = null;
|
|
|
this.editingData.gridList.length = 0;
|
|
|
|
|
|
// 记录触摸开始位置和方块原始信息
|
|
|
- this.touchStartLocation.set(event.getUILocation());
|
|
|
+ this.touchStartPos.set(event.getUILocation());
|
|
|
originalParent = brickNode.parent;
|
|
|
startPos = brickNode.getWorldPosition().clone();
|
|
|
|
|
|
// 将方块移到移动层并放大
|
|
|
brickNode.setParent(this.moveNode);
|
|
|
brickNode.setWorldPosition(startPos);
|
|
|
- tween(brickNode)
|
|
|
- .to(0.2, { scale: new Vec3(1, 1, 1) })
|
|
|
- .start();
|
|
|
+ // tween(brickNode)
|
|
|
+ // .to(0.2, { scale: new Vec3(1, 1, 1) })
|
|
|
+ // .start();
|
|
|
|
|
|
// 从方块列表中移除该方块
|
|
|
const index = this.bricksList.findIndex(item => item === brickData);
|
|
|
@@ -666,40 +658,35 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.editingData.brickData = this.bricksList.splice(index, 1)[0];
|
|
|
} else {
|
|
|
console.error("未找到方块数据:", brickData);
|
|
|
- this.editingData.brickData = brickData;
|
|
|
- }
|
|
|
-
|
|
|
- // 清除旋转数据
|
|
|
- if (this.rotateFlag && this.rotateBrickData !== this.editingData.brickData) {
|
|
|
- this.rotateFlag = false;
|
|
|
- this.rotateBrickData = null;
|
|
|
- if (this.rotateNode) {
|
|
|
- this.rotateNode.children.forEach(node => { node.destroy() });
|
|
|
- }
|
|
|
}
|
|
|
}, this);
|
|
|
|
|
|
// 触摸移动事件
|
|
|
brickNode.on(Node.EventType.TOUCH_MOVE, (event: EventTouch) => {
|
|
|
- if (!isDragging || !this.editingData.brickData) return;
|
|
|
-
|
|
|
- // 清除旋转数据
|
|
|
- if (event.getUILocation().subtract(this.touchStartLocation).length() >= this.rotateFaultTolerant) {
|
|
|
- this.rotateFlag = false;
|
|
|
- this.rotateBrickData = null;
|
|
|
- if (this.rotateNode) {
|
|
|
- this.rotateNode.children.forEach(node => { node.destroy() });
|
|
|
+ if (!isDragging || !this.operateFlag) return;
|
|
|
+
|
|
|
+ const movePos: Vec2 = event.getUILocation().subtract(this.touchStartPos)
|
|
|
+ // 挪动很小时,不移动方块组合
|
|
|
+ if (movePos.length() <= this.rotateFaultTolerant) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 隐藏旋转节点
|
|
|
+ if (this.editingData.brickData && this.editingData.brickData.rotateFlag) {
|
|
|
+ if (this.editingData.brickData.rotateNode) {
|
|
|
+ this.editingData.brickData.rotateNode.active = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 恢复所有网格颜色
|
|
|
this.gridColorRecovery();
|
|
|
-
|
|
|
// 移动方块
|
|
|
- brickNode.setWorldPosition(brickNode.getWorldPosition().add(event.getUIDelta().toVec3()));
|
|
|
-
|
|
|
+ brickNode.setWorldPosition(event.getUILocation().toVec3().add3f(0, this.yOffset, 0))
|
|
|
+ brickNode.scale_x = 1;
|
|
|
+ brickNode.scale_y = 1;
|
|
|
// 重置编辑中的网格数据
|
|
|
this.editingData.gridList.length = 0;
|
|
|
+ //
|
|
|
+
|
|
|
|
|
|
// 检查方块每个子网格是否与游戏网格重叠
|
|
|
const tempGridList: GridData[] = [];
|
|
|
@@ -738,7 +725,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (canPlace) {
|
|
|
this.editingData.gridList = [...tempGridList];
|
|
|
}
|
|
|
-
|
|
|
// 更新网格颜色提示 - 只改变空网格的颜色
|
|
|
tempGridList.forEach(grid => {
|
|
|
// 只处理空网格
|
|
|
@@ -761,17 +747,29 @@ export class EliminateViewComp extends CCComp {
|
|
|
isDragging = false;
|
|
|
this.touchStartFlag = false;
|
|
|
|
|
|
- // 恢复网格颜色
|
|
|
- this.gridColorRecovery();
|
|
|
-
|
|
|
- // 防止如放回方块回弹动画时,已经触摸在另一个方块上面
|
|
|
- if (this.editingData.brickData !== brickData) return;
|
|
|
-
|
|
|
- // 检查是否可以放置
|
|
|
- if (this.editingData.brickData && this.editingData.gridList.length > 0) {
|
|
|
+ // 单击旋转
|
|
|
+ if (!this.editingData.brickData) {
|
|
|
+ console.log("没有数据")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ this.editingData.brickData.rotateFlag &&
|
|
|
+ event.getUILocation().subtract(this.touchStartPos).length() <= this.rotateFaultTolerant
|
|
|
+ ) {
|
|
|
+ const brickData = this.editingData.brickData
|
|
|
+ // 方块放回待选区
|
|
|
+ if (brickData && brickData.brickNode) {
|
|
|
+ this.bricksList.push(brickData)
|
|
|
+ this.brickNode.addChild(brickData.brickNode)
|
|
|
+ brickData.brickNode.setWorldPosition(brickData.brickInitPos)
|
|
|
+ // 旋转
|
|
|
+ this.brickGridRotate(brickData).then(() => {
|
|
|
+ this.operateFlag = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if (this.editingData.brickData && this.editingData.gridList.length > 0) {
|
|
|
// 计算放置的格子数量
|
|
|
const placedGridCount = this.editingData.gridList.length;
|
|
|
-
|
|
|
// 获取中心位置用于显示分数
|
|
|
let centerPos = new Vec3(0, 0, 0);
|
|
|
if (this.editingData.gridList.length > 0 && this.editingData.gridList[0].gridNode) {
|
|
|
@@ -806,6 +804,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
// 销毁方块节点
|
|
|
brickNode.destroy();
|
|
|
|
|
|
+
|
|
|
// 添加新方块到待选区
|
|
|
this.addBrick(this.editingData.brickData.index);
|
|
|
|
|
|
@@ -822,26 +821,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (!canContinue) {
|
|
|
this.gameOver();
|
|
|
}
|
|
|
- this.editingFlag = false;
|
|
|
});
|
|
|
});
|
|
|
}, 0.1);
|
|
|
- } else if (this.rotateFlag) {
|
|
|
- // 旋转方块
|
|
|
- const brickData = this.editingData.brickData;
|
|
|
- this.brickGridRotate(brickData);
|
|
|
- // 方块放回待选区
|
|
|
- this.bricksList.push(brickData);
|
|
|
- if (this.brickNode && brickData.brickNode) {
|
|
|
- this.brickNode.addChild(brickData.brickNode);
|
|
|
- tween(brickData.brickNode)
|
|
|
- .to(0.2, {
|
|
|
- worldPosition: brickData.brickInitPos,
|
|
|
- scale: new Vec3(0.6, 0.6, 0.6)
|
|
|
- })
|
|
|
- .start();
|
|
|
- }
|
|
|
- this.editingFlag = false;
|
|
|
} else {
|
|
|
// 无法放置,将方块返回原位置
|
|
|
const brickData = this.editingData.brickData;
|
|
|
@@ -859,31 +841,13 @@ export class EliminateViewComp extends CCComp {
|
|
|
brickNode.setParent(originalParent);
|
|
|
brickNode.setWorldPosition(brickData.brickInitPos);
|
|
|
}
|
|
|
- this.editingFlag = false;
|
|
|
})
|
|
|
.start();
|
|
|
- } else {
|
|
|
- this.editingFlag = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 检查是否需要处理旋转(短距离移动视为点击)
|
|
|
- if (!this.rotateFlag &&
|
|
|
- this.editingData.brickData &&
|
|
|
- this.editingData.brickData.rotateFlag &&
|
|
|
- event.getUILocation().subtract(this.touchStartLocation).length() < this.rotateFaultTolerant) {
|
|
|
- this.rotateFlag = true;
|
|
|
- this.rotateBrickData = this.editingData.brickData;
|
|
|
-
|
|
|
- // 显示旋转提示
|
|
|
- if (this.rotatePrefab && this.rotateNode && brickNode) {
|
|
|
- const rotateIndicator = instantiate(this.rotatePrefab);
|
|
|
- this.rotateNode.addChild(rotateIndicator);
|
|
|
- rotateIndicator.setWorldPosition(brickNode.getWorldPosition());
|
|
|
}
|
|
|
}
|
|
|
+ // 格子颜色恢复
|
|
|
+ this.gridColorRecovery()
|
|
|
};
|
|
|
-
|
|
|
brickNode.on(Node.EventType.TOUCH_END, touchEndHandler, this);
|
|
|
brickNode.on(Node.EventType.TOUCH_CANCEL, touchEndHandler, this);
|
|
|
}
|
|
|
@@ -903,13 +867,16 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
brickGridRotate(brickData: BrickData) {
|
|
|
- const next = this.nextGridRotate(brickData.gridConfig, brickData.deg)
|
|
|
- brickData.deg = next.deg
|
|
|
- brickData.gridConfig = next.gridConfig;
|
|
|
- if (brickData.brickNode) {
|
|
|
- tween(brickData.brickNode).to(0.1, { angle: next.deg }).start();
|
|
|
- }
|
|
|
- // this.audioManager.playRotate()
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const next = this.nextGridRotate(brickData.gridConfig, brickData.deg)
|
|
|
+ brickData.deg = next.deg
|
|
|
+ brickData.gridConfig = next.gridConfig
|
|
|
+ if (brickData.brickNode) {
|
|
|
+ tween(brickData.brickNode).to(this.aniBrickRotate, { angle: next.deg }).call(() => {
|
|
|
+ resolve(true)
|
|
|
+ }).start()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//下一个旋转
|
|
|
@@ -1108,7 +1075,15 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
this.score += score;
|
|
|
this.lab_score.string = this.score.toString();
|
|
|
+ if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
+ ServerHandler.inst.updateEliminationReward({
|
|
|
+ count: 1,
|
|
|
+ score: this.score,
|
|
|
+ level: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
+ //要服务器请求完了出了数据才展示动画
|
|
|
const lastGrid = gridEliminateList[gridEliminateList.length - 1];
|
|
|
if (lastGrid?.gridNode && this.coinPrefab && this.amountLb?.node) {
|
|
|
const lastPos = lastGrid.gridNode.getWorldPosition();
|
|
|
@@ -1137,15 +1112,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
- ServerHandler.inst.updateEliminationReward({
|
|
|
- count: 1,
|
|
|
- score: this.score,
|
|
|
- level: 1
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
// 告诉调用者有消除发生
|
|
|
resolve(true)
|
|
|
// 检查是否需要继续消除
|
|
|
@@ -1200,7 +1166,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (!prefab) return;
|
|
|
|
|
|
let completedCount = 0;
|
|
|
- const totalCoins = Math.min(count, 10); // 限制最大数量
|
|
|
+ const totalCoins = Math.min(count, 6); // 限制最大数量
|
|
|
|
|
|
for (let i = 0; i < totalCoins; i++) {
|
|
|
const coin = instantiate(prefab);
|
|
|
@@ -1241,10 +1207,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
// 显示微信分数增加动画
|
|
|
private showWechatScoreAnimation() {
|
|
|
if (!this.tweenWechatNode) return;
|
|
|
-
|
|
|
// 生成随机小数(小于1,保留2位小数)
|
|
|
- const randomValue = Math.random() * 0.99;
|
|
|
- const formattedValue = randomValue.toFixed(2);
|
|
|
+ const changeNum = smc.game.GameModel.changeWxCoin;
|
|
|
+ if (!changeNum) return;
|
|
|
+ const formattedValue = changeNum;
|
|
|
|
|
|
// 获取并设置分数标签
|
|
|
const scoreLabel = this.tweenWechatNode.getChildByName("lab_num")?.getComponent(Label);
|
|
|
@@ -1271,15 +1237,21 @@ export class EliminateViewComp extends CCComp {
|
|
|
.to(0.2, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
// 重置位置
|
|
|
- this.tweenWechatNode.setPosition(originalPosition);
|
|
|
+ this.tweenWechatNode.setPosition(new Vec3(
|
|
|
+ originalPosition.x,
|
|
|
+ originalPosition.y - 50,
|
|
|
+ originalPosition.z
|
|
|
+ ));
|
|
|
this.tweenWechatNode.active = false;
|
|
|
|
|
|
// 更新总金额
|
|
|
if (this.amountLb) {
|
|
|
- const currentAmount = parseFloat(this.amountLb.string);
|
|
|
- const newAmount = currentAmount + parseFloat(formattedValue);
|
|
|
+ const currentAmount = this.money;
|
|
|
+ const newAmount = currentAmount + formattedValue;
|
|
|
this.money = newAmount;
|
|
|
- this.amountLb.string = newAmount.toFixed(2);
|
|
|
+ this.amountLb.changeTo(0.5, newAmount, () => {
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
.start();
|
|
|
@@ -1290,8 +1262,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (!this.tweenRedNode) return;
|
|
|
//如果有值就是要那个,没有就是取随机
|
|
|
|
|
|
- const randomValue = Math.random() * 0.99;
|
|
|
- const formattedValue = randomValue.toFixed(2);
|
|
|
+ const changeNum = smc.game.GameModel.changeHbCoin;
|
|
|
+ if (!changeNum) return;
|
|
|
+ const formattedValue = changeNum;
|
|
|
|
|
|
// 获取并设置分数标签
|
|
|
const scoreLabel = this.tweenRedNode.getChildByName("lab_num")?.getComponent(Label);
|
|
|
@@ -1319,15 +1292,20 @@ export class EliminateViewComp extends CCComp {
|
|
|
.to(0.2 / num, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
// 重置位置
|
|
|
- this.tweenRedNode.setPosition(originalPosition);
|
|
|
+ this.tweenRedNode.setPosition(new Vec3(
|
|
|
+ originalPosition.x,
|
|
|
+ originalPosition.y - 50,
|
|
|
+ originalPosition.z
|
|
|
+ ));
|
|
|
this.tweenRedNode.active = false;
|
|
|
|
|
|
// 更新总红包金额
|
|
|
if (this.awardLb) {
|
|
|
- const currentAmount = parseFloat(this.awardLb.string);
|
|
|
- const newAmount = currentAmount + parseFloat(formattedValue);
|
|
|
+ const currentAmount = this.cash;
|
|
|
+ const newAmount = currentAmount + formattedValue;
|
|
|
this.cash = newAmount;
|
|
|
- this.awardLb.string = newAmount.toFixed(2);
|
|
|
+ this.awardLb.changeTo(0.5, newAmount, () => {
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
.start();
|
|
|
@@ -1506,12 +1484,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
updateGameScore() {
|
|
|
if (this.score >= this.targetScore) {
|
|
|
//修改游戏状态
|
|
|
- this.gameState = GameState.GAME_OVER;
|
|
|
+ this.gameState = GameState.GAME_PASS;
|
|
|
//弹出恭喜通关
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1781,7 +1757,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.executeAutoPlace()
|
|
|
}, 0.3)
|
|
|
}
|
|
|
- this.editingFlag = false
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
@@ -1791,12 +1766,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
doubleSpeedOpenSuccess() {
|
|
|
this._isDoubleSpeed = true;
|
|
|
//3分钟后关闭
|