RedpointComponent.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function(t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", { value: !0 });
  17. const s = t("App"),
  18. o = t("RedPointMgr"),
  19. { ccclass: a, property: n, menu: r, executeInEditMode: l } = cc._decorator;
  20. t = class extends cc.Component {
  21. constructor() {
  22. super(...arguments),
  23. (this._isMulti = !1),
  24. (this.types = []),
  25. (this._type = 0),
  26. (this.numLab = null),
  27. (this.redNode = null);
  28. }
  29. set isMulti(t) {
  30. (this._isMulti = t) || (this.types.length = 1);
  31. }
  32. get isMulti() {
  33. return this._isMulti;
  34. }
  35. set type(t) {
  36. this.isMulti ? (this._type = t) : (this.types[0] = Object.keys(o.RedPointMgr.types)[t]);
  37. }
  38. get type() {
  39. return this.isMulti ? this._type : Object.keys(o.RedPointMgr.types).indexOf(this.types[0]);
  40. }
  41. addType() {
  42. var t;
  43. !this.isMulti ||
  44. ((t = Object.keys(o.RedPointMgr.types)[this._type]) && -1 === this.types.indexOf(t) && this.types.push(t));
  45. }
  46. deleteType() {
  47. var t;
  48. !this.isMulti || ((t = Object.keys(o.RedPointMgr.types)[this._type]) && this.types.remove(t));
  49. }
  50. onLoad() {}
  51. onEnable() {
  52. this.types.length &&
  53. this.redNode &&
  54. (1 === this.types.length ?
  55. s.default.RedPointMgr.subscribe(this.types[0], this.onUpdateRed, this) :
  56. s.default.RedPointMgr.subscribeGroup(this.types, this.onUpdateRed, this));
  57. }
  58. onDisable() {
  59. this.types.length &&
  60. this.redNode &&
  61. (1 === this.types.length ?
  62. s.default.RedPointMgr.unsubscribe(this.types[0], this.onUpdateRed, this) :
  63. s.default.RedPointMgr.unsubscribeGroup(this));
  64. }
  65. onUpdateRed(t) {
  66. "number" == typeof t
  67. ?
  68. (this.numLab && ((this.numLab.string = t + ""), (this.numLab.node.active = !0)),
  69. (this.redNode.active = !!t)) :
  70. (this.numLab && (this.numLab.node.active = !1), (this.redNode.active = t));
  71. }
  72. };
  73. e([n({ editorOnly: !0 })], t.prototype, "_isMulti", void 0),
  74. e([n({})], t.prototype, "isMulti", null),
  75. e(
  76. [
  77. n({
  78. type: cc.String,
  79. readonly: !0,
  80. visible: function() {
  81. return this.isMulti;
  82. }
  83. })
  84. ],
  85. t.prototype,
  86. "types",
  87. void 0
  88. ),
  89. e([n({ editorOnly: !0 })], t.prototype, "_type", void 0),
  90. e([n({ type: cc.Enum({}) })], t.prototype, "type", null),
  91. e([n(cc.Label)], t.prototype, "numLab", void 0),
  92. e([n(cc.Node)], t.prototype, "redNode", void 0),
  93. (t = e([a, l], t)),
  94. (i.default = t);