003c244b-ccbb-48c9-afed-cb434d616083.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. "use strict";
  2. cc._RF.push(module, '003c2RLzLtIya/ty0NNYWCD', 'UIADPanel');
  3. // scripts/UI/UIADPanel.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("../../common-plugin/Scripts/Utils");
  26. var CocosZ_1 = require("../Framework/CocosZ");
  27. var Msg_1 = require("../Framework/Msg");
  28. var ATRewardedVideoJSSDK_1 = require("../AnyThinkAds/ATRewardedVideoJSSDK");
  29. var ATAndroidJS2_1 = require("../ATAndroidJS2");
  30. var GlobalManager_1 = require("../GlobalManager");
  31. // @ts-ignore
  32. var i18n = require('LanguageData');
  33. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  34. var NewClass = /** @class */ (function (_super) {
  35. __extends(NewClass, _super);
  36. function NewClass() {
  37. var _this = _super !== null && _super.apply(this, arguments) || this;
  38. _this.btnAD = null;
  39. _this.btnSkip = null;
  40. _this.adKey = "zh_ad_type";
  41. _this.isDiamond = false;
  42. return _this;
  43. }
  44. NewClass.prototype.start = function () {
  45. console.log('zh:uiadpanel start ');
  46. if (CocosZ_1.cocosz.isADON) {
  47. this.node.scale = 0;
  48. cc.tween(this.node).to(0.3, { scale: 1 }, { easing: "backOut" }).start();
  49. Utils_1.utils.SendEvent("页面-" + (this.isDiamond ? "钻石" : "金币"));
  50. }
  51. else {
  52. this.node.destroy();
  53. }
  54. this.initAdForPage();
  55. };
  56. NewClass.prototype.initAdForPage = function () {
  57. if (cc.sys.os === cc.sys.OS_ANDROID) {
  58. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  59. console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId()));
  60. var setting = {};
  61. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  62. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  63. }
  64. };
  65. NewClass.prototype.setDiamond = function () {
  66. this.isDiamond = true;
  67. this.node.getChildByName("bg").active = false;
  68. this.node.getChildByName("bg1").active = true;
  69. };
  70. NewClass.prototype.watchAD = function () {
  71. var _this = this;
  72. Utils_1.utils.SendEvent("\u89C6\u9891-" + (this.isDiamond ? "钻石购买" : "金币购买") + "-\u64AD\u653E");
  73. // 注册方法 , this.ClickClose.bind(this));
  74. GlobalManager_1.default.getInstance().registerMethod('event_UIADPanel_forAd', this.event_UIADPanel_forAd.bind(this));
  75. cc.sys.localStorage.setItem(this.adKey, 'event_UIADPanel_forAd'); //
  76. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  77. console.log('zh:AD ready for event_UIADPanel_forAd');
  78. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  79. }
  80. else {
  81. console.log('zh:AD not ready for event_UIADPanel_forAd');
  82. this.event_UIADPanel_forAd();
  83. this.initAdForPage();
  84. }
  85. if (2 > 1) {
  86. return; //下面是原始的代码
  87. }
  88. CocosZ_1.cocosz.watchAD(function () {
  89. Utils_1.utils.SendEvent("\u89C6\u9891-" + (_this.isDiamond ? "钻石购买" : "金币购买") + "-\u6210\u529F");
  90. if (_this.isDiamond) {
  91. var num = CocosZ_1.cocosz.isDeBug ? 10000 : 200;
  92. CocosZ_1.cocosz.dataMgr.DiamondCount += num;
  93. Msg_1.default.Show(i18n.t("msg.gxhdzs") + num); //恭喜获得钻石
  94. }
  95. else {
  96. var num = CocosZ_1.cocosz.isDeBug ? 10000 : 500;
  97. CocosZ_1.cocosz.dataMgr.CoinCount += num;
  98. Msg_1.default.Show(i18n.t("msg.gxhdjb") + num); //恭喜获得金币
  99. }
  100. _this.node.destroy();
  101. }, function () {
  102. Utils_1.utils.SendEvent("\u89C6\u9891-" + (_this.isDiamond ? "钻石购买" : "金币购买") + "-\u5931\u8D25");
  103. });
  104. };
  105. //zh:
  106. NewClass.prototype.event_UIADPanel_forAd = function () {
  107. console.log('zh:event_UIADPanel_forAd 被触发');
  108. if (this.isDiamond) {
  109. var num = CocosZ_1.cocosz.isDeBug ? 10000 : 200;
  110. CocosZ_1.cocosz.dataMgr.DiamondCount += num;
  111. Msg_1.default.Show(i18n.t("msg.gxhdzs") + num); //恭喜获得钻石
  112. }
  113. else {
  114. var num = CocosZ_1.cocosz.isDeBug ? 10000 : 500;
  115. CocosZ_1.cocosz.dataMgr.CoinCount += num;
  116. Msg_1.default.Show(i18n.t("msg.gxhdjb") + num); //恭喜获得金币
  117. }
  118. this.node.destroy();
  119. };
  120. NewClass.prototype.exit = function () {
  121. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  122. this.node.destroy();
  123. };
  124. __decorate([
  125. property(cc.Node)
  126. ], NewClass.prototype, "btnAD", void 0);
  127. __decorate([
  128. property(cc.Node)
  129. ], NewClass.prototype, "btnSkip", void 0);
  130. NewClass = __decorate([
  131. ccclass
  132. ], NewClass);
  133. return NewClass;
  134. }(cc.Component));
  135. exports.default = NewClass;
  136. cc._RF.pop();