import { _decorator, Component, Node, LabelComponent } from 'cc'; import { GUIManager } from '../../../engines/gui/GUIManager'; import { GUIMediator } from '../../../engines/gui/GUIMediator'; import { SceneManager } from '../../../engines/scenes/SceneManager'; import GameConfigManager from '../../models/GameConfigManager'; import { GameModel } from '../../models/GameModel'; import { GameController } from '../fightings/GameController'; import { UIConst } from '../UIConst'; const { ccclass, property } = _decorator; @ccclass('GameOverMediator') export class GameOverMediator extends GUIMediator { @property(Node) WinGroup:Node=null; @property({ type:LabelComponent }) WinAwardLabel:LabelComponent=null; @property(Node) DefeatedGroup:Node=null; private isWin:boolean; private award:number; onLoad(){ } OnShow(data?:any):void{ super.OnShow(data); this.isWin=data; this.WinGroup.active=this.isWin; this.DefeatedGroup.active=!this.isWin; //胜利 if(this.isWin==true){ this.WinGroup.active=true; this.DefeatedGroup.active=false; let levelConfig:any=GameConfigManager.GetLevelConfig(GameModel.single.currentLevel-1); //关卡基础奖励 this.award=levelConfig.awards+levelConfig.killAward*GameModel.single.killCount; this.WinAwardLabel.string=this.award.toString(); }else{//失败 //失败不算奖励 this.WinGroup.active=false; this.DefeatedGroup.active=true; } } /** * 开始下一关 */ PlayNextLevel():void{ this.AddAward(); this.HideSelf(); GameController.single.PlayNextLevel(); } /** * 重玩 */ Replay():void{ this.AddAward(); this.HideSelf(); GameController.single.Replay(); } /** * 返回主界面 */ BackToMain():void{ this.AddAward(); SceneManager.single.Swicth("PrepareScene"); GUIManager.single.Hide(UIConst.FIGHTING_UI); //关闭自身 this.HideSelf(); } /** * 去全屏幕界面 */ GoToFullOutput():void{ this.AddAward(); GUIManager.single.Show(UIConst.FULL_OUTPUT_UI); this.HideSelf(); } /** * 获取奖励 */ private AddAward(value:number=1):void{ if(this.isWin){ GameModel.single.gold+=this.award*value; } } OnHide():void{ } }