7a7b363a-f4eb-4c35-b135-9c98d88343d7.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. "use strict";
  2. cc._RF.push(module, '7a7b3Y69OtMNbE1nJjYg0PX', 'redPoint');
  3. // scripts/UI/redPoint.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var CocosZ_1 = require("../Framework/CocosZ");
  26. var Constant_1 = require("../Framework/Constant");
  27. var gameDate_1 = require("../Game/gameDate");
  28. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  29. var RedPointType;
  30. (function (RedPointType) {
  31. RedPointType[RedPointType["none"] = 0] = "none";
  32. RedPointType[RedPointType["sign"] = 1] = "sign";
  33. RedPointType[RedPointType["turntable"] = 2] = "turntable";
  34. RedPointType[RedPointType["online"] = 3] = "online";
  35. })(RedPointType || (RedPointType = {}));
  36. var RedPoint = /** @class */ (function (_super) {
  37. __extends(RedPoint, _super);
  38. function RedPoint() {
  39. var _this = _super !== null && _super.apply(this, arguments) || this;
  40. _this.type = RedPointType.none;
  41. _this.refreshOnClick = true;
  42. _this.isRefresh = false;
  43. _this.isTweenAngle = false;
  44. _this.isTweenScale = false;
  45. _this.isListen = false;
  46. return _this;
  47. }
  48. RedPoint.prototype.start = function () {
  49. var _this = this;
  50. this.node.opacity = 0;
  51. // 刷新
  52. this.setRedPoint();
  53. if (this.isRefresh) {
  54. cc.tween(this.node)
  55. .delay(1)
  56. .call(function () { _this.setRedPoint(); })
  57. .union()
  58. .repeatForever()
  59. .start();
  60. }
  61. // 缓动角度
  62. if (this.isTweenAngle) {
  63. cc.tween(this.node).by(0.25, { angle: 15 }).by(0.25 * 2, { angle: -30 }).by(0.25, { angle: 15 }).delay(1).union().repeatForever().start();
  64. }
  65. // 缓动缩放
  66. if (this.isTweenScale) {
  67. cc.tween(this.node).by(0.25, { scale: 0.1 }).by(0.25 * 2, { scale: -0.2 }).by(0.25, { scale: 0.1 }).delay(1).union().repeatForever().start();
  68. }
  69. // 监听事件
  70. if (this.isListen) {
  71. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMessageHandler, this);
  72. }
  73. };
  74. /** 销毁监听 */
  75. RedPoint.prototype.onDestroy = function () {
  76. cc.game.targetOff(this);
  77. };
  78. /** 监听事件 */
  79. RedPoint.prototype._onGameMessageHandler = function (event) {
  80. switch (event.type) {
  81. }
  82. };
  83. /** 监听消息 */
  84. RedPoint.prototype.onClick = function () {
  85. // 本地存储
  86. switch (this.type) {
  87. }
  88. // 点击父节点刷新红点
  89. if (this.refreshOnClick) {
  90. this.setRedPoint();
  91. }
  92. };
  93. /** 显示 */
  94. RedPoint.prototype.show = function () {
  95. this.node.opacity = 255;
  96. // 点击监听
  97. if (this.node.parent) {
  98. this.node.parent.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
  99. }
  100. };
  101. /** 隐藏 */
  102. RedPoint.prototype.hide = function () {
  103. this.node.opacity = 0;
  104. // 取消监听
  105. if (this.node.parent) {
  106. this.node.parent.off(cc.Node.EventType.TOUCH_END, this.onClick, this);
  107. }
  108. };
  109. /** 设置红点 */
  110. RedPoint.prototype.setRedPoint = function () {
  111. switch (this.type) {
  112. case RedPointType.sign: {
  113. var bool = (new Date().toDateString() != CocosZ_1.cocosz.dataMgr.LastDailyBonusTime);
  114. bool ? this.show() : this.hide();
  115. break;
  116. }
  117. case RedPointType.turntable: {
  118. var bool = (CocosZ_1.cocosz.useCJTimes < Constant_1.default.commonCJTimes);
  119. bool ? this.show() : this.hide();
  120. break;
  121. }
  122. case RedPointType.online: {
  123. var arr = CocosZ_1.cocosz.dataMgr.receiveToday;
  124. for (var i = 0; i < arr.length; i++) {
  125. if (!arr[i]) {
  126. if (CocosZ_1.cocosz.dataMgr.OnlineToday > gameDate_1.default.TimeReward[i].time) {
  127. this.show();
  128. return;
  129. }
  130. }
  131. }
  132. this.hide();
  133. break;
  134. }
  135. }
  136. };
  137. __decorate([
  138. property({ type: cc.Enum(RedPointType), tooltip: "红点类型" })
  139. ], RedPoint.prototype, "type", void 0);
  140. __decorate([
  141. property({ tooltip: "点击父节点刷新红点" })
  142. ], RedPoint.prototype, "refreshOnClick", void 0);
  143. __decorate([
  144. property({ tooltip: "是否刷新" })
  145. ], RedPoint.prototype, "isRefresh", void 0);
  146. __decorate([
  147. property({ tooltip: "是否缓动角度" })
  148. ], RedPoint.prototype, "isTweenAngle", void 0);
  149. __decorate([
  150. property({ tooltip: "是否缓动缩放" })
  151. ], RedPoint.prototype, "isTweenScale", void 0);
  152. __decorate([
  153. property({ tooltip: "是否监听" })
  154. ], RedPoint.prototype, "isListen", void 0);
  155. RedPoint = __decorate([
  156. ccclass
  157. ], RedPoint);
  158. return RedPoint;
  159. }(cc.Component));
  160. exports.default = RedPoint;
  161. cc._RF.pop();