UIBattleEnd.ts 1.07 KB
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { WindowName } from "../../Global";
import { BattleManager } from "../../kernel/battle/BattleManager";
import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class UIBattleEnd extends UIBase {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    protected onEnable(): void {
        let isWin = this.enableParam as boolean;

        this.node.getChildByName('txt').getComponent(cc.Label).string = (isWin ? '赢' : '输');
    }

    // update (dt) {}

    //#region event

    onBtnExitClick() {
        BattleManager.ins.leaveBattle();
        UIManager.ins.closeWindow(WindowName.BATTLE_END);
        UIManager.ins.openScene('Main');
    }

    //#endregion
}