import { _decorator, game, Node } from 'cc';
import { BaseView } from '../../../framework/layer/BaseView';
import { AudioID } from '../../../framework/config/AudioConf';
import { Framework } from '../../../framework/Framework';
import { MaterialUtil } from '../../../framework/util/MaterialUtil';

const { ccclass, property } = _decorator;

@ccclass('Restart')
export class Restart extends BaseView {

	protected onLoad() {
		super.onLoad();
	}

	protected onDestroy() {

	}

	//UI开打时会调用,如果有初始化代码应该放到此函数
	onOpen(text) {
		this.Label.text.string = (text) ? text : '发生错误，请重启游戏';
		MaterialUtil.Restart();
	}

	//UI关闭时会调用,该函数在onDestroy前调用
	onClose() {

	}

	//框架管理UI层级时会调用,可根据UI情况修改
	onShow() {
		super.onShow();
	}

	//框架管理UI层级时会调用,可根据UI情况修改
	onHide() {
		super.onHide();
	}

	//UI事件处理
	private onTouchButton(event: Event) {
		Framework.audio.playEffect(AudioID.Click);
		let target: any = event.target;
		if (target.name == 'btn_red') {
			
			game.restart()
		}
	}
}