import { _decorator, director } from 'cc'; import { UIBase } from '../../GameFrameWork/UIBase'; import { resMgr } from '../../../Frames/ResourcesMgr'; import { GameOverData } from './Data/GameOverData'; const { ccclass, property } = _decorator; @ccclass('GameOver') export class GameOver extends UIBase { // //是否胜利 // win: boolean = null; // killCount: number = null; // killPercent: number = null; // //金币奖励 // killAward: number = null; // lifeAward: number = null; // stageClearAward: number = null; // totalAward: number = null; // //经验奖励 // xp: number = null; // //钻石奖励 // lifeDia: number = null; // stageClearDia: number = null; // totalDia: number = null; gameOverDt: GameOverData = null; protected onStart() { this.gameOverDt = GameOverData.Instance; this.onBtnClick("_btnBack", this._onBtnBack); this.config(); } // config() { // this.getSprite("_gameOverUITitle").spriteFrame = this.win ? // resMgr.getSpriteFrame("GameWin") : // resMgr.getSpriteFrame("GameOver"); // this.getLabel("_labelRight").string = this.win ? "下一关" : "重新开始"; // const labelDate = { // "_killCount":this.killCount, // "_lifePercent":`${this.killPercent} %`, // "_kill":this.killAward, // "_life":this.lifeAward, // "_stageClear":this.stageClearAward, // "_total":this.totalAward, // "_xp":this.xp, // "_lifeDia":this.lifeDia, // "_stageClearDia":this.stageClearDia, // "_totalDia":this.totalDia, // } // this._setLabels(labelDate); // // this.getLabel("_killCount").string = String(this.killCount); // // this.getLabel("_lifePercent").string = `${String(this.killPercent)} %`; // // this.getLabel("_kill").string = String(this.killAward); // // this.getLabel("_life").string = String(this.lifeAward); // // this.getLabel("_stageClear").string = String(this.stageClearAward); // // this.getLabel("_total").string = String(this.totalAward); // // this.getLabel("_xp").string = String(this.xp); // // this.getLabel("_lifeDia").string = String(this.lifeDia); // // this.getLabel("_stageClearDia").string = String(this.stageClearDia); // // this.getLabel("_totalDia").string = String(this.totalDia); // } // private _setLabels(labelDate){ // for(const [labelName, value] of labelDate){ // this.getLabel(labelName).string = String(value); // } // } config() { this.getSprite("_gameOverUITitle").spriteFrame = this.gameOverDt.Win ? resMgr.getSpriteFrame("GameWin") : resMgr.getSpriteFrame("GameOver"); this.getLabel("_labelRight").string = this.gameOverDt.Win ? "下一关" : "重新开始"; const labelData = new Map(); labelData.set("_killCount", this.gameOverDt.KillCount); labelData.set("_lifePercent", `${this.gameOverDt.LifePercent} %`); labelData.set("_kill", this.gameOverDt.KillAward); labelData.set("_life", this.gameOverDt.LifeAward); labelData.set("_stageClear", this.gameOverDt.StageClearAward); labelData.set("_total", this.gameOverDt.TotalAward); labelData.set("_xp", this.gameOverDt.Xp); labelData.set("_lifeDia", this.gameOverDt.LifeDia); labelData.set("_stageClearDia", this.gameOverDt.StageClearDia); labelData.set("_totalDia", this.gameOverDt.TotalDia); this._setLabels(labelData); } private _setLabels(labelData: Map) { for (const [labelName, value] of labelData.entries()) { this.getLabel(labelName).string = String(value); } } private _onBtnBack(){ //销毁 this.gameOverDt.clearData(); this.hide(true); director.loadScene("StartScene"); } }