|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-27 10:46:23
|
|
|
+ * @LastEditTime: 2025-04-27 15:21:12
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, v3, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -20,6 +20,7 @@ import { DCHandler } from "../common/manager/DCHandler";
|
|
|
import { Tween } from "cc";
|
|
|
import { AD_TYPE } from "../common/config/GameDefine";
|
|
|
import { ADHandler } from "../common/manager/ADHandler";
|
|
|
+import { director } from "cc";
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -193,6 +194,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
//旋转容错
|
|
|
rotateFaultTolerant = 50;
|
|
|
|
|
|
+ //游戏暂停状态
|
|
|
+ private gamePause: boolean = false;
|
|
|
+
|
|
|
isAutoMode: boolean = false;
|
|
|
autoModeInterval: number = 1 // 自动模式的间隔时间(秒)
|
|
|
autoModeTimer: number = 0 // 自动模式计时器
|
|
|
@@ -279,6 +283,8 @@ export class EliminateViewComp extends CCComp {
|
|
|
oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
|
|
|
oops.message.on(GameEvent.StartAutoGame, this.startAutoGame, this);
|
|
|
oops.message.on(GameEvent.updateGameState, this.updateGameState, this);
|
|
|
+ oops.message.on(GameEvent.pauseGame, this.pauseGame, this);
|
|
|
+ oops.message.on(GameEvent.resumeGame, this.resumeGame, this);
|
|
|
}
|
|
|
|
|
|
updateGameState(event: string, args: string) {
|
|
|
@@ -295,7 +301,15 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ pauseGame() {
|
|
|
+ this.gamePause = true;
|
|
|
+ director.pause();
|
|
|
+ }
|
|
|
|
|
|
+ resumeGame() {
|
|
|
+ this.gamePause = false;
|
|
|
+ director.resume();
|
|
|
+ }
|
|
|
|
|
|
//初始化网格
|
|
|
private initGrid() {
|
|
|
@@ -685,7 +699,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.redPacketPrefab,
|
|
|
lastPos,
|
|
|
this.lab_hbCoin.node.getWorldPosition(),
|
|
|
- 5,
|
|
|
+ 2,
|
|
|
() => {
|
|
|
// 显示红包分数增加动画
|
|
|
this.showRedPacketScoreAnimation();
|
|
|
@@ -699,7 +713,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.coinPrefab,
|
|
|
lastPos,
|
|
|
this.lab_wxCoin.node.getWorldPosition(),
|
|
|
- score,
|
|
|
+ 2,
|
|
|
() => {
|
|
|
// 显示微信分数增加动画
|
|
|
this.showWechatScoreAnimation();
|
|
|
@@ -1261,11 +1275,15 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
this.operateFlag = true;
|
|
|
//新手引导
|
|
|
+ console.log("消除返回", this.isGuideMode);
|
|
|
+ console.log("新手引导", this.guideStep);
|
|
|
if (this.isGuideMode) {
|
|
|
this.scheduleOnce(() => {
|
|
|
if (this.guideStep < 4) {
|
|
|
+ console.log("新手引导", this.guideStep);
|
|
|
this.setupGuideStep(this.guideStep + 1)
|
|
|
} else {
|
|
|
+ console.log("新手引导结束");
|
|
|
this.isGuideMode = false;
|
|
|
this.guideNode.active = false;
|
|
|
Tween.stopAllByTarget(this.guideFinger);
|
|
|
@@ -1472,7 +1490,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
.start();
|
|
|
}
|
|
|
|
|
|
- // 修改 gridEliminate 方法来显示消除次数
|
|
|
+ //
|
|
|
gridEliminate() {
|
|
|
return new Promise<boolean>((resolve, reject) => {
|
|
|
const d = this.gridEliminateCheck(this.gridList)
|
|
|
@@ -1537,7 +1555,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
this.score += score;
|
|
|
- this.updateGameScore();
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
ServerHandler.inst.updateEliminationReward({
|
|
|
count: totalEliminationsInThisRound,
|
|
|
@@ -1545,40 +1562,38 @@ export class EliminateViewComp extends CCComp {
|
|
|
level: smc.account.AccountModel.curLevel,
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
if (DeviceUtil.isAndroid && DeviceUtil.isNative) {
|
|
|
- //需要欧安的是否通关了,当前通关了就不要弹了
|
|
|
- if (this.score >= this.targetScore) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.eliminateInterval.length > 0) {
|
|
|
- const minNum = this.eliminateInterval[0]
|
|
|
- const maxNum = this.eliminateInterval[1]
|
|
|
- if (minNum && maxNum) {
|
|
|
- const randomNum = randomRangeInt(minNum, maxNum + 1);
|
|
|
- //这个数可以被总消除次数整除那就可以弹广告
|
|
|
- if (this.eliminateTotal % randomNum === 0) {
|
|
|
- //如果有自动就暂停自动
|
|
|
- if (this.autoState) {
|
|
|
- this.gameState = GameState.PAUSED;
|
|
|
- }
|
|
|
- if (smc.game.GameModel.skipAdConfig != -1) {
|
|
|
- if (smc.game.GameModel.skipAdCount > 0 && smc.game.GameModel.skipAdCount % smc.game.GameModel.skipAdConfig == 0) {
|
|
|
- console.log("skipAdCount>>>>>>>>>>>>>>>", smc.game.GameModel.skipAdCount);
|
|
|
- console.log("skipAdConfig>>>>>>>>>>>>>>", smc.game.GameModel.skipAdConfig);
|
|
|
- smc.game.GameModel.viewType = "double_reward";
|
|
|
- ADHandler.inst.showAd(AD_TYPE.Double_Receive);
|
|
|
+ //需要欧知道是否通关了,当前通关了就不要弹了
|
|
|
+ if (this.score < this.targetScore) {
|
|
|
+ if (this.eliminateInterval.length > 0) {
|
|
|
+ const minNum = this.eliminateInterval[0]
|
|
|
+ const maxNum = this.eliminateInterval[1]
|
|
|
+ if (minNum && maxNum) {
|
|
|
+ const randomNum = randomRangeInt(minNum, maxNum + 1);
|
|
|
+ //这个数可以被总消除次数整除那就可以弹广告
|
|
|
+ if (this.eliminateTotal % randomNum === 0) {
|
|
|
+ //如果有自动就暂停自动
|
|
|
+ if (this.autoState) {
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
+ }
|
|
|
+ if (smc.game.GameModel.skipAdConfig != -1) {
|
|
|
+ if (smc.game.GameModel.skipAdCount > 0 && smc.game.GameModel.skipAdCount % smc.game.GameModel.skipAdConfig == 0) {
|
|
|
+ console.log("skipAdCount>>>>>>>>>>>>>>>", smc.game.GameModel.skipAdCount);
|
|
|
+ console.log("skipAdConfig>>>>>>>>>>>>>>", smc.game.GameModel.skipAdConfig);
|
|
|
+ smc.game.GameModel.viewType = "double_reward";
|
|
|
+ ADHandler.inst.showAd(AD_TYPE.Double_Receive);
|
|
|
+ } else {
|
|
|
+ ServerHandler.inst.getDoubleSurprise();
|
|
|
+ }
|
|
|
} else {
|
|
|
ServerHandler.inst.getDoubleSurprise();
|
|
|
}
|
|
|
- } else {
|
|
|
- ServerHandler.inst.getDoubleSurprise();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 告诉调用者有消除发生
|
|
|
+ this.updateGameScore();
|
|
|
resolve(true)
|
|
|
}, 0.1)
|
|
|
})
|
|
|
@@ -1625,6 +1640,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
let completedCount = 0;
|
|
|
const totalCoins = Math.min(count, 5); // 限制最大数量
|
|
|
+ const delayBetweenCoins = 0.1; // 每个金币之间的延迟时间
|
|
|
|
|
|
for (let i = 0; i < totalCoins; i++) {
|
|
|
const coin = instantiate(prefab);
|
|
|
@@ -1633,7 +1649,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
coin.setWorldPosition(startPos);
|
|
|
// 创建曲线动画
|
|
|
const num = this.isDoubleSpeed ? this.doubleNum : 1;
|
|
|
+
|
|
|
+ // 添加延迟,使金币一个接一个飞出
|
|
|
tween(coin)
|
|
|
+ .delay(i * delayBetweenCoins / num) // 每个金币有不同的延迟
|
|
|
.to(0.2 / num, {
|
|
|
position: new Vec3(
|
|
|
coin.position.x,
|
|
|
@@ -1932,6 +1951,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
smc.game.GameModel.curScore = this.score;
|
|
|
if (this.score >= this.targetScore) {
|
|
|
this.gameState = GameState.GAME_PASS;
|
|
|
+ //防止第一关的时候出问题
|
|
|
+ if (this.guideNode.active) {
|
|
|
+ this.guideNode.active = false;
|
|
|
+ }
|
|
|
//弹出通关奖励界面
|
|
|
DCHandler.inst.reportData(3000505, smc.account.AccountModel.curLevel);
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
@@ -2210,7 +2233,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
// ✅ 销毁方块节点
|
|
|
brickData.brickNode.destroy()
|
|
|
-
|
|
|
// ✅ 补充新的砖块
|
|
|
this.addBrick(brickData.index)
|
|
|
// ✅ 消除检查逻辑保持和手动一致
|
|
|
@@ -2322,7 +2344,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
const showState = smc.game.GameModel.popupShow
|
|
|
if (!showState) {
|
|
|
//展示这些的时候,游戏要暂停
|
|
|
- this.gameState = GameState.PAUSED;
|
|
|
+ if (this.popupType != "") {
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
+ }
|
|
|
switch (this.popupType) {
|
|
|
case "weal_1":
|
|
|
oops.gui.open(UIID.WarmReminder);
|