|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-23 11:13:27
|
|
|
+ * @LastEditTime: 2025-04-23 15:13:01
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -225,6 +225,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
private randomList: number[] = [];
|
|
|
|
|
|
+ private autoFunction: Function | null = null;
|
|
|
|
|
|
|
|
|
/** 视图层逻辑代码分离演示 */
|
|
|
@@ -319,13 +320,10 @@ export class EliminateViewComp extends CCComp {
|
|
|
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 = 200;
|
|
|
+ this.targetScore = smc.game.GameModel.targetScore;
|
|
|
this.popupType = smc.game.GameModel.popupType;
|
|
|
this.lab_score.string = this.score.toString();
|
|
|
this.lab_wxCoin.string = Format.formatWxCoin(this.money);
|
|
|
@@ -592,7 +590,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
- this.updateGameScore();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1423,6 +1420,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
this.score += score;
|
|
|
+ this.updateGameScore();
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
ServerHandler.inst.updateEliminationReward({
|
|
|
count: totalEliminationsInThisRound,
|
|
|
@@ -1837,6 +1835,13 @@ export class EliminateViewComp extends CCComp {
|
|
|
console.log("游戏结束")
|
|
|
smc.game.GameModel.curScore = this.score;
|
|
|
oops.gui.open(UIID.GameOver);
|
|
|
+ //如果有自动就要关闭自动
|
|
|
+ if (this.autoFunction) {
|
|
|
+ this.unschedule(this.autoFunction);
|
|
|
+ this.autoFunction = null;
|
|
|
+ this.initButtonState(false);
|
|
|
+ this.autoState = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1896,6 +1901,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
//设置按钮
|
|
|
private btn_setting() {
|
|
|
oops.gui.open(UIID.Setting);
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
}
|
|
|
|
|
|
//左边微信按钮
|
|
|
@@ -1905,7 +1911,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
} else {
|
|
|
oops.gui.open(UIID.WechatWithdraw);
|
|
|
}
|
|
|
-
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
}
|
|
|
|
|
|
//顶部红包按钮
|
|
|
@@ -1917,14 +1923,14 @@ export class EliminateViewComp extends CCComp {
|
|
|
} else {
|
|
|
oops.gui.open(UIID.RedPacketWithdraw);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
}
|
|
|
|
|
|
- //二倍速按钮
|
|
|
+ //二倍速按钮
|
|
|
private btn_double() {
|
|
|
// oops.gui.open(UIID.DoubleSpeed);
|
|
|
if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
ServerHandler.inst.getDoubleSpeedTime();
|
|
|
} else {
|
|
|
oops.gui.open(UIID.DoubleSpeed);
|
|
|
@@ -1940,7 +1946,18 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.autoState = !this.autoState;
|
|
|
this.initButtonState(this.autoState);
|
|
|
if (this.autoState) {
|
|
|
+
|
|
|
this.executeAutoPlace();
|
|
|
+ this.autoFunction = this.executeAutoPlace;
|
|
|
+ this.schedule(this.autoFunction, 1.5);
|
|
|
+ } else {
|
|
|
+ //关闭
|
|
|
+ if (this.autoFunction) {
|
|
|
+ this.unschedule(this.autoFunction);
|
|
|
+ this.autoFunction = null;
|
|
|
+ this.initButtonState(false);
|
|
|
+ this.autoState = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2119,11 +2136,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
if (!promptFlag) {
|
|
|
this.autoState = false
|
|
|
this.gameOver()
|
|
|
- } else if (this.autoState) {
|
|
|
- // 继续自动放置
|
|
|
- this.scheduleOnce(() => {
|
|
|
- this.executeAutoPlace()
|
|
|
- }, this.autoPlaceInterval)
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -2147,11 +2159,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
//改变按钮时间
|
|
|
// let time = smc.game.GameModel.doubleSpeedTime;
|
|
|
this.doubleSpeedTime = smc.game.GameModel.doubleSpeedTime;
|
|
|
- let time = 15;
|
|
|
- if (time <= 0) {
|
|
|
+ if (this.doubleSpeedTime <= 0) {
|
|
|
return
|
|
|
}
|
|
|
- console.log("二倍速时间", time);
|
|
|
if (!this.autoState) {
|
|
|
this.btn_auto();
|
|
|
//改按钮状态
|
|
|
@@ -2160,18 +2170,19 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
this.callback = function () {
|
|
|
if (!this.adShowingFlag && this.gameState === GameState.PLAYING) {
|
|
|
- time--
|
|
|
+ this.doubleSpeedTime--
|
|
|
//修改剩余时间,秒格式化成时分10:59
|
|
|
- const minutes = Math.floor(time / 60);
|
|
|
- const seconds = time % 60;
|
|
|
+ const minutes = Math.floor(this.doubleSpeedTime / 60);
|
|
|
+ const seconds = this.doubleSpeedTime % 60;
|
|
|
const formattedTime = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
|
this.lab_doubleTime.string = formattedTime;
|
|
|
//时间到了
|
|
|
- if (time <= 0) {
|
|
|
+ if (this.doubleSpeedTime <= 0) {
|
|
|
this.lab_doubleTime.string = "二倍速";
|
|
|
this.isDoubleSpeed = false;
|
|
|
this.doubleNum = 1;
|
|
|
//再打开继续二倍速页面
|
|
|
+ this.gameState = GameState.PAUSED;
|
|
|
oops.gui.open(UIID.KeepSpeed);
|
|
|
this.unschedule(this.callback);
|
|
|
}
|