import { PlayABC } from "../Script/Channel/PlayABC";
import AssetMgr from "../Script/Common/Module/AssetMgr/AssetMgr";
import EventMgr from "../Script/Common/Module/EventMgr/EventMgr";
import { UICtrl } from "../Script/Common/UICtrl/UICtrl";
import { View } from "../Script/Common/UICtrl/View";

//代码入口
const { ccclass, property } = cc._decorator;

@ccclass
export default class Main extends UICtrl {
	onLoad(): void {
		super.onLoad();

		// 初始化框架模块，资源管理，UI管理，网络管理，日志管理，声音管理等...
		this.init();

		//注册事件
		this.regEvent();
	}

	onDestroy(): void {
		//注销事件
		this.unEvent();
	}

	//注册事件
	regEvent() {
		//窗口变化监听
		window.addEventListener('resize', this.scaleEventCallBack, false)
	}

	//注销事件
	unEvent() {

	}

	init() {
		//初始化适配
		View.getInstance().Init();

		//初始化脚手架信息
		PlayABC.getInstance().InitData(() => {
			// //进入游戏
			// AssetMgr.loadBundlePrefab("LayerPrefab", "Game").then((Layer) => {
			// 	// Layer.addComponent("Game");
			// 	Layer.parent = this.m_view["UILayer"];
			// });
			// this.view["UILayer/Game"].addComponent("Game");
			this.view["UILayer/Game"].active = true;
		});
	}

	//屏幕缩放
	scaleEventCallBack() {
		EventMgr.emit("adjustUI");
	}
}
