System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7", "__unresolved_8", "__unresolved_9", "__unresolved_10"], function (_export, _context) { "use strict"; var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, director, ResUtil, TableLoadUtil, get_new_head_icon, TableUtil, ModuleDef, SceneDef, PlayerData, ch, gui, UI_Hall, _dec, _class, _class2, _crd, ccclass, property, GameState, life_countdown_Max, Hall; function _reportPossibleCrUseOfResUtil(extras) { _reporterNs.report("ResUtil", "../../core/util/ResUtil", _context.meta, extras); } function _reportPossibleCrUseOfTableLoadUtil(extras) { _reporterNs.report("TableLoadUtil", "../../core/util/TableLoadUtil", _context.meta, extras); } function _reportPossibleCrUseOfget_new_head_icon(extras) { _reporterNs.report("get_new_head_icon", "../../core/util_class/HeadIcon", _context.meta, extras); } function _reportPossibleCrUseOfTableUtil(extras) { _reporterNs.report("TableUtil", "../../module_extra/table_ts/TableUtil", _context.meta, extras); } function _reportPossibleCrUseOfModuleDef(extras) { _reporterNs.report("ModuleDef", "../../Scripts/ModuleDef", _context.meta, extras); } function _reportPossibleCrUseOfSceneDef(extras) { _reporterNs.report("SceneDef", "../../Scripts/SceneDef", _context.meta, extras); } function _reportPossibleCrUseOfPlayerData(extras) { _reporterNs.report("PlayerData", "../game/PlayerData", _context.meta, extras); } function _reportPossibleCrUseOfch(extras) { _reporterNs.report("ch", "../../ch/ch", _context.meta, extras); } function _reportPossibleCrUseOfgui(extras) { _reporterNs.report("gui", "../../core/ui/ui", _context.meta, extras); } function _reportPossibleCrUseOfUI_Hall(extras) { _reporterNs.report("UI_Hall", "../ui/UI_Hall/UI_Hall", _context.meta, extras); } return { setters: [function (_unresolved_) { _reporterNs = _unresolved_; }, function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; _decorator = _cc._decorator; Component = _cc.Component; director = _cc.director; }, function (_unresolved_2) { ResUtil = _unresolved_2.ResUtil; }, function (_unresolved_3) { TableLoadUtil = _unresolved_3.default; }, function (_unresolved_4) { get_new_head_icon = _unresolved_4.default; }, function (_unresolved_5) { TableUtil = _unresolved_5.TableUtil; }, function (_unresolved_6) { ModuleDef = _unresolved_6.ModuleDef; }, function (_unresolved_7) { SceneDef = _unresolved_7.SceneDef; }, function (_unresolved_8) { PlayerData = _unresolved_8.default; }, function (_unresolved_9) { ch = _unresolved_9.ch; }, function (_unresolved_10) { gui = _unresolved_10.gui; }, function (_unresolved_11) { UI_Hall = _unresolved_11.UI_Hall; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "7cb62YJXe5LPKnKF0hMl+Rc", "Hall", undefined); __checkObsolete__(['_decorator', 'Component', 'director', 'Node', 'profiler']); ({ ccclass, property } = _decorator); _export("GameState", GameState = /*#__PURE__*/function (GameState) { GameState[GameState["gameing"] = 0] = "gameing"; GameState[GameState["wait"] = 1] = "wait"; GameState[GameState["win"] = 2] = "win"; GameState[GameState["fail"] = 3] = "fail"; return GameState; }({})); _export("life_countdown_Max", life_countdown_Max = 1800); _export("Hall", Hall = (_dec = ccclass('Hall'), _dec(_class = (_class2 = class Hall extends Component { constructor(...args) { super(...args); this.player = void 0; this.head_icon = (_crd && get_new_head_icon === void 0 ? (_reportPossibleCrUseOfget_new_head_icon({ error: Error() }), get_new_head_icon) : get_new_head_icon)(); this.sceneChanging = false; //场景切换 this.bornRunning = false; // 是否在生成中 this.gameState = GameState.win; this.firstEnter = false; } static getInstance() { return Hall.instance; } onEnable() { // 计算离线时间,并更新倒计时 this.startLifeTimer(); } onLoad() { window.addEventListener('beforeunload', async () => { let res = Date.now(); if (res) { const nowTimestamp = Math.floor(res / 1000); // 记录当前时间(秒) this.player.set_last_exit_time(nowTimestamp); if (this.gameState == GameState.fail || this.gameState == GameState.wait || this.gameState == GameState.gameing) { if (this.player.get_life() > 0) { this.player.set_life(this.player.get_life() - 1); } } } }); window['wx'].onShow(async () => { let res = Date.now(); if (res) { const nowTimestamp = Math.floor(res / 1000); // 记录当前时间(秒) this.player.set_last_exit_time(nowTimestamp); if (this.gameState == GameState.wait || this.gameState == GameState.gameing) { this.player.set_life(this.player.get_life() + 1); } } }); window['wx'].onHide(async () => { let res = Date.now(); if (res) { const nowTimestamp = Math.floor(res / 1000); // 记录当前时间(秒) this.player.set_last_exit_time(nowTimestamp); if (this.gameState == GameState.fail || this.gameState == GameState.wait || this.gameState == GameState.gameing) { if (this.player.get_life() > 0) { this.player.set_life(this.player.get_life() - 1); } } } }); } async start() { if (!Hall.instance) { Hall.instance = this; } this.init(); director.addPersistRootNode(this.node); // if(chsdk.checkFromSidebar()) // { // Hall.getInstance().player.add_item(2,2); // } } async init() { await this.loadTable(); this.player = (_crd && PlayerData === void 0 ? (_reportPossibleCrUseOfPlayerData({ error: Error() }), PlayerData) : PlayerData).getInstance((_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.get_gid(), (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).sdk.get_uid().toString()); await this.player.init_user_info(); await this.player.load(); this.player.set_login_num(1); if (this.player.get_max_floor() == 0) { this.firstEnter = true; Hall.getInstance().player.set_life(5); (_crd && ResUtil === void 0 ? (_reportPossibleCrUseOfResUtil({ error: Error() }), ResUtil) : ResUtil).loadScene((_crd && SceneDef === void 0 ? (_reportPossibleCrUseOfSceneDef({ error: Error() }), SceneDef) : SceneDef).GAME, (_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({ error: Error() }), ModuleDef) : ModuleDef).GAME, true); } else { (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).show(_crd && UI_Hall === void 0 ? (_reportPossibleCrUseOfUI_Hall({ error: Error() }), UI_Hall) : UI_Hall); } await this.calculateOfflineTime(); this.startLifeTimer(); } loadTable() { (_crd && ch === void 0 ? (_reportPossibleCrUseOfch({ error: Error() }), ch) : ch).log.log_start("加载配置初始化"); (_crd && TableLoadUtil === void 0 ? (_reportPossibleCrUseOfTableLoadUtil({ error: Error() }), TableLoadUtil) : TableLoadUtil).preloadAll((_crd && ModuleDef === void 0 ? (_reportPossibleCrUseOfModuleDef({ error: Error() }), ModuleDef) : ModuleDef).EXTRA, "table_json", async () => {}, (_crd && TableUtil === void 0 ? (_reportPossibleCrUseOfTableUtil({ error: Error() }), TableUtil) : TableUtil).set); } async calculateOfflineTime() { const lastExitTime = this.player.get_last_exit_time(); console.log(`上次退出时间: ${new Date(lastExitTime * 1000)}`); if (!lastExitTime) return; const lastExitTimestamp = lastExitTime; let res = Date.now(); if (res) { const nowTimestamp = Math.floor(res / 1000); // 以秒为单位 console.log(`当前时间: ${new Date(nowTimestamp * 1000)}`); const elapsedTime = nowTimestamp - lastExitTimestamp; console.log(`离线时间: ${elapsedTime} 秒`); let countdown = this.player.get_life_countdown(); this.player.set_life(this.player.get_life() + Math.floor(elapsedTime / life_countdown_Max)); if (this.player.get_life() >= 10) { this.player.set_life_countdown(0); } else { this.player.set_life_countdown((countdown - elapsedTime) % life_countdown_Max); } } } startLifeTimer() { this.unschedule(this.LifeCountDownTimer); this.schedule(this.LifeCountDownTimer, 1.0); } LifeCountDownTimer() { if (!this.player) { console.warn("Player 未初始化,跳过倒计时"); return; } console.log('计时器启动'); if (this.player.get_life() < 5) { if (this.player.get_life_countdown() > 0) { console.log("正在执行倒计时:" + (this.player.get_life_countdown() - 1)); this.player.set_life_countdown(this.player.get_life_countdown() - 1); if (director.getScene().name == "hall") { var _get; console.log("倒计时显示刷新:" + this.player.get_life_countdown()); (_get = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Hall === void 0 ? (_reportPossibleCrUseOfUI_Hall({ error: Error() }), UI_Hall) : UI_Hall)) == null || _get.set_Life_CountDown(this.player.get_life_countdown(), true); } } else { var _get2; this.player.set_life(this.player.get_life() + 1); (_get2 = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Hall === void 0 ? (_reportPossibleCrUseOfUI_Hall({ error: Error() }), UI_Hall) : UI_Hall)) == null || _get2.set_Life(this.player.get_life()); if (this.player.get_life() != 5) { var _get3; this.player.set_life_countdown(life_countdown_Max); (_get3 = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Hall === void 0 ? (_reportPossibleCrUseOfUI_Hall({ error: Error() }), UI_Hall) : UI_Hall)) == null || _get3.set_Life_CountDown(this.player.get_life_countdown(), true); } } } else { if (director.getScene().name == "hall") { var _get4; (_get4 = (_crd && gui === void 0 ? (_reportPossibleCrUseOfgui({ error: Error() }), gui) : gui).get(_crd && UI_Hall === void 0 ? (_reportPossibleCrUseOfUI_Hall({ error: Error() }), UI_Hall) : UI_Hall)) == null || _get4.set_Life_CountDown(this.player.get_life_countdown(), false); } } } }, _class2.instance = void 0, _class2)) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=ae09e1dc27462fa243348fea3c76bfbe0bbcfc5f.js.map