Main.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { _decorator, Component, Node, Prefab, director, instantiate } from 'cc';
  2. import { GameNode } from './GameNode';
  3. import { GameUI } from './GameUI';
  4. import { HallUI } from './HallUI';
  5. import WindowManager from '../core/manager/WindowManager';
  6. import platformSystem from '../platform/platformSystem';
  7. import { bundleMgr } from '../core/manager/BundleManager';
  8. import { GameConst } from '../core/common/GameConst';
  9. import { audioMgr } from '../core/manager/AudioManager';
  10. import { settingData } from '../user/SettingData';
  11. import BasePanel from '../core/component/BasePanel';
  12. const { ccclass, property } = _decorator;
  13. @ccclass('Main')
  14. export class Main extends BasePanel {
  15. @property({type:Node,tooltip:"资源加载lable"})
  16. public start_bg: Node;
  17. public static I: Main;
  18. _HallUI: HallUI = null;
  19. _GameUI: GameUI = null;
  20. _GameNode: GameNode = null;
  21. start(){
  22. if(settingData.data.bgMusic){
  23. audioMgr.play(GameConst.audios.bg_music,true);
  24. }
  25. Main.I = this;
  26. WindowManager.ins.register(this.node)
  27. WindowManager.ins.open("HallUI").then(panle => {
  28. this._HallUI = panle
  29. })
  30. WindowManager.ins.open("GameUI").then(async panle => {
  31. this._GameUI = panle;
  32. this._GameUI.node.active = false;
  33. let res: any = await bundleMgr.loadAsset(GameConst.bundleName.resources,"prefabs/GameNode",Prefab)
  34. this._GameNode = instantiate(res).getComponent(GameNode);
  35. director.getScene().addChild(this._GameNode.node);
  36. })
  37. }
  38. play() {
  39. this.start_bg.active = false;
  40. this._HallUI.node.active = false;
  41. this._GameUI.node.active = true;
  42. this._GameUI.restart();
  43. this._GameNode.node.active = true;
  44. this._GameNode.restart();
  45. platformSystem.platform.hideBannerAd();
  46. }
  47. backHall() {
  48. platformSystem.platform.showBannerAd();
  49. this.start_bg.active = true;
  50. this._GameNode.node.active = false;
  51. this._HallUI.node.active = true;
  52. this._GameUI.node.active = false;
  53. }
  54. }