Main.ts 2.2 KB

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