a4909ae9-a451-4bfc-9922-3d555b085924.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. "use strict";
  2. cc._RF.push(module, 'a4909rppFFL/JkiPVVbCFkk', 'AdAgentBroser');
  3. // common-plugin/Scripts/AdAgentBroser.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. Object.defineProperty(exports, "__esModule", { value: true });
  19. var AdAgent_1 = require("./AdAgent");
  20. var YZ_NativeBanner_1 = require("./YZ_NativeBanner");
  21. var YZ_NativeInsert_1 = require("./YZ_NativeInsert");
  22. var YZ_Constant_1 = require("./YZ_Constant");
  23. var CommonConfig_1 = require("./CommonConfig");
  24. var Utils_1 = require("./Utils");
  25. var YZ_NativeAdObject_1 = require("./YZ_NativeAdObject");
  26. var AdAgentBroser = /** @class */ (function (_super) {
  27. __extends(AdAgentBroser, _super);
  28. function AdAgentBroser() {
  29. var _this = _super !== null && _super.apply(this, arguments) || this;
  30. _this._nativeBannerInfo = null;
  31. //当前显示Banner的位置
  32. _this._curLocation = YZ_Constant_1.BannerLocation.None;
  33. _this.signleNativeAd = null;
  34. _this._curNativeItem = null;
  35. return _this;
  36. }
  37. /**
  38. * 获取当前banner配置
  39. */
  40. AdAgentBroser.prototype.getNativeBannerInfo = function () {
  41. return new CommonConfig_1.NativeBannerInfo();
  42. };
  43. AdAgentBroser.prototype.ShowBanner = function (location) {
  44. if (location === void 0) { location = null; }
  45. if (this._curLocation != location) {
  46. this.HideBanner(location);
  47. }
  48. this._curLocation = location;
  49. if (this.getNativeBannerInfo().is_show_banner == -1) {
  50. Utils_1.utils.showLog("当前位置配置为不展示banner!");
  51. this.HideBanner(location);
  52. return;
  53. }
  54. if (!this._nativeBannerNode) {
  55. this._nativeBannerNode = cc.instantiate(Utils_1.utils.config.otherconfig.nativeBanner);
  56. cc.director.getScene().addChild(this._nativeBannerNode, 1000);
  57. }
  58. this._nativeBannerNode.active = true;
  59. var nativeBanner = this._nativeBannerNode.getComponent(YZ_NativeBanner_1.default);
  60. if (nativeBanner) {
  61. var addate = { title: "今日头条", desc: "看新闻用今日头条", imgUrlList: [Utils_1.utils.cur_tool.img_url], icon: Utils_1.utils.cur_tool.img_url };
  62. nativeBanner.init(null, addate, this.getNativeBannerInfo());
  63. }
  64. // utils.showRecommendGamesBanner();
  65. };
  66. AdAgentBroser.prototype.ShowInterstitial = function () {
  67. if (!this._nativeInsertNode) {
  68. this._nativeInsertNode = cc.instantiate(Utils_1.utils.config.otherconfig.nativeInsert);
  69. cc.director.getScene().addChild(this._nativeInsertNode, 9999);
  70. }
  71. this._nativeInsertNode.active = true;
  72. var nativeBanner = this._nativeInsertNode.getComponent(YZ_NativeInsert_1.default);
  73. if (nativeBanner) {
  74. var addate = { title: "今日头条", desc: "看新闻用今日头条", imgUrlList: [Utils_1.utils.cur_tool.img_url], icon: Utils_1.utils.cur_tool.img_url };
  75. nativeBanner.init(null, addate);
  76. }
  77. // utils.showRecommendGamesBanner();
  78. };
  79. AdAgentBroser.prototype.showStatementAds = function (data) {
  80. Utils_1.utils.adManager.ShowInterstitial();
  81. // utils.showCrossWidget6();
  82. };
  83. AdAgentBroser.prototype.HideBanner = function (location) {
  84. if (location === void 0) { location = null; }
  85. if (this._nativeBannerNode) {
  86. this._nativeBannerNode.active = false;
  87. }
  88. Utils_1.utils.hideRecommendGamesBanner();
  89. };
  90. AdAgentBroser.prototype.ShowVideo = function (callback) {
  91. callback(true, "视频播放成功!");
  92. };
  93. AdAgentBroser.prototype.showBeforGameOverAd = function (level, levelStatus, rewardValue, closeCallFunc, rewardFunc) {
  94. cc.log("显示结算前广告: #Level= ", level, " #LevelStatys=", levelStatus, " #rewardValue = ", rewardValue);
  95. Utils_1.utils.currentLevel = level;
  96. Utils_1.utils.isSuccess = levelStatus == YZ_Constant_1.LevelStatus.GameWin;
  97. Utils_1.utils.rewardCallFunc = rewardFunc;
  98. Utils_1.utils.rewardCloseFunc = closeCallFunc;
  99. Utils_1.utils.rewardValue = rewardValue;
  100. var adType = Utils_1.utils.adManager.checkShowBeforGameOverAd(level, levelStatus == YZ_Constant_1.LevelStatus.GameWin);
  101. switch (adType) {
  102. case YZ_Constant_1.BeForGameOverAdId.SharePanel:
  103. Utils_1.utils.recordEnd();
  104. Utils_1.utils.showShareRecordPanel();
  105. break;
  106. case YZ_Constant_1.BeForGameOverAdId.GoldBox:
  107. Utils_1.utils.adManager.showRewardBoxPanel();
  108. break;
  109. case YZ_Constant_1.BeForGameOverAdId.Turntable:
  110. Utils_1.utils.adManager.showrewardTurnTablePanel();
  111. break;
  112. default:
  113. closeCallFunc && closeCallFunc();
  114. break;
  115. }
  116. };
  117. /**
  118. * 创建结算页面推广组件
  119. */
  120. AdAgentBroser.prototype.ShowSingleNativeAd = function (params) {
  121. if (Utils_1.utils.config.otherconfig.singleNativeAd) {
  122. if (this.signleNativeAd && cc.isValid(this.signleNativeAd)) {
  123. this.signleNativeAd.destroy();
  124. }
  125. this.signleNativeAd = cc.instantiate(Utils_1.utils.config.otherconfig.singleNativeAd);
  126. var nativeItem = this.signleNativeAd.getComponent("YZ_NativeItem");
  127. nativeItem.showType = 2;
  128. nativeItem.params = params;
  129. this._curNativeItem = nativeItem;
  130. if (params && params.parent) {
  131. params.parent.addChild(this.signleNativeAd, cc.macro.MAX_ZINDEX);
  132. }
  133. var nativeObj = new YZ_NativeAdObject_1.default();
  134. var data = {
  135. imgUrlList: [Utils_1.utils.cur_tool.img_url],
  136. icon: Utils_1.utils.cur_tool.img_url,
  137. title: "爱奇艺视频",
  138. desc: "下载爱奇艺,即送VIP!"
  139. };
  140. nativeObj.data = data;
  141. nativeItem._nativeAd = nativeObj;
  142. this._curNativeItem.init(nativeObj);
  143. Utils_1.utils.showLog("单个原生广告创建成功!");
  144. return this.signleNativeAd;
  145. }
  146. else {
  147. Utils_1.utils.showLog("未找到预制体 singleNativeAd, 请查看CommonUtils组件上是否赋值!");
  148. return null;
  149. }
  150. };
  151. return AdAgentBroser;
  152. }(AdAgent_1.default));
  153. exports.default = AdAgentBroser;
  154. cc._RF.pop();