Main.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. const { ccclass, property } = _decorator;
  10. @ccclass('Main')
  11. export class Main extends Component {
  12. public static I: Main;
  13. _HallUI: HallUI = null;
  14. _GameUI: GameUI = null;
  15. _GameNode: GameNode = null;
  16. start() {
  17. Main.I = this;
  18. WindowManager.ins.register(this.node)
  19. WindowManager.ins.open("HallUI").then(panle => {
  20. this._HallUI = panle
  21. })
  22. WindowManager.ins.open("GameUI").then(panle => {
  23. this._GameUI = panle;
  24. this._GameUI.node.active = false;
  25. bundleMgr.loadAsset(GameConst.bundleName.resources,"prefabs/GameNode",Prefab, (err, res) => {
  26. this._GameNode = (instantiate(res) as Node).getComponent(GameNode);
  27. director.getScene().addChild(this._GameNode.node);
  28. })
  29. })
  30. }
  31. play() {
  32. this._HallUI.node.active = false;
  33. this._GameUI.node.active = true;
  34. this._GameUI.restart();
  35. this._GameNode.node.active = true;
  36. this._GameNode.restart();
  37. platformSystem.platform.hideBannerAd();
  38. }
  39. backHall() {
  40. platformSystem.platform.showBannerAd();
  41. this._GameNode.node.active = false;
  42. this._HallUI.node.active = true;
  43. this._GameUI.node.active = false;
  44. }
  45. }