UIGame.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import Config from "../../../Config";
  2. import { GuideType, InGame, OpenType } from "../../../data/const/TypeConst";
  3. import { ViewZOrder } from "../../../data/const/ViewZOrder";
  4. import FguiMgr from "../../../frameWork/fgui/FguiMgr";
  5. import AssetMgr from "../../../utils/AssetMgr";
  6. import { HomeView } from "../../fgui/Home/Home/HomeView";
  7. const { ccclass, menu, property } = cc._decorator;
  8. @ccclass
  9. @menu("UI/scene/UIGame")
  10. export default class UIGame extends cc.Component {
  11. @property(cc.Prefab)
  12. uiHand: cc.Prefab = null
  13. @property(cc.Prefab)
  14. uiMask: cc.Prefab = null
  15. @property(cc.Prefab)
  16. netMask: cc.Prefab = null
  17. @property(cc.Prefab)
  18. guideView: cc.Prefab = null
  19. @property(cc.Prefab)
  20. handMaskView: cc.Prefab = null
  21. @property(cc.Prefab)
  22. dialogView: cc.Prefab = null
  23. // @property(cc.Prefab) uiMapGuideSkip: cc.Prefab = null
  24. @property(cc.Prefab) safeAreaNode: cc.Prefab = null
  25. public static Instance: UIGame;
  26. protected async onLoad(): Promise<void> {
  27. //初始化fgui
  28. FguiMgr.Instance.Init();
  29. Config.inGame = InGame.home
  30. UIGame.Instance = this;
  31. }
  32. protected onEnable(): void {
  33. }
  34. protected onDisable(): void {
  35. }
  36. protected start(): void {
  37. //清空已经打开的fgui界面
  38. FguiMgr.Instance.clearCacheMap()
  39. // 网络遮罩层
  40. AssetMgr.instantiate(cc.director.getScene(), this.safeAreaNode);
  41. // AssetMgr.instantiate(cc.director.getScene(), this.uiHand)
  42. AssetMgr.instantiate(cc.director.getScene(), this.guideView)
  43. AssetMgr.instantiate(cc.director.getScene(), this.handMaskView)
  44. AssetMgr.instantiate(cc.director.getScene(), this.dialogView)
  45. AssetMgr.instantiate(cc.director.getScene(), this.uiMask)
  46. AssetMgr.instantiate(cc.director.getScene(), this.netMask)
  47. this.EnterGame();
  48. }
  49. async EnterGame(closeFunc?: Function) {
  50. // 进入游戏
  51. FguiMgr.Instance.openUI(HomeView, ViewZOrder.Home)
  52. }
  53. //fgui相关
  54. protected onDestroy(): void {
  55. FguiMgr.Instance.Dispose()
  56. }
  57. protected update(dt: number): void {
  58. FguiMgr.Instance.OnUpdate(dt)
  59. }
  60. protected lateUpdate(dt: number): void {
  61. FguiMgr.Instance.OnLateUpdate(dt)
  62. }
  63. }