You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
7.9 KiB
192 lines
7.9 KiB
|
|
//*********************
|
|
// create by 流云
|
|
// time: Thu Oct 23 2025
|
|
// desc:
|
|
//*********************
|
|
import { _decorator, Component, Node, find, Sprite, Label, Tween } from 'cc';
|
|
import { Auto_BattlePause } from './Auto_BattlePause';
|
|
|
|
import { BattleDataManager } from '../BattleGame/BattleDataManager';
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
|
import { UIID } from '../../game/ConfigRes';
|
|
import { OtherDataType, StatisticsType } from '../../game/GameData';
|
|
import { BattleType, ChapterDifficulty } from '../../manager/ChapterDataManager';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('UIBattlePause')
|
|
export class UIBattlePause extends Auto_BattlePause {
|
|
|
|
onLoad(): void {
|
|
super.onLoad();
|
|
}
|
|
|
|
onEnable(): void {
|
|
super.onEnable();
|
|
}
|
|
|
|
onDisable(): void {
|
|
super.onDisable();
|
|
}
|
|
|
|
onInit(): void {
|
|
this.showOpenCenterEff();
|
|
this.showOpenMaskEff(2);
|
|
|
|
let replica = gg.game.CurentSelectReplica;
|
|
if (replica) {
|
|
let used = Number(gg.data.getkeyKeyValue(OtherDataType.ReplicaCanEnterCountToday, replica.id)) || 0;
|
|
let maxCount = replica.count;
|
|
let have = Math.max(0, maxCount - used);
|
|
this.count = have;
|
|
this.ui_Count.active = true;
|
|
this.lb_count.string = `${have}/${maxCount}`;
|
|
this.btnRestart.getComponent(Sprite).grayscale = have == 0;
|
|
|
|
return;
|
|
}
|
|
|
|
this.ui_Count.active = false
|
|
|
|
if(gg.data.project.vigourCost == 0){
|
|
this.ui_tilitag.active = false
|
|
this.lb_tilifree.node.active = true
|
|
this.lb_tililab.node.active = false
|
|
}else{
|
|
this.ui_tilitag.active = true
|
|
this.lb_tilifree.node.active = false
|
|
this.lb_tililab.node.active = true
|
|
this.lb_tililab.string = `-${gg.data.project.vigourCost}`
|
|
}
|
|
|
|
}
|
|
|
|
count = -1;
|
|
|
|
click_btnExit() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
if (gg.game.CurentSelectBattleType == BattleType.BoxMode) {
|
|
gg.game.CurentBattle.fubenBoxAddAtk = 0
|
|
gg.game.CurentBattle.fubenBoxSkillCoolDown = 0
|
|
gg.game.CurentBattle.fubenBoxAddCrit = 0
|
|
gg.game.CurentBattle.fubenBoxAddDamage = 0
|
|
gg.game.CurentBattle.fubenBoxReduceBossSpeed = 0
|
|
gg.game.playerSkillGroupIdArray = []
|
|
gg.game.playerWeaponGroupIdArray = []
|
|
}
|
|
let curDeadMonsterNum = gg.game.CurentBattle.MonsterDeadNum
|
|
let totalMonsterNum = gg.game.CurentBattle.TotalMonsterNum
|
|
|
|
if (gg.game.CurentBattle.BattleType == BattleType.Level && totalMonsterNum > 0)
|
|
gg.data.project.setChapterStatusByProgress(gg.game.CurentBattle.ChapterId, gg.game.CurentBattle.Difficulty, curDeadMonsterNum / totalMonsterNum);
|
|
|
|
gg.PRR.upToServer(3, gg.game.CurentBattle.BattleTime, () => {
|
|
console.log("玩家记录上报-退出数据上传成功");
|
|
}, () => {
|
|
console.log("玩家记录上报-退出数据上传失败");
|
|
});
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-退出游戏`)
|
|
gg.game.CurentBattle.tryAddEarlyChapterChallengeCount();
|
|
//第3波退出/重新开始,算失败次数+1
|
|
if (curWaveNum >= 3 && gg.game.CurentBattle.ChapterId == gg.data.doc.chapter && gg.game.CurentBattle.BattleType == BattleType.Level && gg.game.CurentBattle.Difficulty == ChapterDifficulty.Normal) {
|
|
gg.data.setStatistics(StatisticsType.SuccessContinuousCount, 0)
|
|
}
|
|
|
|
gg.game.IsPlayedGame = false
|
|
let id = UIID.Home;
|
|
if (gg.game.CurentSelectBattleType != BattleType.Level) id = UIID.Replica;
|
|
|
|
const cam = gg.ui.GameCamera;
|
|
Tween.stopAllByTarget(cam);
|
|
gg.game.CurentBattle.addFailWeight(true);
|
|
if(gg.game.CurentBattle.BattleType == BattleType.InfiniteMode){
|
|
gg.ui.popPanel(UIID.BattleFail)
|
|
this.close(2)
|
|
}else{
|
|
gg.game.enterMain(id);
|
|
}
|
|
|
|
}
|
|
click_ui_center() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-继续游戏`)
|
|
this.close(2).then(() => {
|
|
gg.game.CurentBattle.IsEdit = false;
|
|
gg.game.CurentBattle.resume();
|
|
});
|
|
}
|
|
click_btnRestart() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
let result = 0;
|
|
let replica = gg.game.CurentSelectReplica;
|
|
if (replica) {
|
|
if (this.count == 0) {
|
|
gg.ui.showToast('今日次数已用完!')
|
|
return
|
|
}
|
|
result = gg.game.enterBattle(true);
|
|
if (result == 1) {
|
|
let str = gg.data.getkeyKeyValue(OtherDataType.ReplicaCanEnterCountToday, replica.id);
|
|
let next = (Number(str) || 0) + 1;
|
|
gg.data.setkeyKeyValue(OtherDataType.ReplicaCanEnterCountToday, replica.id, next);
|
|
}
|
|
} else {
|
|
gg.PRR.upToServer(2, gg.game.CurentBattle.BattleTime, () => {
|
|
console.log("玩家记录上报-重玩数据上传成功");
|
|
}, () => {
|
|
console.log("玩家记录上报-重玩数据上传失败");
|
|
});
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-重新开始`)
|
|
gg.game.CurentBattle.tryAddEarlyChapterChallengeCount();
|
|
//第3波退出/重新开始,算失败次数+1
|
|
if (curWaveNum >= 3 && gg.game.CurentBattle.ChapterId == gg.data.doc.chapter && gg.game.CurentBattle.BattleType == BattleType.Level && gg.game.CurentBattle.Difficulty == ChapterDifficulty.Normal) {
|
|
gg.data.setStatistics(StatisticsType.SuccessContinuousCount, 0)
|
|
}
|
|
gg.game.CurentBattle.addFailWeight(true);
|
|
result = gg.game.enterBattle(true);
|
|
}
|
|
|
|
if (result == 1||result == 2) {
|
|
// gg.PRR.upToServer(2, gg.game.CurentBattle.BattleTime, () => {
|
|
// console.log("玩家记录上报-重玩数据上传成功");
|
|
// }, () => {
|
|
// console.log("玩家记录上报-重玩数据上传失败");
|
|
// });
|
|
// let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
// gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-重新开始`)
|
|
// //第3波退出/重新开始,算失败次数+1
|
|
// if (curWaveNum >= 3 && gg.game.CurentBattle.ChapterId == gg.data.doc.chapter && gg.game.CurentBattle.BattleType == BattleType.Level && gg.game.CurentBattle.Difficulty == ChapterDifficulty.Normal) {
|
|
// gg.data.setStatistics(StatisticsType.SuccessContinuousCount, 0)
|
|
// }
|
|
// if (curWaveNum >= 3)
|
|
// gg.data.project.addFailCount(gg.game.CurentBattle.ChapterId, gg.game.CurentBattle.BattleType, gg.game.CurentBattle.Difficulty);
|
|
|
|
this.close(2)
|
|
}
|
|
|
|
}
|
|
/**检查体力是否足够 */
|
|
checkVigour() {
|
|
if (gg.data.getVigour() < gg.data.project.vigourCost) {
|
|
|
|
gg.ui.openPanel(UIID.buyPower)
|
|
return false
|
|
}
|
|
gg.data.subVigour(gg.data.project.vigourCost)
|
|
return true
|
|
}
|
|
|
|
|
|
click_btnCon() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-继续游戏`)
|
|
this.close(2).then(() => {
|
|
gg.game.CurentBattle.IsEdit = false;
|
|
gg.game.CurentBattle.resume();
|
|
});
|
|
}
|
|
}
|
|
|