|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-09 18:39:13
|
|
|
+ * @LastEditTime: 2025-04-10 15:29:11
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -10,11 +10,11 @@ import { oops } from "db://oops-framework/core/Oops";
|
|
|
import { ecs } from "db://oops-framework/libs/ecs/ECS";
|
|
|
import { LabelChange } from "db://oops-framework/libs/gui/label/LabelChange";
|
|
|
import { CCComp } from "db://oops-framework/module/common/CCComp";
|
|
|
-import { GameEvent } from "../../common/config/GameEvent";
|
|
|
-import { UIID } from "../../common/config/GameUIConfig";
|
|
|
-import { smc } from "../../common/SingletonModuleComp";
|
|
|
-import { CocosHandler } from "../../common/manager/CocosHandler";
|
|
|
import { DeviceUtil } from "db://oops-framework/core/utils/DeviceUtil";
|
|
|
+import { GameEvent } from "../common/config/GameEvent";
|
|
|
+import { UIID } from "../common/config/GameUIConfig";
|
|
|
+import { CocosHandler } from "../common/manager/CocosHandler";
|
|
|
+import { smc } from "../common/SingletonModuleComp";
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -22,8 +22,8 @@ const { ccclass, property } = _decorator;
|
|
|
enum GameState {
|
|
|
READY, // 准备中
|
|
|
PLAYING, // 游戏中
|
|
|
- PAUSED, // 暂停
|
|
|
- GAME_OVER // 游戏结束
|
|
|
+ PAUSED, // 暂停 --看广告用
|
|
|
+ GAME_OVER // 游戏结束
|
|
|
}
|
|
|
|
|
|
// 游戏模式枚举
|
|
|
@@ -76,7 +76,6 @@ interface EditingData {
|
|
|
interface BrickData {
|
|
|
index: number,
|
|
|
brickKey: string | null,
|
|
|
- rotateTag: boolean,
|
|
|
rotateFlag: boolean,
|
|
|
gridConfig: Grids[],
|
|
|
deg: number,
|
|
|
@@ -105,7 +104,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
private tweenRedNode: Node = null!;
|
|
|
|
|
|
@property({ type: Prefab, displayName: "金币预制体" })
|
|
|
- private coinPrefab: Prefab = null!;
|
|
|
+ private coinPrefab: Prefab = null!
|
|
|
@property({ type: Prefab, displayName: "红包预制体" })
|
|
|
private redPacketPrefab: Prefab = null!;
|
|
|
@property({ type: Label, displayName: "本局分数" })
|
|
|
@@ -115,11 +114,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
@property({ type: Label, displayName: "第几块金砖" })
|
|
|
private lab_brick: Label = null!;
|
|
|
|
|
|
- @property({ type: Label, displayName: "第几关" })
|
|
|
- private lab_levle: Label = null!;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@property({ type: Prefab, displayName: "item预制体列表" })
|
|
|
private itemPrefabs: Prefab[] = [];
|
|
|
@property({ type: Node, displayName: "网格Node" })
|
|
|
@@ -138,12 +132,12 @@ 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; // 列数
|
|
|
@@ -154,7 +148,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
private score: number = 0; //本局分数
|
|
|
private money: number = 0; //左边金钱
|
|
|
private cash: number = 0; //右边红包钱数
|
|
|
- private goldNum: number = 0; //尽快数量
|
|
|
+ private goldNum: number = 0; //金块数量
|
|
|
|
|
|
private targetScore: number = 0; //目标分数
|
|
|
|
|
|
@@ -263,10 +257,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
//设置数据
|
|
|
setData() {
|
|
|
- this.score = smc.account.AccountModel.curScore || 0;
|
|
|
+ this.score = smc.game.GameModel.curScore || 0;
|
|
|
this.money = smc.account.AccountModel.gameCoin;
|
|
|
this.cash = smc.account.AccountModel.cashCoin;
|
|
|
- this.targetScore = smc.account.AccountModel.targetScore || 0;
|
|
|
+ this.targetScore = smc.game.GameModel.targetScore || 0;
|
|
|
this.lab_score.string = this.score.toString();
|
|
|
this.amountLb.string = this.money.toString();
|
|
|
this.awardLb.string = this.cash.toString();
|
|
|
@@ -395,7 +389,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
console.warn('无效的网格数据');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
// 清理现有子节点
|
|
|
this.clearGridChildren(gridData.gridNode);
|
|
|
|
|
|
@@ -483,7 +476,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
deg: 0,
|
|
|
brickNode: null,
|
|
|
brickInitPos: new Vec3(),
|
|
|
- rotateTag: false,
|
|
|
type: randomIndex,
|
|
|
}
|
|
|
this.bricksList.push(brickData)
|
|
|
@@ -1525,226 +1517,248 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //自动按钮
|
|
|
+ //自动放置
|
|
|
private btn_auto() {
|
|
|
- //自动放置
|
|
|
this.autoState = !this.autoState;
|
|
|
- this._isDoubleSpeed = !this._isDoubleSpeed;
|
|
|
this.initButtonState(this.autoState);
|
|
|
+ this.gameState = GameState.PLAYING
|
|
|
if (this.autoState) {
|
|
|
- this.gameState = GameState.PLAYING;
|
|
|
- this.executeAutoPlace()
|
|
|
+ this.startAutoMode();
|
|
|
+ } else {
|
|
|
+ this.stopAutoMode();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private autoModeScheduleKey: number = 0;
|
|
|
|
|
|
- executeAutoPlace() {
|
|
|
- if (!this.autoState || this.gameState !== GameState.PLAYING || this.editingFlag) {
|
|
|
- return
|
|
|
- }
|
|
|
- console.log("开始自动放置")
|
|
|
- const bestPlacement = this.findBestPlacement()
|
|
|
- if (!bestPlacement) {
|
|
|
- // 所有方块都无法放置,游戏结束
|
|
|
- this.autoState = false
|
|
|
- this.gameOver()
|
|
|
- return
|
|
|
- }
|
|
|
+ private startAutoMode() {
|
|
|
+ this.stopAutoMode(); // 确保先停止之前的自动模式
|
|
|
+ const interval = this._isDoubleSpeed ? this.autoModeInterval / this._doubleNum : this.autoModeInterval;
|
|
|
+ this.autoModeScheduleKey = this.schedule(this.executeAutoPlacement, interval);
|
|
|
+ }
|
|
|
|
|
|
- // 执行放置
|
|
|
- this.placeBrickAtPosition(bestPlacement)
|
|
|
+ private stopAutoMode() {
|
|
|
+ this.unschedule(this.executeAutoPlacement);
|
|
|
}
|
|
|
|
|
|
- findBestPlacement() {
|
|
|
- const placements = []
|
|
|
+ // 调整自动放置速度
|
|
|
+ public setAutoPlacementSpeed(interval: number) {
|
|
|
+ this.autoModeInterval = interval;
|
|
|
+ if (this.autoState) {
|
|
|
+ this.startAutoMode(); // 重新启动以更新间隔
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 对每个方块计算所有可能的放置位置和分数
|
|
|
- for (let brickIndex = 0; brickIndex < this.bricksList.length; brickIndex++) {
|
|
|
- const brickData = this.bricksList[brickIndex]
|
|
|
+ // 执行自动放置
|
|
|
+ private executeAutoPlacement() {
|
|
|
+ if (this.editingFlag || this.gameState !== GameState.PLAYING) return;
|
|
|
|
|
|
- // 检查不同旋转状态
|
|
|
- let gridConfigs = [brickData.gridConfig]
|
|
|
- let degrees = [brickData.deg]
|
|
|
+ // 查找最佳放置方案
|
|
|
+ const bestPlacement = this.findBestPlacement();
|
|
|
+ if (!bestPlacement) {
|
|
|
+ this.gameOver();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // 如果可旋转,计算所有旋转状态
|
|
|
- if (brickData.rotateFlag) {
|
|
|
- for (let i = 1; i <= 3; i++) {
|
|
|
- const next = this.nextGridRotate(
|
|
|
- i === 1 ? brickData.gridConfig : gridConfigs[i - 1],
|
|
|
- i === 1 ? brickData.deg : degrees[i - 1]
|
|
|
- )
|
|
|
- gridConfigs.push(next.gridConfig)
|
|
|
- degrees.push(next.deg)
|
|
|
- }
|
|
|
- }
|
|
|
+ this.autoPlaceBrick(bestPlacement);
|
|
|
+ }
|
|
|
|
|
|
- // 遍历所有网格位置
|
|
|
- for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
|
|
|
- for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
|
|
|
- // 对每个旋转状态检查
|
|
|
- for (let rotateIndex = 0; rotateIndex < gridConfigs.length; rotateIndex++) {
|
|
|
- const currentGridConfig = gridConfigs[rotateIndex]
|
|
|
- const currentDeg = degrees[rotateIndex]
|
|
|
|
|
|
+ // 查找最佳放置方案
|
|
|
+ private findBestPlacement() {
|
|
|
+ // 最佳放置方案
|
|
|
+ let bestPlacement: {
|
|
|
+ brickIndex: number,
|
|
|
+ row: number,
|
|
|
+ column: number,
|
|
|
+ rotateCount: number,
|
|
|
+ score: number
|
|
|
+ } | null = null;
|
|
|
+
|
|
|
+ // 遍历所有方块
|
|
|
+ for (let brickI = 0; brickI < this.bricksList.length; brickI++) {
|
|
|
+ const brickData = this.bricksList[brickI];
|
|
|
+
|
|
|
+ // 尝试所有可能的旋转状态
|
|
|
+ let currentGridConfig = [...brickData.gridConfig];
|
|
|
+ let currentDeg = brickData.deg;
|
|
|
+
|
|
|
+ for (let rotateCount = 0; rotateCount < 4; rotateCount++) {
|
|
|
+ // 遍历所有网格位置
|
|
|
+ for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
|
|
|
+ for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
|
|
|
// 检查是否可以放置
|
|
|
if (this.moveIf(rowIndex, columnIndex, currentGridConfig)) {
|
|
|
- // 复制网格并模拟放置
|
|
|
- const gridList = this.copyGridList()
|
|
|
- currentGridConfig.forEach((gridConfigData) => {
|
|
|
- const r = gridConfigData.row + rowIndex
|
|
|
- const c = gridConfigData.column + columnIndex
|
|
|
- gridList[r][c].status = CellState.FILLED
|
|
|
- // gridList[r][c].gridColorKey = brickData.gridColorKey
|
|
|
- gridList[r][c].type = brickData.type;
|
|
|
- })
|
|
|
-
|
|
|
- // 检查是否可以消除,计算分数
|
|
|
- const elimination = this.gridEliminateCheck(gridList)
|
|
|
- let score = 0
|
|
|
-
|
|
|
- if (elimination.gridEliminateList.length > 0) {
|
|
|
- // 计算消除得分
|
|
|
- for (let i = 1; i <= elimination.eliminateRowNum; i++) {
|
|
|
- score += this.cols * i
|
|
|
+ // 复制网格状态并模拟放置
|
|
|
+ const gridListCopy = this.copyGridList();
|
|
|
+ currentGridConfig.forEach((configData) => {
|
|
|
+ gridListCopy[configData.row + rowIndex][configData.column + columnIndex].status = CellState.FILLED;
|
|
|
+ gridListCopy[configData.row + rowIndex][configData.column + columnIndex].type = brickData.type;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算放置后的分数
|
|
|
+ const eliminateResult = this.gridEliminateCheck(gridListCopy);
|
|
|
+ const eliminatedCount = eliminateResult.gridEliminateList.length;
|
|
|
+
|
|
|
+ let score = 0;
|
|
|
+ // 有消除,计算消除分数
|
|
|
+ if (eliminatedCount > 0) {
|
|
|
+ for (let i = 1; i <= eliminateResult.eliminateRowNum; i++) {
|
|
|
+ score += this.cols * i;
|
|
|
}
|
|
|
- for (let i = 1; i <= elimination.eliminateColumnNum; i++) {
|
|
|
- score += this.rows * i
|
|
|
+ for (let i = 1; i <= eliminateResult.eliminateColumnNum; i++) {
|
|
|
+ score += this.rows * i;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 记录此放置选项
|
|
|
- placements.push({
|
|
|
- brickIndex,
|
|
|
- brickData,
|
|
|
- rowIndex,
|
|
|
- columnIndex,
|
|
|
- gridConfig: currentGridConfig,
|
|
|
- deg: currentDeg,
|
|
|
- score,
|
|
|
- canEliminate: elimination.gridEliminateList.length > 0
|
|
|
- })
|
|
|
+ // 如果没有消除,至少给予放置的块数作为基础分
|
|
|
+ if (score === 0) {
|
|
|
+ score = currentGridConfig.length * 0.1; // 给一个很小的分数,优先选择能放置的方案
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新最佳方案
|
|
|
+ if (!bestPlacement || score > bestPlacement.score) {
|
|
|
+ bestPlacement = {
|
|
|
+ brickIndex: brickI,
|
|
|
+ row: rowIndex,
|
|
|
+ column: columnIndex,
|
|
|
+ rotateCount: rotateCount,
|
|
|
+ score: score
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 按优先级排序:最高分 > 有分数 > 没有分数但可放置
|
|
|
- placements.sort((a, b) => {
|
|
|
- // 首先按分数排序
|
|
|
- if (a.score !== b.score) {
|
|
|
- return b.score - a.score
|
|
|
- }
|
|
|
- // 其次按是否可消除排序
|
|
|
- if (a.canEliminate !== b.canEliminate) {
|
|
|
- return a.canEliminate ? -1 : 1
|
|
|
+ // 旋转方块到下一个状态
|
|
|
+ if (rotateCount < 3 && brickData.rotateFlag) {
|
|
|
+ const next = this.nextGridRotate(currentGridConfig, currentDeg);
|
|
|
+ currentGridConfig = next.gridConfig;
|
|
|
+ currentDeg = next.deg;
|
|
|
+ }
|
|
|
}
|
|
|
- // 最后按照方块优先级排序(底部的方块优先)
|
|
|
- return a.brickIndex - b.brickIndex
|
|
|
- })
|
|
|
+ }
|
|
|
|
|
|
- return placements.length > 0 ? placements[0] : null
|
|
|
+ return bestPlacement;
|
|
|
}
|
|
|
|
|
|
- // ... existing code ...
|
|
|
+ // 自动放置方块
|
|
|
+ private autoPlaceBrick(placement: { brickIndex: number, row: number, column: number, rotateCount: number, score: number }) {
|
|
|
+ const brickData = this.bricksList[placement.brickIndex];
|
|
|
+ if (!brickData || !brickData.brickNode) return;
|
|
|
+ console.log("brickData>>>>>>", brickData);
|
|
|
+ // 获取方块节点
|
|
|
+ const brickNode = brickData.brickNode;
|
|
|
+
|
|
|
+ // 先将方块移到移动层以便显示动画
|
|
|
+ const originalParent = brickNode.parent;
|
|
|
+ const startPos = brickNode.getWorldPosition().clone();
|
|
|
+ brickNode.setParent(this.moveNode);
|
|
|
+ brickNode.setWorldPosition(startPos);
|
|
|
+
|
|
|
+ // 放大方块
|
|
|
+ tween(brickNode)
|
|
|
+ .to(0.2, { scale: new Vec3(1, 1, 1) })
|
|
|
+ .start();
|
|
|
|
|
|
- placeBrickAtPosition(placement) {
|
|
|
- // 获取方块数据
|
|
|
- const brickData = placement.brickData
|
|
|
- const index = this.bricksList.findIndex(data => data === brickData)
|
|
|
- if (index === -1) {
|
|
|
- console.error("无法找到要放置的方块:", brickData)
|
|
|
- return
|
|
|
- }
|
|
|
+ // 从方块列表中移除该方块
|
|
|
+ this.bricksList.splice(placement.brickIndex, 1);
|
|
|
|
|
|
- // 从待选区移除方块
|
|
|
- this.editingData.brickData = this.bricksList.splice(index, 1)[0]
|
|
|
+ // 准备旋转和定位数据
|
|
|
+ let currentGridConfig = [...brickData.gridConfig];
|
|
|
+ let currentDeg = brickData.deg;
|
|
|
|
|
|
- // 如果需要旋转,执行旋转
|
|
|
- const num = this._isDoubleSpeed ? this._doubleNum : 1;
|
|
|
- if (brickData.deg !== placement.deg) {
|
|
|
- // 更新方块配置和角度
|
|
|
- brickData.gridConfig = placement.gridConfig
|
|
|
- brickData.deg = placement.deg
|
|
|
- // 添加旋转动画
|
|
|
- tween(brickData.brickNode).to(0.2 / num, { angle: placement.deg }).start()
|
|
|
- }
|
|
|
+ // 计算目标网格的中心位置
|
|
|
+ const targetGridList: GridData[] = [];
|
|
|
+ let targetPos = new Vec3(0, 0, 0);
|
|
|
|
|
|
- // 准备网格列表
|
|
|
- this.editingData.gridList = []
|
|
|
- placement.gridConfig.forEach((gridConfigData: GridConfigData) => {
|
|
|
- const r = gridConfigData.row + placement.rowIndex
|
|
|
- const c = gridConfigData.column + placement.columnIndex
|
|
|
- this.editingData.gridList.push(this.gridList[r][c])
|
|
|
- })
|
|
|
-
|
|
|
- // 计算目标位置 - 使用中间位置作为基准
|
|
|
- let centerPos = new Vec3(0, 0, 0);
|
|
|
- let validGridCount = 0;
|
|
|
+ // 确定需要放置的格子
|
|
|
+ for (let i = 0; i < placement.rotateCount; i++) {
|
|
|
+ if (brickData.rotateFlag) {
|
|
|
+ const next = this.nextGridRotate(currentGridConfig, currentDeg);
|
|
|
+ currentGridConfig = next.gridConfig;
|
|
|
+ currentDeg = next.deg;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 计算所有网格的平均位置
|
|
|
- this.editingData.gridList.forEach(grid => {
|
|
|
- if (grid.gridNode) {
|
|
|
- const worldPos = grid.gridNode.getWorldPosition();
|
|
|
- centerPos.add(worldPos);
|
|
|
- validGridCount++;
|
|
|
+ // 计算目标位置--这里出问题了
|
|
|
+ currentGridConfig.forEach(configData => {
|
|
|
+ const gridRow = configData.row + placement.row;
|
|
|
+ const gridCol = configData.column + placement.column;
|
|
|
+ if (gridRow >= 0 && gridRow < this.rows && gridCol >= 0 && gridCol < this.cols) {
|
|
|
+ const grid = this.gridList[gridRow][gridCol];
|
|
|
+ if (grid.gridNode) {
|
|
|
+ targetGridList.push(grid);
|
|
|
+ targetPos.add(grid.gridNode.getWorldPosition());
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 计算平均位置
|
|
|
- if (validGridCount > 0) {
|
|
|
- centerPos.x /= validGridCount;
|
|
|
- centerPos.y /= validGridCount;
|
|
|
- centerPos.z /= validGridCount;
|
|
|
- } else {
|
|
|
- // 如果没有有效网格,使用第一个网格的位置作为后备
|
|
|
- const targetGridData = this.editingData.gridList[0];
|
|
|
- if (targetGridData && targetGridData.gridNode) {
|
|
|
- centerPos = targetGridData.gridNode.getWorldPosition();
|
|
|
- }
|
|
|
+ console.log("this.gridList", this.gridList);
|
|
|
+ if (targetGridList.length > 0) {
|
|
|
+ targetPos.x /= targetGridList.length;
|
|
|
+ targetPos.y /= targetGridList.length;
|
|
|
+ }
|
|
|
+ // 创建动画序列
|
|
|
+ const tweenSequence = tween(brickNode);
|
|
|
+
|
|
|
+ // 1. 先执行旋转动画(如果需要)
|
|
|
+ if (placement.rotateCount > 0 && brickData.rotateFlag) {
|
|
|
+ tweenSequence.to(0.3, { angle: currentDeg });
|
|
|
}
|
|
|
|
|
|
- // 添加到移动节点里进行移动
|
|
|
- const originPos = brickData.brickNode.getWorldPosition()
|
|
|
- brickData.brickNode.setParent(this.moveNode)
|
|
|
- brickData.brickNode.setWorldPosition(originPos)
|
|
|
+ // 2. 再执行移动动画
|
|
|
+ tweenSequence.to(0.5, { worldPosition: targetPos });
|
|
|
+
|
|
|
+ // 3. 动画完成后更新网格和执行后续操作
|
|
|
+ tweenSequence.call(() => {
|
|
|
+ // 放置方块到网格
|
|
|
+ targetGridList.forEach(grid => {
|
|
|
+ grid.status = CellState.FILLED;
|
|
|
+ grid.type = brickData.type;
|
|
|
+ //这是对的
|
|
|
+ console.log(">>>>>>>>>>>>>>>>>", grid);
|
|
|
+ this.generateGrid(grid);
|
|
|
+ });
|
|
|
|
|
|
+ // 显示得分动画
|
|
|
+ this.showScoreAnimation(targetPos, targetGridList.length);
|
|
|
|
|
|
- // 使用动画移动到目标位置--这里的最终放置有问题
|
|
|
- tween(brickData.brickNode)
|
|
|
- .to(2 / num, { worldPosition: centerPos })
|
|
|
- .call(() => {
|
|
|
- // 动画完成后修改格子状态
|
|
|
- this.editingData.gridList.forEach((gridData) => {
|
|
|
- gridData.status = CellState.FILLED
|
|
|
- gridData.type = this.editingData.brickData.type
|
|
|
- this.generateGrid(gridData)
|
|
|
- })
|
|
|
+ // 标记需要重置消除计数器
|
|
|
+ this.shouldResetEliminateCount = true;
|
|
|
+
|
|
|
+ // 销毁方块节点
|
|
|
+ brickNode.destroy();
|
|
|
+
|
|
|
+ // 添加新方块到待选区
|
|
|
+ this.addBrick(brickData.index);
|
|
|
+
|
|
|
+ // 检查消除
|
|
|
+ this.scheduleOnce(() => {
|
|
|
+ this.gridEliminate().then((hasElimination) => {
|
|
|
+ // 如果没有消除,确保下次消除会重置计数
|
|
|
+ if (!hasElimination) {
|
|
|
+ this.shouldResetEliminateCount = true;
|
|
|
+ }
|
|
|
|
|
|
- // 销毁方块
|
|
|
- this.editingData.brickData.brickNode.destroy()
|
|
|
-
|
|
|
- // 添加新方块
|
|
|
- this.addBrick(this.editingData.brickData.index)
|
|
|
-
|
|
|
- // 检查消除和游戏状态
|
|
|
- this.gridEliminate().then(() => {
|
|
|
- this.prompt(false).then((value: unknown) => {
|
|
|
- const promptFlag = value as boolean;
|
|
|
- if (!promptFlag) {
|
|
|
- this.autoState = false
|
|
|
- this.gameOver()
|
|
|
- } else if (this.autoState) {
|
|
|
- // 继续自动放置
|
|
|
- this.scheduleOnce(() => {
|
|
|
- this.executeAutoPlace()
|
|
|
- }, 0.3)
|
|
|
+ // 检查游戏是否结束
|
|
|
+ this.prompt(false).then(canContinue => {
|
|
|
+ if (!canContinue) {
|
|
|
+ this.gameOver();
|
|
|
+ this.stopAutoMode();
|
|
|
}
|
|
|
- this.editingFlag = false
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- .start()
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }, 0.1);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 应用二倍速度
|
|
|
+ if (this._isDoubleSpeed) {
|
|
|
+ tweenSequence.speedScale = this._doubleNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 启动动画
|
|
|
+ tweenSequence.start();
|
|
|
}
|
|
|
|
|
|
|