Hall.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { _decorator, Component, director, Node } from 'cc';
  2. import { ch } from '../../ch/ch';
  3. import { gui } from '../../core/ui/ui';
  4. import get_new_head_icon from '../../core/util_class/HeadIcon';
  5. import PlayerData from '../game/PlayerData';
  6. import { UI_Hall } from '../ui/UI_Hall/UI_Hall';
  7. import TableLoadUtil from '../../core/util/TableLoadUtil';
  8. import { TableUtil } from '../../module_extra/table_ts/TableUtil';
  9. import { ModuleDef } from '../../Scripts/ModuleDef';
  10. const { ccclass, property } = _decorator;
  11. @ccclass('Hall')
  12. export class Hall extends Component {
  13. private static instance: Hall;
  14. public player:PlayerData;
  15. public head_icon=get_new_head_icon();
  16. public static getInstance():Hall{
  17. return Hall.instance;
  18. }
  19. start() {
  20. if(!Hall.instance){
  21. Hall.instance=this;
  22. }
  23. gui.show(UI_Hall);
  24. director.addPersistRootNode(this.node);
  25. this.init();
  26. this.loadTable();
  27. }
  28. async init(){
  29. this.player = PlayerData.getInstance(ch.sdk.get_gid(), ch.sdk.get_uid().toString());
  30. this.player.init_user_info();
  31. await this.player.load();
  32. }
  33. private loadTable(): void {
  34. // ch.log.log_start("加载配置初始化");
  35. TableLoadUtil.preloadAll(ModuleDef.EXTRA, "table_json", async () => {
  36. // this.onPreloadingComplete();
  37. console.log("加载配置初始化完成");
  38. }, TableUtil.set);
  39. }
  40. }