|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-16 14:58:52
|
|
|
+ * @LastEditTime: 2025-04-16 16:30:17
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -196,16 +196,27 @@ export class EliminateViewComp extends CCComp {
|
|
|
private totalEliminationCount: number = 0; // 总消除次数(包括行和列)
|
|
|
private currentCombo: number = 0; // 当前连击次数
|
|
|
|
|
|
+
|
|
|
+ //新手引导
|
|
|
+ private isGuideMode = false;
|
|
|
+ private guideStep = 0;
|
|
|
+
|
|
|
/** 视图层逻辑代码分离演示 */
|
|
|
async start() {
|
|
|
// const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
|
|
this.setButton();
|
|
|
this.initButtonState(false);
|
|
|
await this.loadConfig();
|
|
|
- this.initGrid();
|
|
|
this.initData();
|
|
|
this.setData();
|
|
|
this.addEventList();
|
|
|
+ this.initGrid();
|
|
|
+ // if (this.guideStep === 0) {
|
|
|
+ // this.startGuideMode()
|
|
|
+ // } else {
|
|
|
+ // this.initGrid();
|
|
|
+ // }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -215,6 +226,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
oops.message.on(GameEvent.openView, this.openView, this);
|
|
|
oops.message.on(GameEvent.showCoinAnimation, this.showCoinAnimation, this);
|
|
|
oops.message.on(GameEvent.Resurrection, this.onResurrection, this);
|
|
|
+ oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -269,8 +281,14 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.awardLb.string = this.cash.toString();
|
|
|
this.lab_taget.string = this.targetScore.toString();
|
|
|
this.lab_goldNum.string = smc.account.AccountModel.goldCoin.toString();
|
|
|
- console.log("目标分数>>>>>>", this.targetScore);
|
|
|
- console.log("金块>>>>>>>>>>", smc.account.AccountModel.goldCoin)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ updateCoin() {
|
|
|
+ this.money = smc.account.AccountModel.wxCoin;
|
|
|
+ this.cash = smc.account.AccountModel.hbCoin;
|
|
|
+ this.amountLb.string = this.money.toString();
|
|
|
+ this.awardLb.string = this.cash.toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -309,6 +327,144 @@ export class EliminateViewComp extends CCComp {
|
|
|
console.log("复活游戏,分数不清零");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ startGuideMode() {
|
|
|
+ this.isGuideMode = true
|
|
|
+ this.guideStep = 1
|
|
|
+ this.setupGuideStep(this.guideStep)
|
|
|
+ }
|
|
|
+
|
|
|
+ setupGuideStep(step: number) {
|
|
|
+ this.clearAllGuideGrids()
|
|
|
+ this.bricksList.length = 0
|
|
|
+ this.brickNode.destroyAllChildren();
|
|
|
+
|
|
|
+ this.guideStep = step
|
|
|
+
|
|
|
+ if (step === 1) {
|
|
|
+ const emptyIndex = Math.floor(this.cols / 2)
|
|
|
+ for (let c = 0; c < this.cols; c++) {
|
|
|
+ if (c !== emptyIndex) {
|
|
|
+ const g = this.gridList[0][c]
|
|
|
+ g.status = 1
|
|
|
+ g.type = 1;
|
|
|
+ this.generateGrid(g)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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]
|
|
|
+ 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 // 留一个空位用于放置旋转后的L型砖块
|
|
|
+ if (r === 2 && c === 1) continue // 留一个空位用于放置旋转后的L型砖块
|
|
|
+ if (r === 1 && c === 1) continue // 留一个空位用于放置旋转后的L型砖块
|
|
|
+ if (r === 3 && c === 1) continue // 留一个空位用于放置旋转后的L型砖块
|
|
|
+ const g = this.gridList[r][c]
|
|
|
+ g.status = 1
|
|
|
+ g.type = 1;
|
|
|
+ this.generateGrid(g)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建一个L型方块,引导玩家旋转后放置
|
|
|
+ this.createGuideBrick([
|
|
|
+ { row: 0, column: 0 },
|
|
|
+ { row: 0, column: -1 },
|
|
|
+ { row: 0, column: 1 },
|
|
|
+ { row: 1, column: 0 }
|
|
|
+ ], "BrickT", 1, 1, true) //这要双II
|
|
|
+ }
|
|
|
+ else if (step === 4) {
|
|
|
+ const centerRow = Math.floor(this.rows / 2);
|
|
|
+ const centerCol = Math.floor(this.cols / 2);
|
|
|
+
|
|
|
+ // 遍历整个网格
|
|
|
+ for (let r = 0; r < this.rows; r++) {
|
|
|
+ for (let c = 0; c < this.cols; c++) {
|
|
|
+ const inCenter =
|
|
|
+ r >= centerRow && r <= centerRow + 1 &&
|
|
|
+ c >= centerCol && c <= centerCol + 1;
|
|
|
+
|
|
|
+ const isCross =
|
|
|
+ r === centerRow || r === centerRow + 1 || // 中间两行
|
|
|
+ c === centerCol || c === centerCol + 1; // 中间两列
|
|
|
+
|
|
|
+ if (isCross && !inCenter) {
|
|
|
+ const g = this.gridList[r][c];
|
|
|
+ g.status = 1;
|
|
|
+ g.type = 1;
|
|
|
+ this.generateGrid(g);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.createGuideBrick([
|
|
|
+ { row: 0, column: 0 },
|
|
|
+ { row: 0, column: 1 },
|
|
|
+ { row: 1, column: 0 },
|
|
|
+ { row: 1, column: 1 }
|
|
|
+ ], "BrickO", 1, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ clearAllGuideGrids() {
|
|
|
+ for (let row = 0; row < this.rows; row++) {
|
|
|
+ for (let col = 0; col < this.cols; col++) {
|
|
|
+ const grid = this.gridList[row][col]
|
|
|
+ grid.status = 0;
|
|
|
+ grid.type = 0;
|
|
|
+ this.generateGrid(grid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 引导砖块保持底部中间生成
|
|
|
+ createGuideBrick(gridConfig: GridConfigData[], brickKey: string, colorIndex: number, index: number, rotateFlag = false) {
|
|
|
+ const brickData = {
|
|
|
+ index,
|
|
|
+ brickKey: brickKey,
|
|
|
+ rotateFlag,
|
|
|
+ gridConfig,
|
|
|
+ deg: 0,
|
|
|
+ brickNode: new Node(),
|
|
|
+ gridColorKey: "colorKey",
|
|
|
+ brickInitPos: new Vec3(),
|
|
|
+ type: 0,
|
|
|
+ rotateNode: null,
|
|
|
+ }
|
|
|
+ const node = this.generateBrick(brickKey, colorIndex)
|
|
|
+ this.brickNode.addChild(node);
|
|
|
+
|
|
|
+ const transform = this.brickNode.getComponent(UITransform);
|
|
|
+ if (transform) {
|
|
|
+ const midX = transform.width / 2;
|
|
|
+ node.setPosition(midX, 0);
|
|
|
+ brickData.brickNode = node
|
|
|
+ brickData.brickInitPos = node.getWorldPosition()
|
|
|
+ this.bricksList.push(brickData)
|
|
|
+ this.brickAddEvent(brickData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//显示金币动画 --是否只计算红包
|
|
|
showCoinAnimation(event: string, args: string) {
|
|
|
//计算中间的坐标就好
|
|
|
@@ -368,7 +524,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
private clearExistingGrids(): void {
|
|
|
this.gridList = [];
|
|
|
if (this.gridNode) {
|
|
|
- this.gridNode.children.forEach(node => node.destroy());
|
|
|
+ this.gridNode.destroyAllChildren();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1892,7 +2048,27 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ btn_text() {
|
|
|
+ const param = {
|
|
|
+ "ssid": "7308c662d2264b1a952d2690e585872e",
|
|
|
+ "props": {
|
|
|
+ "1004": 0,
|
|
|
+ "1005": 2786919,
|
|
|
+ "1006": 9,
|
|
|
+ "1007": 71,
|
|
|
+ "2001": 2,
|
|
|
+ "8001": 20,
|
|
|
+ "9001": 0
|
|
|
+ },
|
|
|
+ "changes": {
|
|
|
+ "1004": -200000,
|
|
|
+ "8001": 20
|
|
|
+ },
|
|
|
+ "transferStatus": 1,
|
|
|
+ "outTransferNo": "2504161109911229182337024"
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ let str = JSON.stringify(param);
|
|
|
+ ServerHandler.inst.onHbReward(str);
|
|
|
+ }
|
|
|
}
|