|
@@ -1,9 +1,13 @@
|
|
-import { _decorator, Director, director, EventKeyboard, find, Label, NodeEventType, } from 'cc';
|
|
|
|
|
|
+import { _decorator, director, Label, log, PhysicsSystem, } from 'cc';
|
|
import { ModulerBase } from '../../GameFrameWork/ModulerBase';
|
|
import { ModulerBase } from '../../GameFrameWork/ModulerBase';
|
|
import { resMgr } from '../../../Frames/ResourcesMgr';
|
|
import { resMgr } from '../../../Frames/ResourcesMgr';
|
|
import { GameInfo } from '../../../GameInfo';
|
|
import { GameInfo } from '../../../GameInfo';
|
|
-import { messageMgr } from '../../../Frames/MessageMgr';
|
|
|
|
import { localDt } from '../../../Frames/LocalDt';
|
|
import { localDt } from '../../../Frames/LocalDt';
|
|
|
|
+import { GameMgr } from '../../GameFrameWork/GameMgr';
|
|
|
|
+import { EnemyMgr } from './EnemyMgr';
|
|
|
|
+import { MyTower } from './MyTower';
|
|
|
|
+import { Bottom } from './Bottom';
|
|
|
|
+import { EnemyTower } from './EnemyTower';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('GameOver')
|
|
@ccclass('GameOver')
|
|
@@ -59,19 +63,19 @@ export class GameOver extends ModulerBase {
|
|
|
|
|
|
this.getLabel("_lifePercent").string = `${GameInfo.Instance.getLifePecent()}%`;
|
|
this.getLabel("_lifePercent").string = `${GameInfo.Instance.getLifePecent()}%`;
|
|
this.getLabel("_killCount").string = `${GameInfo.Instance.getKillCount()}`;
|
|
this.getLabel("_killCount").string = `${GameInfo.Instance.getKillCount()}`;
|
|
-
|
|
|
|
|
|
+
|
|
const kill: number = this.calculateReward(GameInfo.Instance.getKillCount(), this.KillRewardConfig);
|
|
const kill: number = this.calculateReward(GameInfo.Instance.getKillCount(), this.KillRewardConfig);
|
|
const life: number = this.calculateReward(GameInfo.Instance.getLifePecent(), this.LifeRewardConfig);
|
|
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(GameInfo.Instance.getCurlv(), this.newresultRewardConfig);
|
|
-
|
|
|
|
|
|
+
|
|
this.xp = GameInfo.Instance.getCurlv() * 30;
|
|
this.xp = GameInfo.Instance.getCurlv() * 30;
|
|
this.totalGold = kill + life + stageClear;
|
|
this.totalGold = kill + life + stageClear;
|
|
-
|
|
|
|
|
|
+
|
|
const lifeDia: number = Math.floor(life * 0.08);
|
|
const lifeDia: number = Math.floor(life * 0.08);
|
|
const stageClearDia: number = Math.floor(stageClear * 0.07);
|
|
const stageClearDia: number = Math.floor(stageClear * 0.07);
|
|
-
|
|
|
|
|
|
+
|
|
this.totalDia = lifeDia + stageClearDia;
|
|
this.totalDia = lifeDia + stageClearDia;
|
|
-
|
|
|
|
|
|
+
|
|
this.getLabel("_kill").string = `${kill}`;
|
|
this.getLabel("_kill").string = `${kill}`;
|
|
this.getLabel("_life").string = `${life}`;
|
|
this.getLabel("_life").string = `${life}`;
|
|
this.getLabel("_stageClear").string = `${stageClear}`;
|
|
this.getLabel("_stageClear").string = `${stageClear}`;
|
|
@@ -83,6 +87,8 @@ export class GameOver extends ModulerBase {
|
|
}
|
|
}
|
|
|
|
|
|
private _onBtnBack() {
|
|
private _onBtnBack() {
|
|
|
|
+ director.resume()
|
|
|
|
+ director.purgeDirector();
|
|
this.addReward();
|
|
this.addReward();
|
|
this.clearDt();
|
|
this.clearDt();
|
|
this.hide(false);
|
|
this.hide(false);
|
|
@@ -90,13 +96,14 @@ export class GameOver extends ModulerBase {
|
|
}
|
|
}
|
|
|
|
|
|
private _onBtnRight() {
|
|
private _onBtnRight() {
|
|
- if(GameInfo.Instance.getOverWin()){
|
|
|
|
- this.addReward();
|
|
|
|
|
|
+ director.resume();
|
|
|
|
+ if (GameInfo.Instance.getOverWin()) {
|
|
|
|
+ //初始化场景
|
|
|
|
+ this._initGameScene();
|
|
console.log("下一关")
|
|
console.log("下一关")
|
|
} else {
|
|
} else {
|
|
- console.log("重新开始")
|
|
|
|
|
|
+ //director.loadScene("GameScene")
|
|
}
|
|
}
|
|
- this.clearDt();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//计算奖励
|
|
//计算奖励
|
|
@@ -111,24 +118,43 @@ export class GameOver extends ModulerBase {
|
|
private clearDt() {
|
|
private clearDt() {
|
|
GameInfo.Instance.setKillCount(0);
|
|
GameInfo.Instance.setKillCount(0);
|
|
GameInfo.Instance.setLifePecent(0);
|
|
GameInfo.Instance.setLifePecent(0);
|
|
- GameInfo.Instance.setOverWin(false)
|
|
|
|
|
|
+ GameInfo.Instance.setOverWin(false);
|
|
|
|
+ GameInfo.Instance.setIsGameOver(false);
|
|
}
|
|
}
|
|
|
|
|
|
- private addReward(){
|
|
|
|
|
|
+ private addReward() {
|
|
const map: Map<string, number> = new Map();
|
|
const map: Map<string, number> = new Map();
|
|
- map.set("GameOverRewardGold",this.totalGold + GameInfo.Instance.getGold());
|
|
|
|
|
|
+ map.set("GameOverRewardGold", this.totalGold + localDt.getGold());
|
|
map.set("GameOverRewardDia", this.totalDia + GameInfo.Instance.getDiamond());
|
|
map.set("GameOverRewardDia", this.totalDia + GameInfo.Instance.getDiamond());
|
|
map.set("Xp", this.xp + GameInfo.Instance.getCurGradeExp());
|
|
map.set("Xp", this.xp + GameInfo.Instance.getCurGradeExp());
|
|
-
|
|
|
|
- if(GameInfo.Instance.getOverWin()){
|
|
|
|
|
|
+
|
|
|
|
+ if (GameInfo.Instance.getOverWin()) {
|
|
GameInfo.Instance.setCurLv(GameInfo.Instance.getCurlv() + 1);
|
|
GameInfo.Instance.setCurLv(GameInfo.Instance.getCurlv() + 1);
|
|
map.set("CurLv", GameInfo.Instance.getCurlv());
|
|
map.set("CurLv", GameInfo.Instance.getCurlv());
|
|
}
|
|
}
|
|
GameInfo.Instance.setGameOverReward(map);
|
|
GameInfo.Instance.setGameOverReward(map);
|
|
- GameInfo.Instance.setGold(this.totalGold + GameInfo.Instance.getGold());
|
|
|
|
|
|
+ //GameInfo.Instance.setGold(this.totalGold + GameInfo.Instance.getGold());
|
|
|
|
+ localDt.saveGold(this.totalGold + localDt.getGold());
|
|
|
|
+
|
|
GameInfo.Instance.setDiamond(this.totalDia + GameInfo.Instance.getDiamond());
|
|
GameInfo.Instance.setDiamond(this.totalDia + GameInfo.Instance.getDiamond());
|
|
- localDt.saveGold(GameInfo.Instance.getGold());
|
|
|
|
- localDt.saveDiamond(GameInfo.Instance.getDiamond());
|
|
|
|
|
|
+ localDt.saveDiamond(GameInfo.Instance.getDiamond())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //初始化场景 重置数据
|
|
|
|
+ private _initGameScene() {
|
|
|
|
+ this.addReward();
|
|
|
|
+ this.clearDt();
|
|
|
|
+ GameMgr.Instance.getModuler(EnemyMgr).node.removeAllChildren();
|
|
|
|
+ this.node.parent.getChildByPath("Road/Roles").removeAllChildren();
|
|
|
|
+ this.node.parent.getChildByPath("BulletLayer").removeAllChildren();
|
|
|
|
+
|
|
|
|
+ GameMgr.Instance.getModuler(EnemyMgr).init();
|
|
|
|
+ this.node.parent.getComponentInChildren(EnemyTower).initData();
|
|
|
|
+ this.node.parent.getComponentInChildren(MyTower).initData();
|
|
|
|
+ GameMgr.Instance.getModuler(Bottom).initData();
|
|
|
|
+
|
|
|
|
+ //隐藏
|
|
|
|
+ this.hide(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|