import { _decorator, Component, Node } from 'cc';
import { GUIManager } from '../../../engines/gui/GUIManager';
import { GUIMediator } from '../../../engines/gui/GUIMediator';
import { SceneManager } from '../../../engines/scenes/SceneManager';
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(Node)
    DefeatedGroup:Node=null;

    onLoad(){

    }

    OnShow(data?:any):void{
        super.OnShow(data);
        let isWin:boolean=data;
        this.WinGroup.active=isWin;
        this.DefeatedGroup.active=!isWin;
        //胜利
        if(data==true){
            
        }else{//失败
            
        }
    }

    /**
     * 开始下一关
     */
    PlayNextLevel():void{
        this.HideSelf();
        GameController.single.PlayNextLevel();
    }
    
    /**
     * 重玩
     */
    Replay():void{
        this.HideSelf();
        GameController.single.Replay();
    }

    /**
     * 返回主界面
     */
    BackToMain():void{
        SceneManager.single.Swicth("PrepareScene");
        GUIManager.single.Hide(UIConst.FIGHTING_UI);
        //关闭自身
        this.HideSelf();
    }

    OnHide():void{

    }
}
