import SDK from "./sdk/SDK"; import { App } from "./Manager/App"; import hallModel from "./model/hallModel"; import NotifyModel from "./model/NotifyModel"; import TimeControl from "./TimeControl"; import { EncryptType } from "./sdk/tools/EncryptUtil"; const { ccclass, property } = cc._decorator; @ccclass export default class loadScene extends cc.Component { @property(cc.Label) public percentLabel: cc.Label = null; @property(cc.ProgressBar) public loadingBar: cc.ProgressBar = null; private loadSceneName: string = "hallScene"; // LIFE-CYCLE CALLBACKS: onLoad() { App.Facade.init(false, cc.size(720, 1280), false, true); App.startUp(); App.DataManager.init(); TimeControl.instance.OfflineTime(); this.initModel(); let gameId: any = "richestMan"; SDK.Instance.init(gameId, EncryptType.ED_CM); this.LoadOther(); } initModel(): void { App.Facade.registerModel(hallModel); App.Facade.registerModel(NotifyModel); } LoadOther() { // this.loadConfigs(() => { App.DataManager.LoadAllPropPrefab(this.loadScene.bind(this)) }); // App.DataManager.LoadAllPropPrefab(this.loadScene.bind(this)) ; this.loadScene(); } // private loadConfig() { // App.ConfigMgr.loadConfigs(this.loadScene.bind(this)); // } private loadScene() { App.Facade.runBundleScene(this.loadSceneName,this.loadSceneName,this.loadHallProgress.bind(this)) } /** 导入配置文件 */ private loadConfigs(cb: Function) { console.log("读取配置文件"); let url = "configs" let self = this; cc.loader.loadResDir(url, cc.Asset, (err, res) => { App.DataManager.Configs = res; App.DataManager.LevelCount = res.length; res.sort((a: any, b: any) => { return Number(a._name) - Number(b._name) }); console.log("配置文件解析完成", res); cb(); }) } /**加载大厅界面进度*/ private loadHallProgress(completedCount: number, totalCount: number, item: any) { let progress = completedCount / totalCount; this.setProgress(Math.round(progress * 100)); } /**加载进度 */ private setProgress(value: number) { this.loadingBar.progress = value / 100; this.percentLabel.getComponent(cc.Label).string = value + "%"; } // update (dt) {} }