|
|
@@ -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 19:37:03
|
|
|
+ * @LastEditTime: 2025-04-23 11:13:27
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -236,6 +236,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.initData();
|
|
|
this.setData();
|
|
|
this.addEventList();
|
|
|
+ // smc.account.AccountModel.curLevel = 1;
|
|
|
if (this.guideStep === 0 && smc.account.AccountModel.curLevel == 1) {
|
|
|
this.startGuideMode()
|
|
|
} else {
|
|
|
@@ -256,6 +257,19 @@ export class EliminateViewComp extends CCComp {
|
|
|
// oops.message.on(GameEvent.Resurrection, this.onResurrection, this);
|
|
|
oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
|
|
|
oops.message.on(GameEvent.StartAutoGame, this.startAutoGame, this);
|
|
|
+ oops.message.on(GameEvent.updateGameState, this.updateGameState, this);
|
|
|
+ }
|
|
|
+
|
|
|
+ updateGameState(event: string, args: string) {
|
|
|
+ console.log("更新游戏状态", args);
|
|
|
+ switch (args) {
|
|
|
+ case "paused":
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
+ break;
|
|
|
+ case "playing":
|
|
|
+ this.gameState = GameState.PLAYING;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -302,11 +316,16 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
//设置数据
|
|
|
setData() {
|
|
|
- // this.eliminateInterval = smc.game.GameModel.curLevelConfig.eliminateScope;
|
|
|
+ if (smc.game.GameModel.curLevelConfig.eliminateScope) {
|
|
|
+ this.eliminateInterval = smc.game.GameModel.curLevelConfig.eliminateScope || [];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
this.score = smc.game.GameModel.curScore;
|
|
|
this.money = smc.account.AccountModel.wxCoin;
|
|
|
this.cash = smc.account.AccountModel.hbCoin;
|
|
|
- this.targetScore = smc.game.GameModel.targetScore;
|
|
|
+ // this.targetScore = smc.game.GameModel.targetScore;
|
|
|
+ this.targetScore = 200;
|
|
|
this.popupType = smc.game.GameModel.popupType;
|
|
|
this.lab_score.string = this.score.toString();
|
|
|
this.lab_wxCoin.string = Format.formatWxCoin(this.money);
|
|
|
@@ -361,26 +380,11 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //复活,分数不清零
|
|
|
- onResurrection() {
|
|
|
- console.log("复活游戏,分数不清零");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
startGuideMode() {
|
|
|
this.isGuideMode = true
|
|
|
this.guideStep = 1
|
|
|
this.guideNode.active = true;
|
|
|
- this.setupGuideStep(this.guideStep)
|
|
|
- }
|
|
|
-
|
|
|
- setupGuideStep(step: number) {
|
|
|
- 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);
|
|
|
@@ -402,6 +406,14 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.rotateNode.destroyAllChildren();
|
|
|
}
|
|
|
this.touchStartPos.set(Vec2.ZERO)
|
|
|
+ this.setupGuideStep(this.guideStep)
|
|
|
+ }
|
|
|
+
|
|
|
+ setupGuideStep(step: number) {
|
|
|
+ this.gameState = GameState.PLAYING;
|
|
|
+ this.operateFlag = true
|
|
|
+ this.bricksList.length = 0
|
|
|
+ this.brickNode.destroyAllChildren();
|
|
|
this.clearAllGuideGrids()
|
|
|
|
|
|
this.guideStep = step
|
|
|
@@ -426,34 +438,33 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.createGuideBrick([{ row: 0, column: 0 }], "Brick1", 1, 1)
|
|
|
}
|
|
|
else if (step === 2) {
|
|
|
- const emptyRow = this.rows - 1
|
|
|
for (let r = 0; r < this.rows; r++) {
|
|
|
- if (r !== emptyRow) {
|
|
|
- const g = this.gridList[r][0]
|
|
|
+ if (r !== 0) {
|
|
|
+ const g = this.gridList[r][3]
|
|
|
g.status = 1
|
|
|
g.type = 1;
|
|
|
this.generateGrid(g)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
this.createGuideBrick([{ row: 0, column: 0 }], "Brick1", 1, 1)
|
|
|
}
|
|
|
else if (step === 3) {
|
|
|
// 填满前两列,除去 [2][0] 这个位置,制造一个L型缺口
|
|
|
for (let r = 0; r < this.rows; r++) {
|
|
|
- for (let c = 0; c < 2; c++) {
|
|
|
- if (r === 2 && c === 0) continue
|
|
|
- if (r === 1 && c === 0) continue
|
|
|
- if (r === 3 && c === 0) continue
|
|
|
- if (r === 2 && c === 1) continue
|
|
|
- if (r === 1 && c === 1) continue
|
|
|
- if (r === 3 && c === 1) continue
|
|
|
+ for (let c = 3; c < 5; c++) {
|
|
|
+ if (r === 2 && c === 3) continue
|
|
|
+ if (r === 1 && c === 3) continue
|
|
|
+ if (r === 3 && c === 3) continue
|
|
|
+ if (r === 2 && c === 4) continue
|
|
|
+ if (r === 1 && c === 4) continue
|
|
|
+ if (r === 3 && c === 4) continue
|
|
|
const g = this.gridList[r][c]
|
|
|
g.status = 1
|
|
|
g.type = 1;
|
|
|
this.generateGrid(g)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 创建一个L型方块,引导玩家旋转后放置
|
|
|
this.createGuideBrick([
|
|
|
{ row: 0, column: 0 },
|