UIGame.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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) mapPrefab: cc.Prefab = null
  24. @property(cc.Node) mapLayer: cc.Node = null
  25. // @property(cc.Prefab) uiMapGuideSkip: cc.Prefab = null
  26. @property(cc.Prefab) safeAreaNode: cc.Prefab = null
  27. public static Instance: UIGame;
  28. protected async onLoad(): Promise<void> {
  29. //初始化fgui
  30. FguiMgr.Instance.Init();
  31. Config.inGame = InGame.home
  32. UIGame.Instance = this;
  33. }
  34. protected onEnable(): void {
  35. }
  36. protected onDisable(): void {
  37. }
  38. protected start(): void {
  39. //清空已经打开的fgui界面
  40. FguiMgr.Instance.clearCacheMap()
  41. // 网络遮罩层
  42. AssetMgr.instantiate(cc.director.getScene(), this.safeAreaNode);
  43. // AssetMgr.instantiate(cc.director.getScene(), this.uiHand)
  44. AssetMgr.instantiate(cc.director.getScene(), this.guideView)
  45. AssetMgr.instantiate(cc.director.getScene(), this.handMaskView)
  46. // AssetMgr.instantiate(cc.director.getScene(), this.dialogView)
  47. AssetMgr.instantiate(cc.director.getScene(), this.uiMask)
  48. AssetMgr.instantiate(cc.director.getScene(), this.netMask)
  49. this.EnterGame();
  50. }
  51. async EnterGame(closeFunc?: Function) {
  52. // 进入游戏
  53. FguiMgr.Instance.openUI(HomeView, ViewZOrder.Home)
  54. }
  55. //fgui相关
  56. protected onDestroy(): void {
  57. FguiMgr.Instance.Dispose()
  58. }
  59. protected update(dt: number): void {
  60. FguiMgr.Instance.OnUpdate(dt)
  61. }
  62. protected lateUpdate(dt: number): void {
  63. FguiMgr.Instance.OnLateUpdate(dt)
  64. }
  65. }