GameMgr.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. import HttpMgr from "./HttpMgr";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class GameMgr extends cc.Component {
  15. //单例模式---------------------------
  16. private static instance: GameMgr = null;
  17. public static get Inst(): GameMgr {
  18. if (!GameMgr.instance) {
  19. GameMgr.instance = new GameMgr();
  20. }
  21. return GameMgr.instance;
  22. }
  23. // LIFE-CYCLE CALLBACKS:
  24. // onLoad () {}
  25. start() {
  26. }
  27. // update (dt) {}
  28. /**
  29. * 发送事件
  30. * @param key key值 数数 不可带空格 请检查
  31. * @param value value事件值
  32. */
  33. sendEvent(key: string, value: string) {
  34. // if (!GameConst.ifSendEvent) {
  35. // return;
  36. // }
  37. // JsbMgr.sendEvent(key, value);
  38. }
  39. /**
  40. * 发送星云事件
  41. * @param key
  42. * @param value
  43. */
  44. sendEventCp(key: string, value: string) {
  45. if (!GameConst.ifSendEvent) {
  46. return;
  47. }
  48. HttpMgr.Inst.sendEventCp(key, value);
  49. }
  50. }
  51. /**UIITEM的名称 */
  52. export enum UI_NAME {
  53. Loading = "Loading",
  54. Start = "Start",
  55. Game = "Game",
  56. CashOutUI = "CashOutUI",
  57. ClockInUI = "ClockInUI",
  58. DailyCashOutUI = "DailyCashOutUI",
  59. GameOverUI = "GameOverUI",
  60. GetEnergyUI = "GetEnergyUI",
  61. GetPropUI = "GetPropUI",
  62. GuideAuthUI = "GuideAuthUI",
  63. LevelRedPacketUI = "LevelRedPacketUI",
  64. PauseUI = "PauseUI",
  65. PlayerInfoUI = "PlayerInfoUI",
  66. RedPacketUI = "RedPacketUI",
  67. SettingUI = "SettingUI",
  68. ShopUI = "ShopUI",
  69. ShopActivityUI = "ShopActivityUI",
  70. SurpriseTaskUI = "SurpriseTaskUI",
  71. AdressUI = "AdressUI"
  72. }
  73. /**UIITEM的名称 */
  74. export enum UIITEM_NAME {
  75. CashOutItem = "CashOutItem",
  76. ClockInItem = "ClockInItem",
  77. LevelRedPacketItem = "LevelRedPacketItem",
  78. ShopGoodItem = "ShopGoodItem",
  79. ShopRedPacketItem = "ShopRedPacketItem",
  80. ShopPropItem = "ShopPropItem",
  81. ShopActivityItem = "ShopActivityItem"
  82. }