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.
272 lines
10 KiB
272 lines
10 KiB
|
|
//*********************
|
|
// create by 流云
|
|
// time: Thu Sep 25 2025
|
|
// desc:
|
|
//*********************
|
|
import { _decorator, Component, Node, find, instantiate, Label, sp } from 'cc';
|
|
import { Auto_BattleSuccess } from './Auto_BattleSuccess';
|
|
import { ChapterDataManager, BattleType, ChapterDifficulty } from '../../manager/ChapterDataManager';
|
|
import { StatisticsType, TaskType } from '../../game/GameData';
|
|
import { ItemData } from '../../game/ConfigProjectData';
|
|
import MTools from 'db://assets/mx/tools/MTools';
|
|
import { itemPic } from '../../com/itemPic';
|
|
import { NewFunType } from '../../newFun/NewFun';
|
|
import { UIID } from '../../game/ConfigRes';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/**游戏结果奖励类型 */
|
|
export enum GameResultAwardType {
|
|
Coin = 1,//金币
|
|
Diamond = 2,//钻石
|
|
}
|
|
@ccclass('UIBattleSuccess')
|
|
export class UIBattleSuccess extends Auto_BattleSuccess {
|
|
curCoinNum: number = 0
|
|
curDiamondNum: number = 0
|
|
dataList = null
|
|
addNum = 1
|
|
onLoad(): void {
|
|
super.onLoad();
|
|
}
|
|
|
|
onEnable(): void {
|
|
super.onEnable();
|
|
}
|
|
|
|
onDisable(): void {
|
|
super.onDisable();
|
|
}
|
|
|
|
onInit(): void {
|
|
// 面板可能复用,先重置领取倍率与按钮显隐,避免上次状态残留
|
|
this.addNum = 1;
|
|
this.btnADGet.active = false;
|
|
this.btnShareGet.active = false;
|
|
|
|
gg.audio.playEffect({ name: "胜利" });
|
|
this.showOpenMaskEff(2);
|
|
// let spine = this.ui_center.find("胜利结算").getComponent(sp.Skeleton);
|
|
// spine.setAnimation(0, 'play', false);
|
|
// this.scheduleOnce(()=>{
|
|
// spine.setAnimation(0, 'idle', true);
|
|
// },1.5)
|
|
if (gg.game.CurentBattle.BattleType == BattleType.Level) {
|
|
gg.data.project.setChapterStatusByProgress(gg.game.CurentBattle.ChapterId, gg.game.CurentBattle.Difficulty, 1);
|
|
//gg.targetTaskManager.checkTask()//任务领取状态依赖其他模块不需要统计数据 进入home会自动调用一次checkTask
|
|
} else {
|
|
gg.data.project.addReplicaPassCountToday(gg.game.CurentBattle.CurentConfigReplica.id, gg.game.CurentBattle.Difficulty);
|
|
}
|
|
|
|
//gg.data.savePlaySelectLevelDataPassGame(gg.game.CurentSelectChapterId, BattleDataManager.getGameBattleMode())
|
|
|
|
gg.data.addDayTaskProgressData(TaskType.successPass, 1)
|
|
this.showReward()
|
|
|
|
// 项目不启用“分享双倍”,结算页固定只保留广告双倍入口
|
|
this.btnADGet.active = true
|
|
this.btnShareGet.active = false
|
|
|
|
if (!gg.game.CurentBattle.IsWatchAd && gg.game.CurentSelectChapterId >= 3) {
|
|
gg.sdk.showInterstitialAd(() => {
|
|
|
|
}, () => {
|
|
|
|
}, true)
|
|
}
|
|
|
|
|
|
this.offlineRewardTimeCount()
|
|
|
|
gg.PRR.addRecordData();
|
|
gg.PRR.upToServer(0, gg.game.CurentBattle.BattleTime, () => {
|
|
console.log("玩家记录上报-成功数据上传成功");
|
|
}, () => {
|
|
console.log("玩家记录上报-成功数据上传失败");
|
|
});
|
|
|
|
if(gg.data.doc.chapter == 3){
|
|
gg.game.thirdChapterWinGreatGift = true
|
|
}
|
|
|
|
this.reportChapterPassBlockStats();
|
|
}
|
|
|
|
/**
|
|
* 主线章节通关成功:按武器上报方块叠层、技能条数,以及场上总方块数(与战斗内 DPS 用的叠层统计一致)。
|
|
*/
|
|
private reportChapterPassBlockStats(): void {
|
|
const battle = gg.game.CurentBattle;
|
|
if (!battle || battle.BattleType !== BattleType.Level) {
|
|
return;
|
|
}
|
|
const ch = battle.getReportDYChapterId();
|
|
const wave = battle.CurentWaveNum ?? 0;
|
|
const prefix = `章节${ch}_${wave}-`;
|
|
const weapons = battle.CurUseWeaponArr ?? [];
|
|
for (let i = 0; i < weapons.length; i++) {
|
|
const w = weapons[i];
|
|
if (!w) continue;
|
|
const wid = w.weaponid;
|
|
const wname = (w.name ?? '').replace(/-/g, '_');
|
|
const blockSum = battle.getTetrStackLevelSum(wid);
|
|
const skillCount =
|
|
battle.CurUseSkillArr?.filter((s) => s && s.weapon === wid && s.type !== 3).length ?? 0;
|
|
gg.sdk.reportDY('inLevel', `${prefix}章节通过成功-${wname}方块数目${blockSum}`);
|
|
gg.sdk.reportDY('inLevel', `${prefix}章节通过成功-${wname}技能方块数目${skillCount}`);
|
|
}
|
|
const totalBlocks = battle.curMap?.getTetriNodeCount?.() ?? 0;
|
|
gg.sdk.reportDY('inLevel', `${prefix}章节通过成功-总方块数${totalBlocks}`);
|
|
//gg.game.CurentBattle.getFreeCoinNum
|
|
gg.sdk.reportDY('inLevel', `${prefix}章节通过成功-银币使用次数${gg.game.CurentBattle.getFreeCoinNum}`);
|
|
}
|
|
|
|
|
|
//离线收益开启时间计数
|
|
offlineRewardTimeCount() {
|
|
//离线手机开启计数
|
|
let normalConfId = 1
|
|
let hardConf = gg.newFun.getNewFunData(NewFunType.Difficulty, ChapterDifficulty.Hard);
|
|
let hellConf = gg.newFun.getNewFunData(NewFunType.Difficulty, ChapterDifficulty.Hell);
|
|
let AfkRewards = 0
|
|
if (gg.game.CurentBattle.BattleType == BattleType.Level) {
|
|
if (gg.game.CurentBattle.Difficulty == ChapterDifficulty.Normal) {
|
|
if (gg.game.CurentSelectChapterId >= normalConfId) {
|
|
AfkRewards = StatisticsType.framAfkRewards
|
|
}
|
|
} else if (gg.game.CurentBattle.Difficulty == ChapterDifficulty.Hard) {
|
|
if (gg.game.CurentSelectChapterId >= hardConf.chapter) {
|
|
AfkRewards = StatisticsType.factoryAfkRewards
|
|
}
|
|
} else if (gg.game.CurentBattle.Difficulty == ChapterDifficulty.Hell) {
|
|
if (gg.game.CurentSelectChapterId >= hellConf.chapter) {
|
|
AfkRewards = StatisticsType.mineAfkRewards
|
|
}
|
|
}
|
|
}
|
|
if (AfkRewards) {
|
|
let lastAddTime = gg.data.getStatistics(AfkRewards);
|
|
if (lastAddTime == 0) {
|
|
console.log("离线收益开启时间计数", gg.data.getCurentTime());
|
|
gg.data.setStatistics(AfkRewards, gg.data.getCurentTime());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
showReward() {
|
|
|
|
let reward = [];
|
|
let rewardStr = gg.game.CurentBattle.CurentChapterRewardStr;
|
|
if (rewardStr != '') {
|
|
reward = rewardStr.split('|');
|
|
}
|
|
|
|
// if (zombieReward != '') {
|
|
// reward.push(zombieReward);
|
|
// }
|
|
|
|
|
|
//奖励倍数
|
|
let type = gg.game.CurentSelectBattleType
|
|
|
|
let itemsArray = []
|
|
let addRatio = 1;
|
|
if (type == BattleType.Level) {
|
|
addRatio += gg.data.getFightRewardRatio();
|
|
addRatio += gg.purchase.getMainLineRewardAdd();
|
|
}
|
|
for (let i = 0; i < reward.length; i++) {
|
|
let value = reward[i].split(',')
|
|
let goodId = Number(value[0])
|
|
let itemNum = Math.floor(Number(value[1]) * (addRatio))
|
|
if (goodId == 104 || goodId == 105 || goodId == 106 || goodId == 107) {
|
|
itemNum = itemNum;
|
|
let boxRewardArray = gg.data.getFragmentNumArray(goodId + ',' + itemNum)
|
|
let statsArray = MTools.mergeToStatsArray(boxRewardArray)
|
|
|
|
for (let i = 0; i < statsArray.length; i++) {
|
|
let array = statsArray[i].split('|')
|
|
let id = Number(array[0]);
|
|
let num = Number(array[1]);
|
|
let item = new ItemData(id, num)
|
|
itemsArray.push(item)
|
|
}
|
|
} else {
|
|
if (goodId != 4) {
|
|
itemNum = itemNum;
|
|
}
|
|
let item = new ItemData(goodId, itemNum)
|
|
itemsArray.push(item)
|
|
}
|
|
}
|
|
|
|
//
|
|
this.dataList = itemsArray
|
|
for (let i = 0; i < itemsArray.length; i++) {
|
|
//隔帧处理
|
|
this.scheduleOnce(() => {
|
|
let value = itemsArray[i]
|
|
let item = instantiate(this.ui_singleItem)
|
|
item.active = true
|
|
item.parent = this.ui_content
|
|
item.setPosition(0, 0)
|
|
this.initItem(item, value)
|
|
}, 0.01 * i)
|
|
}
|
|
}
|
|
/**初始化单个物品 */
|
|
initItem(item: Node, value: ItemData) {
|
|
let goodId = value.id
|
|
let num = value.num
|
|
item.getComponent(itemPic).setGoodId(goodId)
|
|
let numLabel = item.getChildByName('numStr').getComponent(Label)
|
|
numLabel.string = num.toString()
|
|
|
|
}
|
|
click_btnGet() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-成功领取奖励`)
|
|
for (let i = 0; i < this.dataList.length; i++) {
|
|
let value = this.dataList[i];
|
|
let goodId = Number(value.id)
|
|
let num = Number(value.num)
|
|
gg.data.addItemNum(goodId, num * this.addNum);
|
|
}
|
|
gg.game.IsPlayedGame = true
|
|
this.close(2)
|
|
|
|
gg.game.enterMain();
|
|
|
|
|
|
}
|
|
click_btnADGet() {
|
|
gg.audio.playEffect({ name: "点击音效" });
|
|
gg.sdk.showVideoAd((res) => {
|
|
if (res) {
|
|
let curWaveNum = gg.game.CurentBattle.CurentWaveNum
|
|
gg.sdk.reportDY("inLevel", `章节${gg.game.CurentBattle.getReportDYChapterId()}_${curWaveNum}-AD-成功双倍领取奖励`)
|
|
this.addNum = 2
|
|
this.btnADGet.active = false
|
|
//刷新界面数字
|
|
this.btnShareGet.active = false
|
|
for (let i = 0; i < this.ui_content.children.length; i++) {
|
|
let item = this.ui_content.children[i]
|
|
let numLabel = item.getChildByName('numStr').getComponent(Label)
|
|
numLabel.string = (Number(numLabel.string) * this.addNum).toString()
|
|
}
|
|
gg.game.CurentBattle.IsWatchAd = true
|
|
} else {
|
|
gg.ui.showToast('观看视频失败');
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
click_btnShareGet() {
|
|
// 项目不启用分享双倍,保留空实现仅防止历史按钮绑定报错
|
|
gg.ui.showToast('该功能未开放');
|
|
|
|
}
|
|
}
|
|
|