|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, director, Label, log, PhysicsSystem, } from 'cc';
|
|
|
+import { _decorator, director, EAxisDirection, Label, log, PhysicsSystem, } from 'cc';
|
|
|
import { ModulerBase } from '../../GameFrameWork/ModulerBase';
|
|
|
import { resMgr } from '../../../Frames/ResourcesMgr';
|
|
|
import { GameInfo } from '../../../GameInfo';
|
|
@@ -50,9 +50,11 @@ export class GameOver extends ModulerBase {
|
|
|
protected onStart(): void {
|
|
|
this.onBtnClick("_btnLeft", this._onBtnBack, this);
|
|
|
this.onBtnClick("_btnRight", this._onBtnRight, this);
|
|
|
+
|
|
|
director.preloadScene("StartScene")
|
|
|
}
|
|
|
config() {
|
|
|
+ GameInfo.Instance.setIsGameOver(true);
|
|
|
this.getSprite("_gameOverUITitle").spriteFrame =
|
|
|
GameInfo.Instance.getOverWin() ?
|
|
|
resMgr.getSpriteFrame("GameWin") :
|
|
@@ -66,9 +68,9 @@ export class GameOver extends ModulerBase {
|
|
|
|
|
|
const kill: number = this.calculateReward(GameInfo.Instance.getKillCount(), this.KillRewardConfig);
|
|
|
const life: number = this.calculateReward(GameInfo.Instance.getLifePecent(), this.LifeRewardConfig);
|
|
|
- const stageClear: number = this.calculateReward(GameInfo.Instance.getCurlv(), this.newresultRewardConfig);
|
|
|
+ const stageClear: number = this.calculateReward(Number(GameInfo.Instance.getCurlv()), this.newresultRewardConfig);
|
|
|
|
|
|
- this.xp = GameInfo.Instance.getCurlv() * 30;
|
|
|
+ this.xp = Number(GameInfo.Instance.getCurlv()) * 30;
|
|
|
this.totalGold = kill + life + stageClear;
|
|
|
|
|
|
const lifeDia: number = Math.floor(life * 0.08);
|
|
@@ -87,12 +89,14 @@ export class GameOver extends ModulerBase {
|
|
|
}
|
|
|
|
|
|
private _onBtnBack() {
|
|
|
- director.resume()
|
|
|
- director.purgeDirector();
|
|
|
+ //director.purgeDirector();
|
|
|
this.addReward();
|
|
|
this.clearDt();
|
|
|
this.hide(false);
|
|
|
- director.loadScene("StartScene");
|
|
|
+ director.loadScene("StartScene", () => {
|
|
|
+ director.resume();
|
|
|
+ GameInfo.Instance.setIsGameOver(false);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private _onBtnRight() {
|
|
@@ -119,25 +123,24 @@ export class GameOver extends ModulerBase {
|
|
|
GameInfo.Instance.setKillCount(0);
|
|
|
GameInfo.Instance.setLifePecent(0);
|
|
|
GameInfo.Instance.setOverWin(false);
|
|
|
- GameInfo.Instance.setIsGameOver(false);
|
|
|
}
|
|
|
|
|
|
private addReward() {
|
|
|
const map: Map<string, number> = new Map();
|
|
|
- map.set("GameOverRewardGold", this.totalGold + localDt.getGold());
|
|
|
+ map.set("GameOverRewardGold", (this.totalGold + Number(localDt.getData("Gold"))));
|
|
|
map.set("GameOverRewardDia", this.totalDia + GameInfo.Instance.getDiamond());
|
|
|
map.set("Xp", this.xp + GameInfo.Instance.getCurGradeExp());
|
|
|
|
|
|
if (GameInfo.Instance.getOverWin()) {
|
|
|
- GameInfo.Instance.setCurLv(GameInfo.Instance.getCurlv() + 1);
|
|
|
- map.set("CurLv", GameInfo.Instance.getCurlv());
|
|
|
+ GameInfo.Instance.setCurLv(Number(GameInfo.Instance.getCurlv()) + 1);
|
|
|
+ map.set("CurLv", Number(GameInfo.Instance.getCurlv()));
|
|
|
}
|
|
|
GameInfo.Instance.setGameOverReward(map);
|
|
|
//GameInfo.Instance.setGold(this.totalGold + GameInfo.Instance.getGold());
|
|
|
- localDt.saveGold(this.totalGold + localDt.getGold());
|
|
|
+ localDt.saveData("Gold", this.totalGold + Number(localDt.getData("Gold")));
|
|
|
|
|
|
GameInfo.Instance.setDiamond(this.totalDia + GameInfo.Instance.getDiamond());
|
|
|
- localDt.saveDiamond(GameInfo.Instance.getDiamond())
|
|
|
+ localDt.saveData("Diamond", GameInfo.Instance.getDiamond())
|
|
|
}
|
|
|
|
|
|
//初始化场景 重置数据
|