Hall.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { _decorator, Component, director, Node, profiler } 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. async start() {
  20. if (!Hall.instance) {
  21. Hall.instance = this;
  22. }
  23. this.init();
  24. gui.show(UI_Hall);
  25. director.addPersistRootNode(this.node);
  26. // if(chsdk.checkFromSidebar())
  27. // {
  28. // Hall.getInstance().player.add_item(2,2);
  29. // }
  30. }
  31. async init() {
  32. this.loadTable();
  33. this.player = PlayerData.getInstance(ch.sdk.get_gid(), ch.sdk.get_uid().toString());
  34. this.player.init_user_info();
  35. await this.player.load();
  36. this.player.set_login_num(1);
  37. console.log("登录次数:" + this.player.get_login_num());
  38. }
  39. private loadTable(): void {
  40. ch.log.log_start("加载配置初始化");
  41. TableLoadUtil.preloadAll(ModuleDef.EXTRA, "table_json", async () => {
  42. }, TableUtil.set);
  43. }
  44. }