|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-24 18:11:32
|
|
|
|
|
|
|
+ * @LastEditTime: 2025-04-25 11:12:46
|
|
|
* @Description: 消除游戏主场景
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, v3, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, v3, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
@@ -18,6 +18,8 @@ import { smc } from "../common/SingletonModuleComp";
|
|
|
import { Format } from "../utils/Format";
|
|
import { Format } from "../utils/Format";
|
|
|
import { DCHandler } from "../common/manager/DCHandler";
|
|
import { DCHandler } from "../common/manager/DCHandler";
|
|
|
import { Tween } from "cc";
|
|
import { Tween } from "cc";
|
|
|
|
|
+import { AD_TYPE } from "../common/config/GameDefine";
|
|
|
|
|
+import { ADHandler } from "../common/manager/ADHandler";
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
@@ -485,16 +487,15 @@ export class EliminateViewComp extends CCComp {
|
|
|
type: colorIndex,
|
|
type: colorIndex,
|
|
|
rotateNode: new Node(),
|
|
rotateNode: new Node(),
|
|
|
}
|
|
}
|
|
|
- console.log("brickKey>>>>>>>>>>", brickKey, colorIndex)
|
|
|
|
|
- const node = this.generateBrick(brickKey, colorIndex)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const node = this.generateBrick(brickKey, colorIndex);
|
|
|
this.brickNode.addChild(node);
|
|
this.brickNode.addChild(node);
|
|
|
const transform = this.brickNode.getComponent(UITransform);
|
|
const transform = this.brickNode.getComponent(UITransform);
|
|
|
if (transform) {
|
|
if (transform) {
|
|
|
const midX = transform.width / 2;
|
|
const midX = transform.width / 2;
|
|
|
node.setPosition(0, 0);
|
|
node.setPosition(0, 0);
|
|
|
brickData.brickNode = node
|
|
brickData.brickNode = node
|
|
|
|
|
+ brickData.brickNode.scale_x = 0.6;
|
|
|
|
|
+ brickData.brickNode.scale_y = 0.6;
|
|
|
brickData.brickInitPos = node.getWorldPosition()
|
|
brickData.brickInitPos = node.getWorldPosition()
|
|
|
this.bricksList.push(brickData)
|
|
this.bricksList.push(brickData)
|
|
|
this.brickAddEvent(brickData)
|
|
this.brickAddEvent(brickData)
|
|
@@ -1125,7 +1126,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
}, this);
|
|
}, this);
|
|
|
// 触摸结束或取消事件
|
|
// 触摸结束或取消事件
|
|
|
const touchEndHandler = (event: EventTouch) => {
|
|
const touchEndHandler = (event: EventTouch) => {
|
|
|
- if (this.adShowingFlag || !this.operateFlag) return
|
|
|
|
|
|
|
+ if (!this.operateFlag) return
|
|
|
this.operateFlag = false
|
|
this.operateFlag = false
|
|
|
// 单击旋转
|
|
// 单击旋转
|
|
|
if (!this.editingData.brickData) {
|
|
if (!this.editingData.brickData) {
|
|
@@ -1195,7 +1196,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
|
|
const simulateResult = this.gridEliminateCheck(tempGridList)
|
|
const simulateResult = this.gridEliminateCheck(tempGridList)
|
|
|
const canEliminate = simulateResult.gridEliminateList.length > 0
|
|
const canEliminate = simulateResult.gridEliminateList.length > 0
|
|
|
-
|
|
|
|
|
|
|
+ //如果不能消除,则将方块返回原位置
|
|
|
if (!canEliminate) {
|
|
if (!canEliminate) {
|
|
|
this.bricksList.push(brickData);
|
|
this.bricksList.push(brickData);
|
|
|
if (brickData.brickNode) {
|
|
if (brickData.brickNode) {
|
|
@@ -1238,6 +1239,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
centerPos.y /= validGridCount;
|
|
centerPos.y /= validGridCount;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 显示放置得分动画(显示一次,包含总格子数)
|
|
|
|
|
+ this.showScoreAnimation(centerPos, placedGridCount);
|
|
|
// 放置方块到网格
|
|
// 放置方块到网格
|
|
|
this.editingData.gridList.forEach(grid => {
|
|
this.editingData.gridList.forEach(grid => {
|
|
|
grid.status = CellState.FILLED;
|
|
grid.status = CellState.FILLED;
|
|
@@ -1245,16 +1248,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.generateGrid(grid);
|
|
this.generateGrid(grid);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 显示放置得分动画(显示一次,包含总格子数)
|
|
|
|
|
- this.showScoreAnimation(centerPos, placedGridCount);
|
|
|
|
|
- //这里要计算分数,并且计算能消除的分数,然后增加分,这才对
|
|
|
|
|
-
|
|
|
|
|
// 标记需要重置消除计数器
|
|
// 标记需要重置消除计数器
|
|
|
this.shouldResetEliminateCount = true;
|
|
this.shouldResetEliminateCount = true;
|
|
|
-
|
|
|
|
|
- // 销毁方块节点
|
|
|
|
|
brickNode.destroy();
|
|
brickNode.destroy();
|
|
|
- // 添加新方块到待选区
|
|
|
|
|
this.addBrick(this.editingData.brickData.index);
|
|
this.addBrick(this.editingData.brickData.index);
|
|
|
|
|
|
|
|
// 检查消除
|
|
// 检查消除
|
|
@@ -1264,7 +1260,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (!hasElimination) {
|
|
if (!hasElimination) {
|
|
|
this.shouldResetEliminateCount = true;
|
|
this.shouldResetEliminateCount = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
this.operateFlag = true;
|
|
this.operateFlag = true;
|
|
|
//新手引导
|
|
//新手引导
|
|
|
if (this.isGuideMode) {
|
|
if (this.isGuideMode) {
|
|
@@ -1280,7 +1275,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
}
|
|
|
}, 0.3)
|
|
}, 0.3)
|
|
|
} else {
|
|
} else {
|
|
|
-
|
|
|
|
|
// 检查游戏是否结束
|
|
// 检查游戏是否结束
|
|
|
this.prompt(false).then(canContinue => {
|
|
this.prompt(false).then(canContinue => {
|
|
|
if (!canContinue) {
|
|
if (!canContinue) {
|
|
@@ -1540,9 +1534,14 @@ export class EliminateViewComp extends CCComp {
|
|
|
// oops.gui.open(UIID.DoubleSpeed);
|
|
// oops.gui.open(UIID.DoubleSpeed);
|
|
|
//如果有自动就暂停自动
|
|
//如果有自动就暂停自动
|
|
|
this.gameState = GameState.PAUSED;
|
|
this.gameState = GameState.PAUSED;
|
|
|
- console.log("弹出翻倍广告");
|
|
|
|
|
- ServerHandler.inst.getDoubleSurprise();
|
|
|
|
|
- //弹出广告
|
|
|
|
|
|
|
+ if (smc.game.GameModel.skipAdConfig != 1) {
|
|
|
|
|
+ if (smc.game.GameModel.skipAdCount % smc.game.GameModel.skipAdConfig == 0) {
|
|
|
|
|
+ smc.game.GameModel.viewType = "double_reward";
|
|
|
|
|
+ ADHandler.inst.showAd(AD_TYPE.Double_Receive);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ServerHandler.inst.getDoubleSurprise();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1553,7 +1552,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //消除检查
|
|
|
gridEliminateCheck(gridList: GridData[][]) {
|
|
gridEliminateCheck(gridList: GridData[][]) {
|
|
|
const gridEliminateList: GridData[] = []
|
|
const gridEliminateList: GridData[] = []
|
|
|
let eliminateRowNum = 0
|
|
let eliminateRowNum = 0
|
|
@@ -1888,17 +1887,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
|
|
gameOver() {
|
|
gameOver() {
|
|
|
this.gameState = GameState.GAME_OVER
|
|
this.gameState = GameState.GAME_OVER
|
|
|
- this.setGameState(GameState.GAME_OVER)
|
|
|
|
|
- console.log("游戏结束")
|
|
|
|
|
smc.game.GameModel.curScore = this.score;
|
|
smc.game.GameModel.curScore = this.score;
|
|
|
oops.gui.open(UIID.GameOver);
|
|
oops.gui.open(UIID.GameOver);
|
|
|
- //如果有自动就要关闭自动
|
|
|
|
|
- if (this.autoFunction) {
|
|
|
|
|
- this.unschedule(this.autoFunction);
|
|
|
|
|
- this.autoFunction = null;
|
|
|
|
|
- this.initButtonState(false);
|
|
|
|
|
- this.autoState = false;
|
|
|
|
|
- }
|
|
|
|
|
const curLevel = smc.account.AccountModel.curLevel;
|
|
const curLevel = smc.account.AccountModel.curLevel;
|
|
|
DCHandler.inst.reportData(3000501, curLevel);
|
|
DCHandler.inst.reportData(3000501, curLevel);
|
|
|
}
|
|
}
|
|
@@ -1909,7 +1899,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.lab_score.string = this.score.toString();
|
|
this.lab_score.string = this.score.toString();
|
|
|
if (this.score >= this.targetScore) {
|
|
if (this.score >= this.targetScore) {
|
|
|
this.gameState = GameState.GAME_PASS;
|
|
this.gameState = GameState.GAME_PASS;
|
|
|
- this.setGameState(this.gameState);
|
|
|
|
|
//弹出通关奖励界面
|
|
//弹出通关奖励界面
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
ServerHandler.inst.getGameAwardInfo();
|
|
ServerHandler.inst.getGameAwardInfo();
|
|
@@ -1931,25 +1920,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
children.forEach(node => node.destroy());
|
|
children.forEach(node => node.destroy());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private setGameState(state: GameState) {
|
|
|
|
|
- this.gameState = state;
|
|
|
|
|
- switch (state) {
|
|
|
|
|
- case GameState.READY:
|
|
|
|
|
- break;
|
|
|
|
|
- case GameState.PLAYING:
|
|
|
|
|
- break;
|
|
|
|
|
- case GameState.PAUSED:
|
|
|
|
|
- break;
|
|
|
|
|
- case GameState.GAME_OVER:
|
|
|
|
|
- //打开游戏结束界面
|
|
|
|
|
- this.autoState = false;
|
|
|
|
|
- this.adShowingFlag = false;
|
|
|
|
|
- //自动按钮改为手动
|
|
|
|
|
- this.initButtonState(false);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
//========================打开其他界面和按钮逻辑=======================
|
|
//========================打开其他界面和按钮逻辑=======================
|
|
|
|
|
|
|
@@ -1968,29 +1938,26 @@ export class EliminateViewComp extends CCComp {
|
|
|
//左边微信按钮
|
|
//左边微信按钮
|
|
|
private btn_withdraw() {
|
|
private btn_withdraw() {
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
ServerHandler.inst.getWechatTxInfo();
|
|
ServerHandler.inst.getWechatTxInfo();
|
|
|
DCHandler.inst.reportData(3000006);
|
|
DCHandler.inst.reportData(3000006);
|
|
|
} else {
|
|
} else {
|
|
|
oops.gui.open(UIID.WechatWithdraw);
|
|
oops.gui.open(UIID.WechatWithdraw);
|
|
|
}
|
|
}
|
|
|
- this.gameState = GameState.PAUSED;
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//顶部红包按钮
|
|
//顶部红包按钮
|
|
|
private btn_award() {
|
|
private btn_award() {
|
|
|
- //oops.gui.open(UIID.RedPacketWithdraw);
|
|
|
|
|
-
|
|
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
ServerHandler.inst.getHbTxInfo();
|
|
ServerHandler.inst.getHbTxInfo();
|
|
|
DCHandler.inst.reportData(3000007);
|
|
DCHandler.inst.reportData(3000007);
|
|
|
} else {
|
|
} else {
|
|
|
oops.gui.open(UIID.RedPacketWithdraw);
|
|
oops.gui.open(UIID.RedPacketWithdraw);
|
|
|
}
|
|
}
|
|
|
- this.gameState = GameState.PAUSED;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //二倍速按钮
|
|
|
|
|
|
|
+ //二倍速按钮继续
|
|
|
private btn_double() {
|
|
private btn_double() {
|
|
|
// oops.gui.open(UIID.DoubleSpeed);
|
|
// oops.gui.open(UIID.DoubleSpeed);
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
@@ -2003,7 +1970,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- //自动放置
|
|
|
|
|
|
|
+ //自动放置,不让点击方块
|
|
|
private btn_auto() {
|
|
private btn_auto() {
|
|
|
this.autoState = !this.autoState;
|
|
this.autoState = !this.autoState;
|
|
|
this.initButtonState(this.autoState);
|
|
this.initButtonState(this.autoState);
|
|
@@ -2017,6 +1984,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
//关闭
|
|
//关闭
|
|
|
if (this.autoFunction) {
|
|
if (this.autoFunction) {
|
|
|
DCHandler.inst.reportData(3000009);
|
|
DCHandler.inst.reportData(3000009);
|
|
|
|
|
+ this.operateFlag = true;
|
|
|
this.unschedule(this.autoFunction);
|
|
this.unschedule(this.autoFunction);
|
|
|
this.autoFunction = null;
|
|
this.autoFunction = null;
|
|
|
this.initButtonState(false);
|
|
this.initButtonState(false);
|
|
@@ -2029,7 +1997,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
|
|
// 执行自动放置
|
|
// 执行自动放置
|
|
|
executeAutoPlace() {
|
|
executeAutoPlace() {
|
|
|
- if (!this.autoState || this.gameState !== GameState.PLAYING || this.adShowingFlag) {
|
|
|
|
|
|
|
+ if (!this.autoState || this.gameState !== GameState.PLAYING) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
const bestPlacement = this.findBestPlacement()
|
|
const bestPlacement = this.findBestPlacement()
|
|
@@ -2041,6 +2009,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
// 执行放置
|
|
// 执行放置
|
|
|
|
|
+ this.operateFlag = false;
|
|
|
this.placeBrickAtPosition(bestPlacement)
|
|
this.placeBrickAtPosition(bestPlacement)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2224,8 +2193,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.doubleNum = 2;
|
|
this.doubleNum = 2;
|
|
|
//改变按钮时间
|
|
//改变按钮时间
|
|
|
// let time = smc.game.GameModel.doubleSpeedTime;
|
|
// let time = smc.game.GameModel.doubleSpeedTime;
|
|
|
- // this.doubleSpeedTime = this.doubleSpeedTime + smc.game.GameModel.doubleSpeedTime;
|
|
|
|
|
- this.doubleSpeedTime = 20;
|
|
|
|
|
|
|
+ this.doubleSpeedTime = this.doubleSpeedTime + smc.game.GameModel.doubleSpeedTime;
|
|
|
|
|
+ // this.doubleSpeedTime = 60;
|
|
|
if (this.doubleSpeedTime <= 0) {
|
|
if (this.doubleSpeedTime <= 0) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -2236,7 +2205,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.initButtonState(this.autoState);
|
|
this.initButtonState(this.autoState);
|
|
|
}
|
|
}
|
|
|
this.callback = function () {
|
|
this.callback = function () {
|
|
|
- if (!this.adShowingFlag && this.gameState === GameState.PLAYING && this.autoState) {
|
|
|
|
|
|
|
+ if (this.gameState === GameState.PLAYING && this.autoState) {
|
|
|
this.doubleSpeedTime--
|
|
this.doubleSpeedTime--
|
|
|
this.autoMoveTime = 0.25;
|
|
this.autoMoveTime = 0.25;
|
|
|
//修改剩余时间,秒格式化成时分10:59
|
|
//修改剩余时间,秒格式化成时分10:59
|