UIGame.ts 2.2 KB

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