123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- o =
- (this && this.__awaiter) ||
- function (t, n, r, l) {
- return new (r = r || Promise)(function (i, e) {
- function s(t) {
- try {
- a(l.next(t));
- } catch (t) {
- e(t);
- }
- }
- function o(t) {
- try {
- a(l.throw(t));
- } catch (t) {
- e(t);
- }
- }
- function a(t) {
- var e;
- t.done
- ? i(t.value)
- : ((e = t.value) instanceof r
- ? e
- : new r(function (t) {
- t(e);
- })
- ).then(s, o);
- }
- a((l = l.apply(t, n || [])).next());
- });
- };
- Object.defineProperty(i, "__esModule", {value: !0}), (i.LoadingConst = void 0);
- const a = t("App"),
- n = t("BaseController"),
- r = t("HotUpdate"),
- l = t("ViewConst"),
- h = (t("LayerManager"), t("SceneConst"));
- ((t = s = i.LoadingConst || (i.LoadingConst = {}))[(t.SetProgress = 0)] = "SetProgress"),
- (t[(t.AddProgressCompleteCB = 1)] = "AddProgressCompleteCB"),
- (t[(t.ProgressComplete = 2)] = "ProgressComplete"),
- (t[(t.SetIsShowBillBoard = 3)] = "SetIsShowBillBoard"),
- (i.default = class extends n.default {
- constructor() {
- super(),
- (this.completeCb = null),
- (this.completeTaget = null),
- (this.hotUPdate = null),
- a.default.DebugUtils.isOpen(!0),
- (this.loadProgress = {
- gameRes: {cur: 0, rate: 20},
- gameZipRes: {cur: 0, rate: 20},
- configAndLoadgame: {cur: 0, rate: 10},
- preloadRes: {cur: 0, rate: 20},
- syncData: {cur: 0, rate: 10},
- allCnt: {cur: 0, rate: 0}
- });
- let t = 0;
- for (const e in this.loadProgress) t += this.loadProgress[e].rate;
- (this.loadProgress.allCnt.rate = t),
- a.default.ViewManager.register(0, {prefabName: "LoadingView", zIndex: 0, controller: this}),
- a.default.ViewManager.register(6, {
- prefabName: "DebugUI",
- zIndex: 250,
- controller: this,
- isNotShowLoad: !0
- }),
- a.default.ViewManager.register(13, {prefabName: "TipView", zIndex: 100, controller: this}),
- a.default.ViewManager.register(5, {prefabName: "ArchiveonMgrView", zIndex: 100, controller: this}),
- a.default.ViewManager.register(14, {
- prefabName: "TipView",
- zIndex: 250,
- isNotShowLoad: !0,
- controller: this
- }),
- this.registerFunc(s.SetProgress, this.setProgress, this),
- this.registerFunc(s.AddProgressCompleteCB, this.setProgress, this),
- this.registerFunc(s.ProgressComplete, this.onProgressComplete, this),
- a.default.ViewManager.open(0);
- }
- onProgressComplete() {
- this.completeCb &&
- (this.completeCb.call(this.completeTaget), (this.completeTaget = this.completeCb = null));
- }
- onGameStart() {
- a.default.DebugUtils.stop("加载时间", "开始进入场景"), a.default.SceneManager.runScene(h.SceneTag.GAME);
- }
- onAddProgressCompleteCB(t, e) {
- (this.completeCb = t), (this.completeTaget = e);
- }
- setProgress(t, e) {
- if (((this.loadProgress[e].cur = t), this.loadingView)) {
- let t = 0;
- for (var i in this.loadProgress) t += this.loadProgress[i].cur * this.loadProgress[i].rate;
- this.loadingView.onProgress(t / this.loadProgress.allCnt.rate);
- }
- }
- onLoadView(t) {
- return o(this, void 0, void 0, function* () {
- 0 === t.viewId && this.loadGame(t);
- });
- }
- onOpenView(t) {}
- onCloseView(t) {
- return o(this, void 0, void 0, function* () {
- t.viewId === l.ViewConst.BillboardView && this.setProgress(1, "billbord");
- });
- }
- loadGame(t) {
- return o(this, void 0, void 0, function* () {
- (t = t || a.default.ViewManager.getView(0)),
- a.default.DebugUtils.start("加载时间"),
- this.onAddProgressCompleteCB(this.onGameStart, this),
- (this.loadingView = t),
- (this.hotUPdate = cc.director.getScene().getComponentInChildren(r.default)),
- this.loadingView.checkHot(),
- yield this.hotUPdate.checkUpdate((t, e, i) => {
- this.loadingView.onHotProgress(t, e, i);
- }),
- (a.default.GameDataMsr.tempData.isCheckUpdate = !0),
- Log.trace("开始加载本地存档数据!"),
- a.default.GameDataMsr.init(),
- cc.log("开始加载配置文件"),
- yield a.default.ConfigManager.loadAllConfig((t, e) => {
- this.setProgress(t / e, "configAndLoadgame");
- }, this),
- Log.trace("初始化平台类!"),
- a.default.Platform.init(),
- Log.trace("开始跟服务器同步存档数据!"),
- a.default.DebugUtils.start("同步数据"),
- yield a.default.Platform.syncData().then(() => {
- this.setProgress(1, "syncData");
- }),
- a.default.DebugUtils.stop("同步数据"),
- a.default.SaveManage.init(),
- a.default.DebugUtils.stop("加载时间", "开始加载压缩包");
- let i = yield a.default.Platform.loadZipFile((t, e) => {
- this.setProgress(t / e, "gameZipRes");
- });
- a.default.DebugUtils.stop("加载时间", "加载压缩包完毕"),
- a.default.SceneManager.preLoadScene(
- h.SceneTag.GAME,
- (t, e) => {
- this.setProgress(t / e, "gameRes"), i || this.setProgress(t / e, "gameZipRes");
- },
- null
- ),
- Log.trace("开始检查是否需要更新每日数据!"),
- a.default.GameDataMsr.loadData(),
- a.default.SaveManage.checkIsNeedUpdateData(),
- this.setProgress(1, "preloadRes"),
- a.default.SaveManage.load(a.default.SoundManager.saveKey);
- });
- }
- });
|