GameMgr.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. DailyCashOutUI = "DailyCashOutUI",
  57. GameOverUI = "GameOverUI",
  58. GetEnergyUI = "GetEnergyUI",
  59. GetPropUI = "GetPropUI",
  60. GuideAuthUI = "GuideAuthUI",
  61. PauseUI = "PauseUI",
  62. PlayerInfoUI = "PlayerInfoUI",
  63. RedPacketUI = "RedPacketUI",
  64. SettingUI = "SettingUI",
  65. ShopUI = "ShopUI",
  66. ShopActivityUI = "ShopActivityUI",
  67. SurpriseTaskUI = "SurpriseTaskUI",
  68. AdressUI = "AdressUI"
  69. }
  70. /**UIITEM的名称 */
  71. export enum UIITEM_NAME {
  72. CashOutItem = "CashOutItem",
  73. ClockInItem = "ClockInItem",
  74. LevelRedPacketItem = "LevelRedPacketItem",
  75. ShopGoodItem = "ShopGoodItem",
  76. ShopRedPacketItem = "ShopRedPacketItem",
  77. ShopPropItem = "ShopPropItem",
  78. ShopActivityItem = "ShopActivityItem"
  79. }