GameMgr.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Learn TypeScript:
  2. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
  4. // Learn Attribute:
  5. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
  10. import GameConst from "../data/GameConst";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class GameMgr extends cc.Component {
  14. //单例模式---------------------------
  15. private static instance: GameMgr = null;
  16. public static get Inst(): GameMgr {
  17. if (!GameMgr.instance) {
  18. GameMgr.instance = new GameMgr();
  19. }
  20. return GameMgr.instance;
  21. }
  22. // LIFE-CYCLE CALLBACKS:
  23. // onLoad () {}
  24. start() {
  25. }
  26. // update (dt) {}
  27. /**
  28. * 发送事件
  29. * @param key key值 数数 不可带空格 请检查
  30. * @param value value事件值
  31. */
  32. sendEvent(key: string, value: string) {
  33. // if (!GameConst.ifSendEvent) {
  34. // return;
  35. // }
  36. // JsbMgr.sendEvent(key, value);
  37. }
  38. /**
  39. * 发送星云事件
  40. * @param key
  41. * @param value
  42. */
  43. sendEventCp(key: string, value: string) {
  44. if (!GameConst.ifSendEvent) {
  45. return;
  46. }
  47. // HttpMgr.Inst.sendEventCp(key, value);
  48. }
  49. }
  50. /**UIITEM的名称 */
  51. export enum UI_NAME {
  52. Loading = "Loading",
  53. Start = "Start",
  54. Game = "Game",
  55. DailyCashOutUI = "DailyCashOutUI",
  56. GameOverUI = "GameOverUI",
  57. GetEnergyUI = "GetEnergyUI",
  58. GetPropUI = "GetPropUI",
  59. GuideAuthUI = "GuideAuthUI",
  60. PauseUI = "PauseUI",
  61. PlayerInfoUI = "PlayerInfoUI",
  62. RedPacketUI = "RedPacketUI",
  63. SettingUI = "SettingUI",
  64. ShopUI = "ShopUI",
  65. ShopActivityUI = "ShopActivityUI",
  66. SurpriseTaskUI = "SurpriseTaskUI",
  67. AdressUI = "AdressUI"
  68. }
  69. /**UIITEM的名称 */
  70. export enum UIITEM_NAME {
  71. CashOutItem = "CashOutItem",
  72. ClockInItem = "ClockInItem",
  73. LevelRedPacketItem = "LevelRedPacketItem",
  74. ShopGoodItem = "ShopGoodItem",
  75. ShopRedPacketItem = "ShopRedPacketItem",
  76. ShopPropItem = "ShopPropItem",
  77. ShopActivityItem = "ShopActivityItem"
  78. }