|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-22 18:11:43
|
|
|
+ * @LastEditTime: 2025-04-22 19:37:03
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -242,9 +242,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.guideNode.active = false;
|
|
|
this.initGrid();
|
|
|
}
|
|
|
-
|
|
|
//更新福利点
|
|
|
this.updateWelfarePoint();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -316,7 +316,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
const num = smc.account.AccountModel.goldCoin
|
|
|
this.lab_goldNum.string = `${num + 1}`;
|
|
|
this.gameState = GameState.PLAYING;
|
|
|
-
|
|
|
this.randomList = this.getRandomUniqueInts();
|
|
|
}
|
|
|
|
|
|
@@ -377,12 +376,34 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
setupGuideStep(step: number) {
|
|
|
- this.clearAllGuideGrids()
|
|
|
this.gameState = GameState.PLAYING;
|
|
|
this.operateFlag = true
|
|
|
this.bricksList.length = 0
|
|
|
this.brickNode.destroyAllChildren();
|
|
|
|
|
|
+ for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
|
|
|
+ const currentRow: GridData[] = [];
|
|
|
+ this.gridList.push(currentRow);
|
|
|
+ for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
|
|
|
+ const gridData = this.createGridData(rowIndex, columnIndex);
|
|
|
+ currentRow.push(gridData);
|
|
|
+ this.createGridNode(gridData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 初始化格子状态
|
|
|
+ for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
|
|
|
+ for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
|
|
|
+ this.gridList[rowIndex][columnIndex].status = CellState.EMPTY
|
|
|
+ this.generateGrid(this.gridList[rowIndex][columnIndex])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 清除旋转数据
|
|
|
+ if (this.rotateNode) {
|
|
|
+ this.rotateNode.destroyAllChildren();
|
|
|
+ }
|
|
|
+ this.touchStartPos.set(Vec2.ZERO)
|
|
|
+ this.clearAllGuideGrids()
|
|
|
+
|
|
|
this.guideStep = step
|
|
|
const tips_node = this.guideNode.getChildByPath("tips/lab_tips");
|
|
|
if (tips_node) {
|
|
|
@@ -393,8 +414,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
if (step === 1) {
|
|
|
-
|
|
|
-
|
|
|
const emptyIndex = Math.floor(this.cols / 2)
|
|
|
for (let c = 0; c < this.cols; c++) {
|
|
|
if (c !== emptyIndex) {
|
|
|
@@ -503,9 +522,11 @@ export class EliminateViewComp extends CCComp {
|
|
|
type: colorIndex,
|
|
|
rotateNode: new Node(),
|
|
|
}
|
|
|
+ console.log("brickKey>>>>>>>>>>", brickKey, colorIndex)
|
|
|
const node = this.generateBrick(brickKey, colorIndex)
|
|
|
- this.brickNode.addChild(node);
|
|
|
|
|
|
+
|
|
|
+ this.brickNode.addChild(node);
|
|
|
const transform = this.brickNode.getComponent(UITransform);
|
|
|
if (transform) {
|
|
|
const midX = transform.width / 2;
|
|
|
@@ -751,8 +772,11 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
const brickKey = Object.keys(this.brickConfig['bricks'])[randomRangeInt(0, Object.keys(this.brickConfig['bricks']).length)];
|
|
|
const brickConfig = this.brickConfig['bricks'][brickKey];
|
|
|
+
|
|
|
const num = Math.floor(Math.random() * this.randomList.length);
|
|
|
+
|
|
|
const randomIndex = this.randomList[num];
|
|
|
+ // const randomIndex = this.randomList[0];
|
|
|
// 生成方块
|
|
|
const brickData: BrickData = {
|
|
|
index,
|