ef4650e3d820747f29e4bf013638014f42bf57bb.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Singleton, Constants, userIns, _dec, _class, _crd, ccclass, property, StateManager, stateMgr;
  4. function _reportPossibleCrUseOfSingleton(extras) {
  5. _reporterNs.report("Singleton", "./Singleton", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfConstants(extras) {
  8. _reporterNs.report("Constants", "../../data/Constants", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfuserIns(extras) {
  11. _reporterNs.report("userIns", "../../data/UserData", _context.meta, extras);
  12. }
  13. return {
  14. setters: [function (_unresolved_) {
  15. _reporterNs = _unresolved_;
  16. }, function (_cc) {
  17. _cclegacy = _cc.cclegacy;
  18. __checkObsolete__ = _cc.__checkObsolete__;
  19. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  20. _decorator = _cc._decorator;
  21. }, function (_unresolved_2) {
  22. Singleton = _unresolved_2.Singleton;
  23. }, function (_unresolved_3) {
  24. Constants = _unresolved_3.Constants;
  25. }, function (_unresolved_4) {
  26. userIns = _unresolved_4.userIns;
  27. }],
  28. execute: function () {
  29. _crd = true;
  30. _cclegacy._RF.push({}, "d10a2XpdK9L24FMMF9uqCTp", "StateManager", undefined);
  31. __checkObsolete__(['_decorator', 'Label', 'Node']);
  32. ({
  33. ccclass,
  34. property
  35. } = _decorator);
  36. StateManager = (_dec = ccclass('StateManager'), _dec(_class = class StateManager extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
  37. error: Error()
  38. }), Singleton) : Singleton) {
  39. constructor() {
  40. super(...arguments);
  41. //存储状态字段与 UI 组件的绑定关系
  42. this.uiBindings = new Map();
  43. }
  44. /**
  45. * 注册UI组件
  46. * @param field 注册的key uiName
  47. * @param label 具体的文本
  48. */
  49. registerUI(field, label) {
  50. if (!this.uiBindings.has(field)) {
  51. this.uiBindings.set(field, []);
  52. } //将UI组件添加到绑定列表
  53. var uiArr = this.uiBindings.get(field);
  54. if (!uiArr.includes(label)) {
  55. uiArr.push(label);
  56. } //初始化UI显示
  57. this.updateSingleUI(field, label);
  58. }
  59. /**
  60. * 全局更新所有绑定该字段
  61. * @param field 注册的key uiName
  62. */
  63. updateAllUI(field) {
  64. var labels = this.uiBindings.get(field);
  65. if (labels) {
  66. labels.forEach(label => {
  67. this.updateSingleUI(field, label);
  68. });
  69. }
  70. }
  71. /**
  72. * 更新单个UI组件
  73. * @param field
  74. * @param label
  75. */
  76. updateSingleUI(field, com) {
  77. if (field == (_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
  78. error: Error()
  79. }), Constants) : Constants).gold) {
  80. //金币数量
  81. com.string = "" + (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  82. error: Error()
  83. }), userIns) : userIns).data.gold;
  84. } else if (field == (_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
  85. error: Error()
  86. }), Constants) : Constants).diamond) {
  87. //钻石数量
  88. com.string = "" + (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  89. error: Error()
  90. }), userIns) : userIns).data.diamond;
  91. } else if (field == (_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
  92. error: Error()
  93. }), Constants) : Constants).levelTask) {//任务数据变化
  94. }
  95. }
  96. }) || _class); //全局单例
  97. _export("stateMgr", stateMgr = StateManager.ins());
  98. _cclegacy._RF.pop();
  99. _crd = false;
  100. }
  101. };
  102. });
  103. //# sourceMappingURL=ef4650e3d820747f29e4bf013638014f42bf57bb.js.map