6f201f73-e99c-476c-bfde-674de364e434.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. "use strict";
  2. cc._RF.push(module, '6f2019z6ZxHbL/eZ03jZOQ0', 'RewardBoxPanel');
  3. // common-plugin/Scripts/RewardBoxPanel.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 Utils_1 = require("./Utils");
  26. var YZ_Constant_1 = require("./YZ_Constant");
  27. var AldUtils_1 = require("./AldUtils");
  28. var PlatUtils_1 = require("./PlatUtils");
  29. var YZ_LocalStorage_1 = require("./YZ_LocalStorage");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. /**
  32. * 五倍奖励宝箱
  33. */
  34. var RewardBoxPanel = /** @class */ (function (_super) {
  35. __extends(RewardBoxPanel, _super);
  36. function RewardBoxPanel() {
  37. var _this = _super !== null && _super.apply(this, arguments) || this;
  38. _this.checked = null;
  39. _this.doubleBtn = null;
  40. _this.tripleVideoBtn = null;
  41. _this.tripleBtn = null;
  42. _this.goldLabel = null;
  43. _this.tirpNode = null;
  44. _this.light = null;
  45. _this.panel = null;
  46. _this.closeBtn = null;
  47. /**
  48. * 奖励回调
  49. */
  50. _this.rewardCallFunc = null;
  51. /**
  52. * 奖励值
  53. */
  54. _this.rewardValue = 0;
  55. _this._boxGetRewardCount = 0;
  56. _this._multiple = 1;
  57. return _this;
  58. }
  59. Object.defineProperty(RewardBoxPanel.prototype, "boxGetRewardCount", {
  60. get: function () {
  61. return this._boxGetRewardCount;
  62. },
  63. set: function (value) {
  64. this._boxGetRewardCount = value;
  65. YZ_LocalStorage_1.default.setItem(YZ_Constant_1.default.ST_GET_BOX_REWARD_COUNT, value + '');
  66. },
  67. enumerable: false,
  68. configurable: true
  69. });
  70. RewardBoxPanel.prototype.onLoad = function () {
  71. if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
  72. this.node.group = Utils_1.utils.otherConfig.group;
  73. }
  74. this.rewardCallFunc = Utils_1.utils.rewardCallFunc;
  75. this.rewardValue = Utils_1.utils.rewardValue;
  76. if (cc.winSize.height < cc.winSize.width) {
  77. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Game);
  78. }
  79. else {
  80. Utils_1.utils.adManager.ShowBanner(YZ_Constant_1.BannerLocation.Game);
  81. }
  82. this.panel.scale = 0;
  83. this._boxGetRewardCount = YZ_LocalStorage_1.default.getItem(YZ_Constant_1.default.ST_GET_BOX_REWARD_COUNT) || 0;
  84. // let result = utils.controView(ViewLocation.box);
  85. // this.checked.active = result.isSelect;
  86. // this.tripLabel.string = result.msg;
  87. // if (result.btnType) {
  88. // this.btnLabel.string = "领取五倍奖励"
  89. // } else {
  90. // this.btnLabel.string = "领取奖励"
  91. // }
  92. AldUtils_1.default.SendEvent("奖励宝箱显示成功!");
  93. this.goldLabel.string = "/" + this.rewardValue.toString();
  94. };
  95. RewardBoxPanel.prototype.onEnable = function () {
  96. var _this = this;
  97. Utils_1.utils.showSkipBtn(this.closeBtn, true);
  98. var ratio = 1;
  99. if (cc.winSize.height < cc.winSize.width) {
  100. // 横屏游戏
  101. ratio = cc.winSize.width / 1920 * 0.6;
  102. }
  103. else {
  104. ratio = cc.winSize.width / 1080;
  105. }
  106. if (PlatUtils_1.default.IsTest) {
  107. Utils_1.utils.ServerConfig.reward_box_change_count = 5;
  108. }
  109. this.panel.runAction(cc.sequence(cc.scaleTo(0.3, ratio).easing(cc.easeBackOut()), cc.callFunc(function () {
  110. var changeCount = Utils_1.utils.ServerConfig.reward_box_change_count ? parseInt(Utils_1.utils.ServerConfig.reward_box_change_count) : 0;
  111. if (Utils_1.utils.ServerConfig.reward_box_change_count != undefined && _this.boxGetRewardCount >= changeCount) {
  112. _this.tripleVideoBtn.active = true;
  113. _this.tripleBtn.active = false;
  114. Utils_1.utils.showScaleAction(_this.tripleVideoBtn, _this.doubleBtn, true, true);
  115. }
  116. else {
  117. _this.tripleVideoBtn.active = false;
  118. Utils_1.utils.showScaleAction(_this.tripleBtn, null, false, true);
  119. }
  120. _this.light.runAction(cc.rotateBy(3, +360).repeatForever());
  121. })));
  122. };
  123. RewardBoxPanel.prototype.onDestroy = function () {
  124. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Game);
  125. if (Utils_1.utils.rewardBoxPanelCloseFunc) {
  126. Utils_1.utils.rewardBoxPanelCloseFunc();
  127. Utils_1.utils.rewardBoxPanelCloseFunc = null;
  128. }
  129. else {
  130. Utils_1.utils.rewardCloseFunc && Utils_1.utils.rewardCloseFunc();
  131. Utils_1.utils.rewardCloseFunc = null;
  132. }
  133. };
  134. RewardBoxPanel.prototype.onClose = function () {
  135. var _this = this;
  136. this.panel.runAction(cc.sequence(cc.scaleTo(0.3, 0).easing(cc.easeBackIn()), cc.callFunc(function () {
  137. _this.node.destroy();
  138. })));
  139. };
  140. // /**
  141. // * 初始化事件回调
  142. // * @param closeCallFunc
  143. // * @param rewardCallFunc
  144. // */
  145. // init(closeCallFunc: Function, rewardCallFunc: Function, reward: number) {
  146. // this.closeCallFunc = closeCallFunc;
  147. // this.rewardCallFunc = rewardCallFunc;
  148. // this.rewardValue = reward;
  149. // }
  150. RewardBoxPanel.prototype.onPlayVideo = function () {
  151. var _this = this;
  152. Utils_1.utils.adManager.ShowVideo(function (ret, msg) {
  153. if (ret) {
  154. Utils_1.utils.showMsg("\u83B7\u5F97" + _this._multiple + "\u500D\u5956\u52B1! +" + _this.rewardValue * _this._multiple);
  155. _this.rewardValue = _this.rewardValue * _this._multiple;
  156. _this.boxGetRewardCount++;
  157. var result = new YZ_Constant_1.YZ_Reward();
  158. result.rewardValue = _this.rewardValue;
  159. if (_this.rewardCallFunc) {
  160. _this.rewardCallFunc(result);
  161. }
  162. _this.onClose();
  163. AldUtils_1.default.SendEvent("宝箱获取奖励成功!");
  164. }
  165. else {
  166. Utils_1.utils.showMsg(msg ? msg : "视频广告播放失败!");
  167. AldUtils_1.default.SendEvent("宝箱视频播放失败!");
  168. }
  169. });
  170. };
  171. /**
  172. * 领取金币
  173. */
  174. RewardBoxPanel.prototype.onGetGold = function (event, data) {
  175. this._multiple = parseInt(data);
  176. switch (event.target.name) {
  177. case "BtnTripleVideo":
  178. AldUtils_1.default.SendEvent("点击宝箱视频获取按钮!");
  179. this.onPlayVideo();
  180. break;
  181. case "BtnDouble":
  182. case "BtnTriple":
  183. AldUtils_1.default.SendEvent("点击宝箱普通获取按钮!");
  184. Utils_1.utils.showMsg("\u83B7\u5F97" + this._multiple + "\u500D\u5956\u52B1! +" + this.rewardValue * this._multiple);
  185. this.boxGetRewardCount++;
  186. if (this.rewardCallFunc) {
  187. var result = new YZ_Constant_1.YZ_Reward();
  188. result.rewardValue = this.rewardValue * this._multiple;
  189. this.rewardCallFunc(result);
  190. }
  191. this.onClose();
  192. break;
  193. }
  194. };
  195. __decorate([
  196. property(cc.Node)
  197. ], RewardBoxPanel.prototype, "checked", void 0);
  198. __decorate([
  199. property(cc.Node)
  200. ], RewardBoxPanel.prototype, "doubleBtn", void 0);
  201. __decorate([
  202. property(cc.Node)
  203. ], RewardBoxPanel.prototype, "tripleVideoBtn", void 0);
  204. __decorate([
  205. property(cc.Node)
  206. ], RewardBoxPanel.prototype, "tripleBtn", void 0);
  207. __decorate([
  208. property(cc.Label)
  209. ], RewardBoxPanel.prototype, "goldLabel", void 0);
  210. __decorate([
  211. property(cc.Node)
  212. ], RewardBoxPanel.prototype, "tirpNode", void 0);
  213. __decorate([
  214. property(cc.Node)
  215. ], RewardBoxPanel.prototype, "light", void 0);
  216. __decorate([
  217. property(cc.Node)
  218. ], RewardBoxPanel.prototype, "panel", void 0);
  219. __decorate([
  220. property(cc.Node)
  221. ], RewardBoxPanel.prototype, "closeBtn", void 0);
  222. RewardBoxPanel = __decorate([
  223. ccclass
  224. ], RewardBoxPanel);
  225. return RewardBoxPanel;
  226. }(cc.Component));
  227. exports.default = RewardBoxPanel;
  228. cc._RF.pop();