af73059e-b9d7-4062-ba4f-f0db7be3d488.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. "use strict";
  2. cc._RF.push(module, 'af730WeuddAYrpP8Nt749SI', 'ShareOrVideo');
  3. // scripts/UI/ShareOrVideo.ts
  4. "use strict";
  5. // Learn TypeScript:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  7. // Learn Attribute:
  8. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  9. // Learn life-cycle callbacks:
  10. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  11. var __extends = (this && this.__extends) || (function () {
  12. var extendStatics = function (d, b) {
  13. extendStatics = Object.setPrototypeOf ||
  14. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16. return extendStatics(d, b);
  17. };
  18. return function (d, b) {
  19. extendStatics(d, b);
  20. function __() { this.constructor = d; }
  21. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22. };
  23. })();
  24. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  25. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27. 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;
  28. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29. };
  30. Object.defineProperty(exports, "__esModule", { value: true });
  31. var CocosZ_1 = require("../Framework/CocosZ");
  32. var Constant_1 = require("../Framework/Constant");
  33. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  34. var ShareOrVideo = /** @class */ (function (_super) {
  35. __extends(ShareOrVideo, _super);
  36. function ShareOrVideo() {
  37. var _this = _super !== null && _super.apply(this, arguments) || this;
  38. _this._btn = false;
  39. _this.isGuideSKill = false;
  40. _this.shareNode = null;
  41. _this.videoNode = null;
  42. return _this;
  43. }
  44. Object.defineProperty(ShareOrVideo.prototype, "btn", {
  45. get: function () {
  46. return this._btn;
  47. },
  48. set: function (v) {
  49. this._btn = false;
  50. if (this.node.getChildByName("share")) {
  51. this.shareNode = this.node.getChildByName("share");
  52. }
  53. if (this.node.getChildByName("video")) {
  54. this.videoNode = this.node.getChildByName("video");
  55. }
  56. },
  57. enumerable: false,
  58. configurable: true
  59. });
  60. ShareOrVideo.prototype.onLoad = function () {
  61. // 监听点击
  62. this.node.on(cc.Node.EventType.TOUCH_END, function () {
  63. cc.game.emit(Constant_1.default.E_ShareOrVideo);
  64. });
  65. // 监听事件
  66. cc.game.on(Constant_1.default.E_ShareOrVideo, this.show, this);
  67. };
  68. ShareOrVideo.prototype.onDestroy = function () {
  69. // 注销事件
  70. cc.game.targetOff(this);
  71. };
  72. ShareOrVideo.prototype.start = function () {
  73. this.show();
  74. };
  75. ShareOrVideo.prototype.show = function () {
  76. if (this.isGuideSKill && CocosZ_1.cocosz.dataMgr.guide_skill) {
  77. // 隐藏分享图标
  78. if (this.shareNode && this.shareNode.isValid) {
  79. this.shareNode.active = false;
  80. }
  81. // 隐藏视频图标
  82. if (this.videoNode && this.videoNode.isValid) {
  83. this.videoNode.active = false;
  84. }
  85. }
  86. else {
  87. // 显示分享图标
  88. if (this.shareNode && this.shareNode.isValid) {
  89. this.shareNode.active = CocosZ_1.cocosz.canShare;
  90. }
  91. // 显示视频图标
  92. if (this.videoNode && this.videoNode.isValid) {
  93. this.videoNode.active = !CocosZ_1.cocosz.canShare;
  94. }
  95. }
  96. };
  97. __decorate([
  98. property()
  99. ], ShareOrVideo.prototype, "btn", null);
  100. __decorate([
  101. property({ type: cc.Boolean, tooltip: "是否新手指引免费使用" })
  102. ], ShareOrVideo.prototype, "isGuideSKill", void 0);
  103. __decorate([
  104. property({ type: cc.Node, tooltip: "分享图标" })
  105. ], ShareOrVideo.prototype, "shareNode", void 0);
  106. __decorate([
  107. property({ type: cc.Node, tooltip: "视频图标" })
  108. ], ShareOrVideo.prototype, "videoNode", void 0);
  109. ShareOrVideo = __decorate([
  110. ccclass
  111. ], ShareOrVideo);
  112. return ShareOrVideo;
  113. }(cc.Component));
  114. exports.default = ShareOrVideo;
  115. cc._RF.pop();