pinball/assets/_Game/Scripts/UI/GameOverPanel.ts

35 lines
1.0 KiB
TypeScript

import { _decorator, Component, Label, Node } from 'cc';
import BEConnector from '../API/BEConnector';
import { GameManager } from '../Manager/GameManager';
const { ccclass, property } = _decorator;
@ccclass('GameOverPanel')
export class GameOverPanel extends Component {
@property(Label) private topScore: Label = null;
@property(Label) private yourScore: Label = null;
@property(Node) private confirmPanel: Node = null;
protected onEnable(): void {
let currentScore = BEConnector.instance.currentScore + GameManager.instance.score;
this.topScore.string = BEConnector.instance.maxScore.toString();
this.yourScore.string = currentScore.toString();
this.scheduleOnce(this.endGame, 60);
}
onClickYesButton() {
this.confirmPanel.active = true;
}
onClickNoButton() {
GameManager.instance.gameOver();
}
protected onDisable(): void {
this.unschedule(this.endGame);
}
private endGame() {
GameManager.instance.gameOver();
}
}