| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { _decorator, Component, director, Node } from 'cc';
- import PlayerData from '../game/PlayerData';
- import { ch } from '../../ch/ch';
- import { FMSType } from '../process/FMS';
- import get_new_fms from '../../core/util_class/FMS';
- import get_new_head_icon from '../../core/util_class/HeadIcon';
- const { ccclass, property } = _decorator;
- export enum GameState {
- start,//开始
- win,//成功
- over,//失败
- wait//等待
- }
- @ccclass('Hall')
- export class Hall extends Component {
- public FMS = get_new_fms();
- private static instance: Hall;
- public player: PlayerData;
- public head_icon = get_new_head_icon();
- sceneChanging: boolean = false;//场景切换
- public static getInstance(): Hall {
- return Hall.instance;
- }
- async start() {
- if (!Hall.instance) {
- Hall.instance = this;
- }
- console.log("hall start")
-
- this.init();
- }
- async init() {
- this.player = PlayerData.getInstance(ch.sdk.get_gid(), ch.sdk.get_uid().toString());
- await this.player.init_user_info();
- await this.player.load();
-
- this.to_hall()
- console.log("12121212")
- }
- to_main() {
- debugger
- this.FMS.Change(FMSType.Main);
- }
- to_hall() {
- this.FMS.Change(FMSType.Hall);
- }
- async preloadUIMainResources() {
- try {
- await new Promise<void>((resolve, reject) => {
- director.preloadScene("game", (err) => {
- if (err) reject(err);
- else resolve();
- });
- });
- } catch (error) {
- console.error("Preload failed:", error);
- }
- }
- }
|