fea03490-b9e1-49a3-b88c-4af676571920.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. "use strict";
  2. cc._RF.push(module, 'fea03SQueFJo7iMSvZ2Vxkg', 'AdManager');
  3. // common-plugin/Scripts/AdManager.ts
  4. "use strict";
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. 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;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var PlatUtils_1 = require("./PlatUtils");
  13. var AdAgentNative_1 = require("./AdAgentNative");
  14. var AdAgentWechat_1 = require("./AdAgentWechat");
  15. var AdAgentOPPO_1 = require("./AdAgentOPPO");
  16. var AdAgentVIVO_1 = require("./AdAgentVIVO");
  17. var AdAgentBaidu_1 = require("./AdAgentBaidu");
  18. var AdAgentDouyin_1 = require("./AdAgentDouyin");
  19. var YZ_Constant_1 = require("./YZ_Constant");
  20. var AdAgentQQ_1 = require("./AdAgentQQ");
  21. var AdAgentQTT_1 = require("./AdAgentQTT");
  22. var Utils_1 = require("./Utils");
  23. var AdAgentXiaomi_1 = require("./AdAgentXiaomi");
  24. var AdAgent4399_1 = require("./AdAgent4399");
  25. var AdAgentIOS_1 = require("./AdAgentIOS");
  26. var AdAgentCocosplay_1 = require("./AdAgentCocosplay");
  27. var AdAgentUC_1 = require("./AdAgentUC");
  28. var AdAgentBili_1 = require("./AdAgentBili");
  29. var AdAgentKwai_1 = require("./AdAgentKwai");
  30. var AdAgentBroser_1 = require("./AdAgentBroser");
  31. var BeforGameOverRecGamesPanel_1 = require("./BeforGameOverRecGamesPanel");
  32. var AdAgentWiFi_1 = require("./AdAgentWiFi");
  33. var AdAgentHago_1 = require("./AdAgentHago");
  34. var AdAgentHuaWei_1 = require("./AdAgentHuaWei");
  35. var AdAgentFaceBook_1 = require("./AdAgentFaceBook");
  36. var YzCustomAdPanel_1 = require("./YzCustomAdPanel");
  37. var AdAgentGoogleWeb_1 = require("./AdAgentGoogleWeb");
  38. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  39. var AdManager = /** @class */ (function () {
  40. function AdManager() {
  41. this._curAdAgent = null;
  42. this.videoCallBack = null;
  43. this._lastShowGameOverAdType = YZ_Constant_1.BeForGameOverAdId.None;
  44. //结算前广告类型数组
  45. this.beforRewardTypes = [YZ_Constant_1.BeForGameOverAdId.SharePanel, YZ_Constant_1.BeForGameOverAdId.GoldBox, YZ_Constant_1.BeForGameOverAdId.Turntable, YZ_Constant_1.BeForGameOverAdId.CreateShortCut, YZ_Constant_1.BeForGameOverAdId.RecGame, YZ_Constant_1.BeForGameOverAdId.LuckBox];
  46. this.rewardBoxPanel = null;
  47. this.rewardRecGamePanel = null;
  48. this.rewardTurnTablePanel = null;
  49. this.rewardShortCutPanel = null;
  50. this._rewardLuckBoxPanel = null;
  51. this._insertLastShowTime = 0;
  52. this._customAdPanel = null;
  53. }
  54. AdManager.prototype.Init = function () {
  55. if (PlatUtils_1.default.IsNativeAndroid) {
  56. this._curAdAgent = new AdAgentNative_1.default();
  57. this._curAdAgent.Init();
  58. }
  59. else if (PlatUtils_1.default.IsWechat) {
  60. this._curAdAgent = new AdAgentWechat_1.default();
  61. this._curAdAgent.Init();
  62. }
  63. else if (PlatUtils_1.default.IsOPPO) {
  64. this._curAdAgent = new AdAgentOPPO_1.default();
  65. this._curAdAgent.Init();
  66. }
  67. else if (PlatUtils_1.default.IsVIVO) {
  68. this._curAdAgent = new AdAgentVIVO_1.default();
  69. this._curAdAgent.Init();
  70. }
  71. else if (PlatUtils_1.default.IsBaidu) {
  72. this._curAdAgent = new AdAgentBaidu_1.default();
  73. this._curAdAgent.Init();
  74. }
  75. else if (PlatUtils_1.default.IsDouyin) {
  76. this._curAdAgent = new AdAgentDouyin_1.default();
  77. this._curAdAgent.Init();
  78. }
  79. else if (PlatUtils_1.default.IsQQ) {
  80. this._curAdAgent = new AdAgentQQ_1.default();
  81. this._curAdAgent.Init();
  82. }
  83. else if (PlatUtils_1.default.IsQTT) {
  84. this._curAdAgent = new AdAgentQTT_1.default();
  85. this._curAdAgent.Init();
  86. }
  87. else if (PlatUtils_1.default.IsXiaoMi) {
  88. this._curAdAgent = new AdAgentXiaomi_1.default();
  89. this._curAdAgent.Init();
  90. }
  91. else if (PlatUtils_1.default.ISUC) {
  92. this._curAdAgent = new AdAgentUC_1.default();
  93. this._curAdAgent.Init();
  94. }
  95. else if (PlatUtils_1.default.ISCocos) {
  96. this._curAdAgent = new AdAgentCocosplay_1.default();
  97. this._curAdAgent.Init();
  98. }
  99. else if (PlatUtils_1.default.Is4399) {
  100. this._curAdAgent = new AdAgent4399_1.default();
  101. this._curAdAgent.Init();
  102. }
  103. else if (PlatUtils_1.default.IsNativeIOS) {
  104. this._curAdAgent = new AdAgentIOS_1.default();
  105. this._curAdAgent.Init();
  106. }
  107. else if (PlatUtils_1.default.IsBili) {
  108. this._curAdAgent = new AdAgentBili_1.default();
  109. this._curAdAgent.Init();
  110. }
  111. else if (PlatUtils_1.default.IsKwai) {
  112. this._curAdAgent = new AdAgentKwai_1.default();
  113. this._curAdAgent.Init();
  114. }
  115. else if (PlatUtils_1.default.IsWiFi) {
  116. this._curAdAgent = new AdAgentWiFi_1.default();
  117. this._curAdAgent.Init();
  118. }
  119. else if (PlatUtils_1.default.IsHago) {
  120. this._curAdAgent = new AdAgentHago_1.default();
  121. this._curAdAgent.Init();
  122. }
  123. else if (PlatUtils_1.default.IsHuaWei) {
  124. this._curAdAgent = new AdAgentHuaWei_1.default();
  125. this._curAdAgent.Init();
  126. }
  127. else if (PlatUtils_1.default.IsFaceBook) {
  128. this._curAdAgent = new AdAgentFaceBook_1.default();
  129. this._curAdAgent.Init();
  130. }
  131. else if (PlatUtils_1.default.IsTest) {
  132. this._curAdAgent = new AdAgentBroser_1.default();
  133. this._curAdAgent.Init();
  134. }
  135. else if (PlatUtils_1.default.IsGoogleWeb) {
  136. this._curAdAgent = new AdAgentGoogleWeb_1.default();
  137. this._curAdAgent.Init();
  138. }
  139. };
  140. AdManager.prototype.OnUpdate = function (dt) { };
  141. /**
  142. * 显示浮窗广告挂件
  143. * @param params
  144. * ```
  145. * {
  146. * group:string
  147. * left:number
  148. * bottom:number
  149. * scale:number
  150. * parent:cc.Node
  151. * }
  152. * ```
  153. * @returns 生成的组件
  154. */
  155. AdManager.prototype.showNativeTryGameWidget = function (params) {
  156. if (params === void 0) { params = null; }
  157. if (!this.checkShowAdTime()) {
  158. Utils_1.utils.showLog("显示插屏时间未达限制!");
  159. return;
  160. }
  161. if (this._curAdAgent) {
  162. if (!Utils_1.utils.isShowNativeTryGamesWidget() || PlatUtils_1.default.IsHuaWei) {
  163. Utils_1.utils.showLog("不能显示原生抖动试玩");
  164. return;
  165. }
  166. this._curAdAgent.showNativeTryGameWidget(params);
  167. }
  168. };
  169. /**
  170. * 隐藏浮动试玩挂件
  171. */
  172. AdManager.prototype.hideNativeTryGameWidget = function () {
  173. if (this._curAdAgent) {
  174. this._curAdAgent.hideNativeTryGameWidget();
  175. }
  176. };
  177. /**
  178. * 展示开屏广告,当前只有华为平台生效
  179. */
  180. AdManager.prototype.showNativeSplashView = function (callBack) {
  181. if (callBack === void 0) { callBack = null; }
  182. if (PlatUtils_1.default.IsHuaWei) {
  183. if (this._curAdAgent) {
  184. this._curAdAgent.showNativeSplashView(callBack);
  185. }
  186. else {
  187. if (callBack) {
  188. callBack();
  189. }
  190. }
  191. }
  192. else {
  193. if (callBack) {
  194. callBack();
  195. }
  196. }
  197. };
  198. /**
  199. * 显示广告条
  200. * @param location 位置
  201. * @param args 参数,控制广告条的宽度和位置,此参数只对微信平台有效,默认居中贴底显示.
  202. * {
  203. * width: 广告条宽度,屏幕的百分比,取值范围0-1;
  204. * bottom: 广告条距离屏幕底部的高度,单位是像素;
  205. * }
  206. */
  207. AdManager.prototype.ShowBanner = function (location, args) {
  208. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  209. if (args === void 0) { args = null; }
  210. if (!this.checkShowAdTime()) {
  211. Utils_1.utils.showLog("显示广告条时间未达限制!");
  212. return;
  213. }
  214. if (this._curAdAgent) {
  215. this._curAdAgent.ShowBanner(location, args);
  216. }
  217. };
  218. AdManager.prototype.HideBanner = function (location) {
  219. if (this._curAdAgent) {
  220. this._curAdAgent.HideBanner(location);
  221. }
  222. };
  223. AdManager.prototype.ShowInterstitial = function (localtion) {
  224. if (localtion === void 0) { localtion = YZ_Constant_1.BannerLocation.Home; }
  225. if (!this.checkShowAdTime()) {
  226. Utils_1.utils.showLog("显示插屏时间未达限制!");
  227. return;
  228. }
  229. if (!this.checkInsertAdTime()) {
  230. Utils_1.utils.showLog("显示插屏时间未达到间隔时间!");
  231. return;
  232. }
  233. if (this._curAdAgent) {
  234. this._curAdAgent.ShowInterstitial(localtion);
  235. }
  236. };
  237. /**
  238. * 播放视频广告
  239. * @param callback Function(ret:boolean,msg:string)
  240. * ret 看完视频返回true, 否则返回false
  241. * msg 播放失败的消息提示
  242. */
  243. AdManager.prototype.ShowVideo = function (callback) {
  244. if (this._curAdAgent) {
  245. this.videoCallBack = callback;
  246. this._curAdAgent.ShowVideo(callback);
  247. }
  248. else {
  249. if (callback)
  250. callback(false, "视频加载失败1!");
  251. }
  252. };
  253. /**
  254. * 显示互动直弹广告
  255. * --目前仅支持趣头条平台
  256. */
  257. AdManager.prototype.showInteractiveAd = function () {
  258. if (this._curAdAgent) {
  259. this._curAdAgent.showInteractiveAd();
  260. }
  261. };
  262. /**
  263. * 显示QQ游戏盒子广告
  264. */
  265. AdManager.prototype.ShowAppBox = function (isMoreGame) {
  266. if (this._curAdAgent) {
  267. this._curAdAgent.ShowAppBox(isMoreGame);
  268. }
  269. };
  270. /**
  271. * 隐藏QQ游戏盒子广告
  272. * --目前仅支持QQ平台--
  273. */
  274. AdManager.prototype.HideAppBox = function () {
  275. if (this._curAdAgent) {
  276. this._curAdAgent.HideAppBox();
  277. }
  278. };
  279. /**
  280. * 显示激励插屏
  281. */
  282. AdManager.prototype.showRewardInsert = function () {
  283. if (this._curAdAgent) {
  284. Utils_1.utils.showLog("显示 RI");
  285. this._curAdAgent.showRewardInsert();
  286. }
  287. };
  288. /**
  289. * 隐藏激励插屏
  290. */
  291. AdManager.prototype.hideRewardInsert = function () {
  292. if (this._curAdAgent) {
  293. this._curAdAgent.hideRewardInsert();
  294. }
  295. };
  296. /**
  297. * 显示关闭按钮的Banner
  298. * @param location
  299. * @param closeBtn
  300. */
  301. AdManager.prototype.ShowCloseBtnBanner = function (location, args) {
  302. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  303. if (!this.checkShowAdTime()) {
  304. Utils_1.utils.showLog("显示广告条时间未达限制!");
  305. return;
  306. }
  307. if (this._curAdAgent) {
  308. this._curAdAgent.ShowCloseBtnBanner(location, args);
  309. }
  310. };
  311. /**
  312. * 显示结算窗口的推荐广告
  313. */
  314. AdManager.prototype.ShowStatementRecomment = function () {
  315. if (this._curAdAgent) {
  316. if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO) {
  317. return this._curAdAgent.ShowStatementRecomment();
  318. }
  319. else if (PlatUtils_1.default.IsWechat) {
  320. return Utils_1.utils.showCrossWidget6();
  321. }
  322. }
  323. return null;
  324. };
  325. /**
  326. * 获取原生广告数据
  327. */
  328. AdManager.prototype.getNativeAdData = function (args) {
  329. if (this._curAdAgent) {
  330. Utils_1.utils.showLog("adManager 获取原生广告");
  331. return this._curAdAgent.getNativeAdData(args);
  332. }
  333. return null;
  334. };
  335. /**
  336. * 显示结算页面广告
  337. * @param data 参数
  338. * oppo、微信平台结算广告特殊处理
  339. * 趣头条平台结算广告为互动直弹
  340. * vivo、抖音、qq、xiaomi、baidu平台结算界面广告为插屏
  341. */
  342. AdManager.prototype.showStatementAds = function (data) {
  343. var res = { "type": -1, "node": null };
  344. if (!this.checkShowAdTime()) {
  345. Utils_1.utils.showLog("显示结算页面广告时间未达限制!");
  346. return res;
  347. }
  348. if (this._curAdAgent) {
  349. if (PlatUtils_1.default.IsWechat || PlatUtils_1.default.IsBaidu) {
  350. return this._curAdAgent.showStatementAds(data);
  351. }
  352. }
  353. if (PlatUtils_1.default.IsQTT) {
  354. Utils_1.utils.adManager.showInteractiveAd();
  355. }
  356. else {
  357. Utils_1.utils.adManager.ShowInterstitial();
  358. }
  359. Utils_1.utils.showLog("非oppo和微信平台正常显示结算广告");
  360. return res;
  361. };
  362. AdManager.prototype.createNativeAd = function (params, yzItem) {
  363. if (params === void 0) { params = null; }
  364. if (this._curAdAgent) {
  365. this._curAdAgent.createNativeAd(params, yzItem);
  366. }
  367. };
  368. AdManager.prototype.hideKyxBanner = function () {
  369. if (this._curAdAgent) {
  370. this._curAdAgent.hideKyxBanner();
  371. }
  372. };
  373. AdManager.prototype.showBeforGameOverAd = function (level, levelStatus, rewardValue, closeCallFunc, rewardFunc) {
  374. if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsDouyin || PlatUtils_1.default.IsBaidu || PlatUtils_1.default.IsWechat || PlatUtils_1.default.IsQQ || PlatUtils_1.default.IsKwai || PlatUtils_1.default.IsNativeAndroid || PlatUtils_1.default.IsNativeIOS || Utils_1.utils._tool_Broswer || PlatUtils_1.default.IsWiFi || PlatUtils_1.default.IsHuaWei) {
  375. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.befor_ad_min_level && Utils_1.utils.ServerConfig.befor_ad_min_level >= level) {
  376. Utils_1.utils.showLog(level + " >>\u670D\u52A1\u5668\u914D\u7F6E\u7ED3\u7B97\u524D\u5E7F\u544A\u5728" + Utils_1.utils.ServerConfig.befor_ad_min_level + "\u5173\u540E\u624D\u80FD\u663E\u793A\uFF01");
  377. closeCallFunc && closeCallFunc();
  378. return;
  379. }
  380. Utils_1.utils.showLog("显示结算前广告: #Level= ", level, " #LevelStatys=", levelStatus, " #rewardValue = ", rewardValue);
  381. Utils_1.utils.currentLevel = level;
  382. Utils_1.utils.isSuccess = levelStatus == YZ_Constant_1.LevelStatus.GameWin;
  383. Utils_1.utils.rewardCallFunc = rewardFunc;
  384. Utils_1.utils.rewardCloseFunc = closeCallFunc;
  385. Utils_1.utils.rewardValue = rewardValue;
  386. // if (PlatUtils.IsNativeAndroid || CC_DEBUG) {
  387. // if (utils.isSuccess) {
  388. // utils.yzRedBagInfo.progress++;
  389. // }
  390. // if (utils.canShowRedBag() && utils.yzRedBagInfo.progress >= utils.yzRedBagInfo.totalProgress) {
  391. // utils.showLog("当前红包进度已满,显示获得红包窗口!");
  392. // utils.showOpenRedBagPanel({ showType: 2 });
  393. // return;
  394. // }
  395. // }
  396. var adType = Utils_1.utils.adManager.checkShowBeforGameOverAd(level, levelStatus == YZ_Constant_1.LevelStatus.GameWin);
  397. switch (adType) {
  398. case YZ_Constant_1.BeForGameOverAdId.SharePanel:
  399. Utils_1.utils.recordEnd();
  400. Utils_1.utils.showShareRecordPanel();
  401. break;
  402. case YZ_Constant_1.BeForGameOverAdId.GoldBox:
  403. Utils_1.utils.adManager.showRewardBoxPanel();
  404. break;
  405. case YZ_Constant_1.BeForGameOverAdId.Turntable:
  406. Utils_1.utils.adManager.showrewardTurnTablePanel();
  407. break;
  408. case YZ_Constant_1.BeForGameOverAdId.CreateShortCut:
  409. Utils_1.utils.adManager.showRewardShortCutPanel();
  410. break;
  411. case YZ_Constant_1.BeForGameOverAdId.RecGame:
  412. Utils_1.utils.adManager.showRecGamePanel();
  413. break;
  414. case YZ_Constant_1.BeForGameOverAdId.LuckBox:
  415. var show_level = Utils_1.utils.ServerConfig.reward_luck_box_show_level ? Utils_1.utils.ServerConfig.reward_luck_box_show_level : 0;
  416. if (level > show_level) {
  417. Utils_1.utils.adManager.showRewardLuckBoxPanel();
  418. }
  419. else {
  420. Utils_1.utils.showLog("幸运宝箱间隔关卡未达到!");
  421. closeCallFunc && closeCallFunc();
  422. Utils_1.utils.rewardCloseFunc = null;
  423. }
  424. break;
  425. default:
  426. closeCallFunc && closeCallFunc();
  427. Utils_1.utils.rewardCloseFunc = null;
  428. break;
  429. }
  430. }
  431. else {
  432. closeCallFunc && closeCallFunc();
  433. Utils_1.utils.rewardCloseFunc = null;
  434. }
  435. };
  436. //结算前广告显示方法
  437. AdManager.prototype.getRewardCloseAndShowCallFunc = function (index) {
  438. var result = null;
  439. switch (index) {
  440. case 1:
  441. result = Utils_1.utils.adManager.showShareRecordPanel;
  442. break;
  443. case 2:
  444. result = Utils_1.utils.adManager.showRewardBoxPanel;
  445. break;
  446. case 3:
  447. result = Utils_1.utils.adManager.showrewardTurnTablePanel;
  448. break;
  449. case 4:
  450. result = Utils_1.utils.adManager.showRewardShortCutPanel;
  451. break;
  452. case 5:
  453. result = Utils_1.utils.adManager.showRecGamePanel;
  454. break;
  455. case 6:
  456. result = Utils_1.utils.adManager.showRewardLuckBoxPanel;
  457. break;
  458. }
  459. return result;
  460. };
  461. /**
  462. * befor_game_over_share_interval 分享弹窗间隔 例如:1、2、3、4、5
  463. * befor_game_over_reward_box_interval 宝箱弹窗间隔 例如:1、2、3、4、5
  464. * befor_game_over_turntable_interval 转盘抽奖间隔 例如:1、2、3、4、5
  465. * befor_game_over_shortcut_interval 添加桌面间隔 例如:1、2、3、4、5
  466. *
  467. * befor_game_over_share_type 分享弹窗类型 例如: all、success、fail
  468. * befor_game_over_reward_box_type 宝箱弹窗类型 例如: all、success、fail
  469. * befor_game_over_turntable_type 抽奖弹窗类型 例如: all、success、fail
  470. * befor_game_over_shortcut_type 添加桌面间类型 例如: all、success、fail
  471. *
  472. * befor_game_over_sync_list 同时展示顺序 例如: 123、321、12、21、32
  473. * befor_game_over_sync_interval 同时展示间隔关卡数 例如:1、2、3、4、5
  474. * befor_game_over_sync_type 同时展示类型 例如: all、success、fail
  475. *
  476. * level 当前关卡 isSuccess是否胜利
  477. * @returns result : 1:分享弹窗,2:宝箱弹窗,3:转盘弹窗 4:快捷桌面添加 5:更多游戏列表 6、幸运宝箱
  478. */
  479. AdManager.prototype.checkShowBeforGameOverAd = function (level, isSuccess) {
  480. if (!this._curAdAgent || !Utils_1.utils.ServerConfig) {
  481. Utils_1.utils.showLog("组件初始化失败!");
  482. return YZ_Constant_1.BeForGameOverAdId.None;
  483. }
  484. var befor_game_over_reward_share_interval = Utils_1.utils.ServerConfig.befor_game_over_share_interval;
  485. var befor_game_over_reward_box_interval = Utils_1.utils.ServerConfig.befor_game_over_reward_box_interval;
  486. var befor_game_over_turntable_interval = Utils_1.utils.ServerConfig.befor_game_over_turntable_interval;
  487. var befor_game_over_shortcut_interval = Utils_1.utils.ServerConfig.auto_desktop_interval;
  488. var befor_game_over_rec_game_interval = Utils_1.utils.ServerConfig.befor_game_over_rec_game_interval;
  489. var befor_game_over_luck_box_interval = Utils_1.utils.ServerConfig.befor_game_over_luck_box_interval;
  490. var befor_game_over_reward_share_type = Utils_1.utils.ServerConfig.befor_game_over_share_type;
  491. var befor_game_over_reward_box_type = Utils_1.utils.ServerConfig.befor_game_over_reward_box_type;
  492. var befor_game_over_turntable_type = Utils_1.utils.ServerConfig.befor_game_over_turntable_type;
  493. var befor_game_over_rec_game_type = Utils_1.utils.ServerConfig.befor_game_over_rec_game_type;
  494. var befor_game_over_luck_box_type = Utils_1.utils.ServerConfig.befor_game_over_luck_box_type;
  495. var befor_game_over_shortcut_type = Utils_1.utils.ServerConfig.auto_desktop_type;
  496. var befor_game_over_is_sync = Utils_1.utils.ServerConfig.befor_game_over_sync_list;
  497. var befor_game_over_sync_interval = Utils_1.utils.ServerConfig.befor_game_over_sync_interval;
  498. var befor_game_over_sync_type = Utils_1.utils.ServerConfig.befor_game_over_sync_type;
  499. if (PlatUtils_1.default.IsTest) {
  500. // befor_game_over_turntable_type = "all";
  501. // befor_game_over_turntable_interval = 2;
  502. // befor_game_over_is_sync = "32";
  503. // befor_game_over_sync_interval = "1";
  504. // befor_game_over_sync_type = "all";
  505. // befor_game_over_rec_game_type = "all";
  506. // befor_game_over_rec_game_interval = 4;
  507. // befor_game_over_luck_box_type = "all";
  508. // befor_game_over_luck_box_interval = 1;
  509. befor_game_over_reward_box_type = "all";
  510. befor_game_over_reward_box_interval = 1;
  511. }
  512. var result = YZ_Constant_1.BeForGameOverAdId.None;
  513. var isShow = false;
  514. if (befor_game_over_is_sync) {
  515. Utils_1.utils.showLog("进入同步显示弹窗判断:", befor_game_over_is_sync, "<<interval=", befor_game_over_sync_interval, "<<<type", befor_game_over_sync_type);
  516. switch (befor_game_over_sync_type) {
  517. case "all":
  518. isShow = true;
  519. break;
  520. case "success":
  521. isShow = isSuccess;
  522. break;
  523. case "fail":
  524. isShow = !isSuccess;
  525. break;
  526. }
  527. if (isShow && befor_game_over_sync_interval && level % befor_game_over_sync_interval == 0) {
  528. var syncTypes = befor_game_over_is_sync.split("");
  529. for (var i = 0; i < syncTypes.length; i++) {
  530. if (i == 0) {
  531. result = this.beforRewardTypes[parseInt(syncTypes[i]) - 1];
  532. }
  533. var closeFunc = null;
  534. if (i == syncTypes.length - 1) {
  535. closeFunc = Utils_1.utils.rewardCloseFunc;
  536. }
  537. else {
  538. closeFunc = this.getRewardCloseAndShowCallFunc(parseInt(syncTypes[i + 1]));
  539. }
  540. switch (syncTypes[i]) {
  541. case "1":
  542. Utils_1.utils.shareRecordPanelCloseFunc = closeFunc;
  543. break;
  544. case "2":
  545. Utils_1.utils.rewardBoxPanelCloseFunc = closeFunc;
  546. break;
  547. case "3":
  548. Utils_1.utils.turnTablePanelCloseFunc = closeFunc;
  549. break;
  550. case "4":
  551. Utils_1.utils.rewardShortCutPanelCloseFunc = closeFunc;
  552. break;
  553. case "5":
  554. Utils_1.utils.rewardRecGamePanelCloseFunc = closeFunc;
  555. break;
  556. case "6":
  557. Utils_1.utils.rewardLuckBoxPanelCloseFunc = closeFunc;
  558. break;
  559. }
  560. }
  561. }
  562. }
  563. else {
  564. var showCount = 0;
  565. if (befor_game_over_reward_share_type) {
  566. showCount++;
  567. }
  568. if (befor_game_over_reward_box_type) {
  569. showCount++;
  570. }
  571. if (befor_game_over_turntable_type) {
  572. showCount++;
  573. }
  574. if (befor_game_over_shortcut_type) {
  575. showCount++;
  576. }
  577. if (befor_game_over_luck_box_type) {
  578. showCount++;
  579. }
  580. Utils_1.utils.showLog("显示的类型" + showCount + "种,进行顺序切换判断,上一次显示的类型为:" + this._lastShowGameOverAdType);
  581. isShow = true;
  582. if (befor_game_over_reward_share_interval && level % befor_game_over_reward_share_interval == 0) {
  583. Utils_1.utils.showLog("进入显示分享奖励弹窗判断", befor_game_over_reward_share_type, "<<");
  584. if (showCount > 1) {
  585. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.SharePanel;
  586. }
  587. if (isShow) {
  588. switch (befor_game_over_reward_share_type) {
  589. case "all":
  590. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_reward_share_interval + "\u5173\uFF0C\u663E\u793A\u5206\u4EAB\u5956\u52B1\u5F39\u7A97\uFF01");
  591. result = YZ_Constant_1.BeForGameOverAdId.SharePanel;
  592. break;
  593. case "success":
  594. if (isSuccess) {
  595. result = YZ_Constant_1.BeForGameOverAdId.SharePanel;
  596. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_reward_share_interval + "\u5173\uFF0C\u663E\u793A\u5206\u4EAB\u5956\u52B1\u5F39\u7A97\uFF01");
  597. }
  598. break;
  599. case "fail":
  600. if (!isSuccess) {
  601. result = YZ_Constant_1.BeForGameOverAdId.SharePanel;
  602. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_reward_share_interval + "\u5173\uFF0C\u663E\u793A\u5206\u4EAB\u5956\u52B1\u5F39\u7A97\uFF01");
  603. }
  604. break;
  605. }
  606. }
  607. }
  608. if (result != YZ_Constant_1.BeForGameOverAdId.None) {
  609. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  610. this._lastShowGameOverAdType = result;
  611. return result;
  612. }
  613. if (befor_game_over_reward_box_interval && level % befor_game_over_reward_box_interval == 0) {
  614. Utils_1.utils.showLog("进入显示宝箱判断", befor_game_over_reward_box_type, "<<");
  615. if (showCount > 1) {
  616. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.GoldBox;
  617. }
  618. if (isShow) {
  619. switch (befor_game_over_reward_box_type) {
  620. case "all":
  621. result = YZ_Constant_1.BeForGameOverAdId.GoldBox;
  622. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_reward_box_interval + "\u5173\uFF0C\u663E\u793A\u5B9D\u7BB1\u5F39\u7A97\uFF01");
  623. break;
  624. case "success":
  625. if (isSuccess) {
  626. result = YZ_Constant_1.BeForGameOverAdId.GoldBox;
  627. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_reward_box_interval + "\u5173\uFF0C\u663E\u793A\u5B9D\u7BB1\u5F39\u7A97\uFF01");
  628. }
  629. break;
  630. case "fail":
  631. if (!isSuccess) {
  632. result = YZ_Constant_1.BeForGameOverAdId.GoldBox;
  633. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_reward_box_interval + "\u5173\uFF0C\u663E\u793A\u5B9D\u7BB1\u5F39\u7A97\uFF01");
  634. }
  635. break;
  636. }
  637. }
  638. }
  639. if (result != YZ_Constant_1.BeForGameOverAdId.None) {
  640. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  641. this._lastShowGameOverAdType = result;
  642. return result;
  643. }
  644. if (befor_game_over_turntable_interval && level % befor_game_over_turntable_interval == 0) {
  645. Utils_1.utils.showLog("进入显示抽奖弹窗判断", befor_game_over_turntable_type, "<<");
  646. if (showCount > 1) {
  647. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.Turntable;
  648. }
  649. if (isShow) {
  650. switch (befor_game_over_turntable_type) {
  651. case "all":
  652. result = YZ_Constant_1.BeForGameOverAdId.Turntable;
  653. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_turntable_interval + "\u5173\uFF0C\u663E\u793A\u62BD\u5956\u5F39\u7A97\uFF01");
  654. break;
  655. case "success":
  656. if (isSuccess) {
  657. result = YZ_Constant_1.BeForGameOverAdId.Turntable;
  658. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_turntable_interval + "\u5173\uFF0C\u663E\u793A\u62BD\u5956\u5F39\u7A97\uFF01");
  659. }
  660. break;
  661. case "fail":
  662. if (!isSuccess) {
  663. result = YZ_Constant_1.BeForGameOverAdId.Turntable;
  664. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_turntable_interval + "\u5173\uFF0C\u663E\u793A\u62BD\u5956\u5F39\u7A97\uFF01");
  665. }
  666. break;
  667. }
  668. }
  669. }
  670. if (result != YZ_Constant_1.BeForGameOverAdId.None) {
  671. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  672. this._lastShowGameOverAdType = result;
  673. return result;
  674. }
  675. if (befor_game_over_shortcut_interval && level % befor_game_over_shortcut_interval == 0) {
  676. Utils_1.utils.showLog("进入显示添加桌面弹窗判断", befor_game_over_shortcut_type, "<<");
  677. if (showCount > 1) {
  678. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.CreateShortCut;
  679. }
  680. if (isShow) {
  681. switch (befor_game_over_shortcut_type) {
  682. case "all":
  683. result = YZ_Constant_1.BeForGameOverAdId.CreateShortCut;
  684. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_shortcut_interval + "\u5173\uFF0C\u663E\u793A\u6DFB\u52A0\u684C\u9762\u5F39\u7A97\uFF01");
  685. break;
  686. case "success":
  687. if (isSuccess) {
  688. result = YZ_Constant_1.BeForGameOverAdId.CreateShortCut;
  689. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_shortcut_interval + "\u5173\uFF0C\u663E\u793A\u6DFB\u52A0\u684C\u9762\u5F39\u7A97\uFF01");
  690. }
  691. break;
  692. case "fail":
  693. if (!isSuccess) {
  694. result = YZ_Constant_1.BeForGameOverAdId.CreateShortCut;
  695. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_shortcut_interval + "\u5173\uFF0C\u663E\u793A\u6DFB\u52A0\u684C\u9762\u5F39\u7A97\uFF01");
  696. }
  697. break;
  698. }
  699. }
  700. }
  701. else {
  702. Utils_1.utils.showLog("结算前广告验证完成,不显示结算前广告!");
  703. }
  704. if (result != YZ_Constant_1.BeForGameOverAdId.None) {
  705. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  706. this._lastShowGameOverAdType = result;
  707. return result;
  708. }
  709. if (befor_game_over_rec_game_interval && level % befor_game_over_rec_game_interval == 0) {
  710. Utils_1.utils.showLog("进入显示游戏推荐弹窗判断", befor_game_over_rec_game_type, "<<");
  711. if (showCount > 1) {
  712. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.RecGame;
  713. }
  714. if (isShow) {
  715. switch (befor_game_over_rec_game_type) {
  716. case "all":
  717. result = YZ_Constant_1.BeForGameOverAdId.RecGame;
  718. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_rec_game_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  719. break;
  720. case "success":
  721. if (isSuccess) {
  722. result = YZ_Constant_1.BeForGameOverAdId.RecGame;
  723. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_rec_game_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  724. }
  725. break;
  726. case "fail":
  727. if (!isSuccess) {
  728. result = YZ_Constant_1.BeForGameOverAdId.RecGame;
  729. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_rec_game_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  730. }
  731. break;
  732. }
  733. }
  734. }
  735. else {
  736. Utils_1.utils.showLog("结算前广告验证完成,不显示更多游戏广告!");
  737. }
  738. if (result != YZ_Constant_1.BeForGameOverAdId.None) {
  739. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  740. this._lastShowGameOverAdType = result;
  741. return result;
  742. }
  743. if (befor_game_over_luck_box_interval && level % befor_game_over_luck_box_interval == 0) {
  744. Utils_1.utils.showLog("进入显示幸运宝箱弹窗判断", befor_game_over_luck_box_type, "<<");
  745. if (showCount > 1) {
  746. isShow = this._lastShowGameOverAdType != YZ_Constant_1.BeForGameOverAdId.LuckBox;
  747. }
  748. if (isShow) {
  749. switch (befor_game_over_luck_box_type) {
  750. case "all":
  751. result = YZ_Constant_1.BeForGameOverAdId.LuckBox;
  752. Utils_1.utils.showLog("\u95F4\u9694" + befor_game_over_luck_box_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  753. break;
  754. case "success":
  755. if (isSuccess) {
  756. result = YZ_Constant_1.BeForGameOverAdId.LuckBox;
  757. Utils_1.utils.showLog("\u6E38\u620F\u80DC\u5229 >> \u95F4\u9694" + befor_game_over_luck_box_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  758. }
  759. break;
  760. case "fail":
  761. if (!isSuccess) {
  762. result = YZ_Constant_1.BeForGameOverAdId.LuckBox;
  763. Utils_1.utils.showLog("\u6E38\u620F\u5931\u8D25 >> \u95F4\u9694" + befor_game_over_luck_box_interval + "\u5173\uFF0C\u663E\u793A\u6E38\u620F\u63A8\u8350\u5F39\u7A97\uFF01");
  764. }
  765. break;
  766. }
  767. }
  768. }
  769. else {
  770. Utils_1.utils.showLog("结算前广告验证完成,不显示幸运宝箱弹窗!");
  771. }
  772. }
  773. Utils_1.utils.showLog("结算前广告验证完成,显示结算前广告类型:", result);
  774. this._lastShowGameOverAdType = result;
  775. return result;
  776. };
  777. /**
  778. * 显示录屏分享窗口
  779. * @param params
  780. */
  781. AdManager.prototype.showShareRecordPanel = function (params) {
  782. if (params === void 0) { params = null; }
  783. if (!Utils_1.utils._isConfigInit) {
  784. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  785. return null;
  786. }
  787. if (Utils_1.utils.config.otherconfig.shareRecordPanel) {
  788. var node = cc.instantiate(Utils_1.utils.config.otherconfig.shareRecordPanel);
  789. if (node) {
  790. if (Utils_1.utils.shareRecordPanel && cc.isValid(Utils_1.utils.shareRecordPanel)) {
  791. Utils_1.utils.shareRecordPanel.destroy();
  792. }
  793. Utils_1.utils.shareRecordPanel = node;
  794. Utils_1.utils.shareRecordPanel.zIndex = 9999;
  795. var widget = node.getComponent(cc.Widget);
  796. if (params) {
  797. if (params.group) {
  798. node.group = params.group;
  799. }
  800. if (params.scale != null) {
  801. node.scale = params.scale;
  802. }
  803. if (params.top != null) {
  804. widget.isAlignTop = true;
  805. widget.isAlignBottom = false;
  806. widget.top = params.top;
  807. }
  808. else if (params.bottom != null) {
  809. widget.isAlignTop = false;
  810. widget.isAlignBottom = true;
  811. widget.bottom = params.bottom;
  812. }
  813. if (params.left != null) {
  814. widget.isAlignLeft = true;
  815. widget.isAlignRight = false;
  816. widget.left = params.left;
  817. }
  818. else if (params.right != null) {
  819. widget.isAlignLeft = false;
  820. widget.isAlignRight = true;
  821. widget.right = params.right;
  822. }
  823. if (params.parent != null) {
  824. node.parent = params.parent;
  825. }
  826. else {
  827. cc.director.getScene().addChild(Utils_1.utils.shareRecordPanel, 1000);
  828. }
  829. }
  830. else {
  831. cc.director.getScene().addChild(Utils_1.utils.shareRecordPanel, 1000);
  832. }
  833. widget.updateAlignment();
  834. return node;
  835. }
  836. }
  837. else {
  838. Utils_1.utils.showLog("未找到预制体 ShareRecordPanel, 请查看CommonUtils组件上是否赋值!");
  839. }
  840. return null;
  841. };
  842. /**
  843. * 显示宝箱窗口
  844. * @param params
  845. */
  846. AdManager.prototype.showRewardBoxPanel = function () {
  847. if (!Utils_1.utils._isConfigInit) {
  848. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  849. return null;
  850. }
  851. if (Utils_1.utils.config.otherconfig.rewardBoxPanel) {
  852. var node = cc.instantiate(Utils_1.utils.config.otherconfig.rewardBoxPanel);
  853. if (node) {
  854. if (this.rewardBoxPanel && cc.isValid(this.rewardBoxPanel)) {
  855. this.rewardBoxPanel.destroy();
  856. }
  857. this.rewardBoxPanel = node;
  858. this.rewardBoxPanel.zIndex = 9999;
  859. cc.director.getScene().addChild(node, 1000);
  860. return node;
  861. }
  862. }
  863. else {
  864. Utils_1.utils.showLog("未找到预制体 rewardBoxPanel, 请查看CommonUtils组件上是否赋值!");
  865. }
  866. return null;
  867. };
  868. /**
  869. * 显示更多游戏推荐窗口
  870. * @param params
  871. */
  872. AdManager.prototype.showRecGamePanel = function () {
  873. if (!Utils_1.utils._isConfigInit) {
  874. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  875. return null;
  876. }
  877. if (Utils_1.utils.config.otherconfig.beforGameOverRecGamesPanel && Utils_1.utils.getRecommondGameList()) {
  878. var node = cc.instantiate(Utils_1.utils.config.otherconfig.beforGameOverRecGamesPanel);
  879. if (node) {
  880. if (this.rewardRecGamePanel && cc.isValid(this.rewardRecGamePanel)) {
  881. this.rewardRecGamePanel.destroy();
  882. }
  883. this.rewardRecGamePanel = node;
  884. this.rewardRecGamePanel.zIndex = 9999;
  885. cc.director.getScene().addChild(node, 1000);
  886. var recMoreGame = this.rewardRecGamePanel.getComponent(BeforGameOverRecGamesPanel_1.default);
  887. recMoreGame._location = YZ_Constant_1.SubLocation.isBeforGameOverAd;
  888. recMoreGame.init(Utils_1.utils.getRecommondGameList());
  889. recMoreGame.show();
  890. return node;
  891. }
  892. }
  893. else {
  894. Utils_1.utils.showLog("未找到预制体 moreGamesPanel, 请查看CommonUtils组件上是否赋值!");
  895. }
  896. return null;
  897. };
  898. /**
  899. * 显示转盘抽奖窗口
  900. * @param params
  901. */
  902. AdManager.prototype.showrewardTurnTablePanel = function () {
  903. if (!Utils_1.utils._isConfigInit) {
  904. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  905. return null;
  906. }
  907. if (Utils_1.utils.config.otherconfig.rewardTurnTablePanel) {
  908. var node = cc.instantiate(Utils_1.utils.config.otherconfig.rewardTurnTablePanel);
  909. if (node) {
  910. if (this.rewardTurnTablePanel && cc.isValid(this.rewardTurnTablePanel)) {
  911. this.rewardTurnTablePanel.destroy();
  912. }
  913. this.rewardTurnTablePanel = node;
  914. this.rewardTurnTablePanel.zIndex = 9999;
  915. cc.director.getScene().addChild(node, 1000);
  916. return node;
  917. }
  918. }
  919. else {
  920. Utils_1.utils.showLog("未找到预制体 rewardTurnTablePanel, 请查看CommonUtils组件上是否赋值!");
  921. }
  922. return null;
  923. };
  924. /**
  925. * 显示转盘抽奖窗口
  926. * @param params
  927. */
  928. AdManager.prototype.showRewardShortCutPanel = function () {
  929. if (!Utils_1.utils._isConfigInit) {
  930. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  931. return null;
  932. }
  933. if (Utils_1.utils.config.otherconfig.rewardShortCutPanel) {
  934. var node = cc.instantiate(Utils_1.utils.config.otherconfig.rewardShortCutPanel);
  935. if (node) {
  936. if (this.rewardShortCutPanel && cc.isValid(this.rewardShortCutPanel)) {
  937. this.rewardShortCutPanel.destroy();
  938. }
  939. this.rewardShortCutPanel = node;
  940. this.rewardShortCutPanel.zIndex = 9999;
  941. cc.director.getScene().addChild(node, 1000);
  942. return node;
  943. }
  944. }
  945. else {
  946. Utils_1.utils.showLog("未找到预制体 rewardShortCutPanel, 请查看CommonUtils组件上是否赋值!");
  947. }
  948. return null;
  949. };
  950. /**
  951. * 展示幸运宝箱弹窗
  952. * @param params
  953. */
  954. AdManager.prototype.showRewardLuckBoxPanel = function () {
  955. if (!Utils_1.utils._isConfigInit) {
  956. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  957. return null;
  958. }
  959. if (Utils_1.utils.config.otherconfig.rewardLuckBoxPanel) {
  960. var node = cc.instantiate(Utils_1.utils.config.otherconfig.rewardLuckBoxPanel);
  961. if (node) {
  962. if (this._rewardLuckBoxPanel && cc.isValid(this._rewardLuckBoxPanel)) {
  963. this._rewardLuckBoxPanel.destroy();
  964. }
  965. this._rewardLuckBoxPanel = node;
  966. this._rewardLuckBoxPanel.zIndex = 9999;
  967. cc.director.getScene().addChild(node, 1000);
  968. return node;
  969. }
  970. }
  971. else {
  972. Utils_1.utils.showLog("未找到预制体 RewardLuckBoxPanel, 请查看CommonUtils组件上是否赋值!");
  973. }
  974. return null;
  975. };
  976. /**
  977. * 验证广告显示时间是否达到
  978. * @returns true:大于服务器时间 false:小于服务器时间
  979. */
  980. AdManager.prototype.checkShowAdTime = function () {
  981. // if (CC_DEBUG) return true;
  982. if (!Utils_1.utils._isConfigInit) {
  983. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  984. return false;
  985. }
  986. var curTime = new Date().getTime();
  987. var interval = (curTime - Utils_1.utils._gameEntryTime) / 1000;
  988. var showAdTime = 0;
  989. if (PlatUtils_1.default.IsOPPO) {
  990. showAdTime = 90;
  991. }
  992. if (Utils_1.utils.getConfigByKey("show_ad_time") !== "") {
  993. showAdTime = Utils_1.utils.getConfigByKey("show_ad_time");
  994. }
  995. Utils_1.utils.showLog("验证当前广告显示时间:#showAdTime=", showAdTime, " #interval=", interval);
  996. if (interval >= showAdTime) {
  997. return true;
  998. }
  999. return false;
  1000. };
  1001. /**
  1002. * 验证是否能够显示插屏
  1003. * @returns true 可以显示,false 未达到要求不显示
  1004. */
  1005. AdManager.prototype.checkInsertAdTime = function () {
  1006. // utils.ServerConfig.insert_ad_interval_time = 5;
  1007. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.insert_ad_interval_time) {
  1008. var curTime = new Date().getTime();
  1009. var interval = (curTime - this._insertLastShowTime) / 1000;
  1010. if (interval < Utils_1.utils.ServerConfig.insert_ad_interval_time) {
  1011. Utils_1.utils.showLog("验证当前插屏广告显示时间:#showAdTime=", Utils_1.utils.ServerConfig.insert_ad_interval_time, " #interval=", interval);
  1012. return false;
  1013. }
  1014. this._insertLastShowTime = curTime;
  1015. }
  1016. return true;
  1017. };
  1018. /**
  1019. * 显示积木广告
  1020. * @param parme {top,bottom}
  1021. */
  1022. AdManager.prototype.showBlockAd = function (parme) {
  1023. if (this._curAdAgent && PlatUtils_1.default.IsQQ) {
  1024. this._curAdAgent.showBlockAd(parme);
  1025. }
  1026. };
  1027. AdManager.prototype.hideBlockAd = function (parme) {
  1028. if (this._curAdAgent && PlatUtils_1.default.IsQQ) {
  1029. this._curAdAgent.hideBlockAd();
  1030. }
  1031. };
  1032. /**
  1033. * 显示全屏视频广告
  1034. * @param callback
  1035. */
  1036. AdManager.prototype.showFullScreenVideo = function (callback) {
  1037. if (this._curAdAgent) {
  1038. // this.videoCallBack = callback;
  1039. this._curAdAgent.showFullScreenVideo(callback);
  1040. }
  1041. else {
  1042. if (callback)
  1043. callback(false, "视频加载失败2!");
  1044. }
  1045. };
  1046. /**
  1047. * 显示单个原生广告
  1048. * @param params
  1049. */
  1050. AdManager.prototype.ShowSingleNativeAd = function (params) {
  1051. if (!this.checkShowAdTime()) {
  1052. Utils_1.utils.showLog("显示广告条时间未达限制!");
  1053. return;
  1054. }
  1055. if (this._curAdAgent) {
  1056. this._curAdAgent.ShowSingleNativeAd && this._curAdAgent.ShowSingleNativeAd(params);
  1057. }
  1058. };
  1059. /**
  1060. * 隐藏单个原生广告
  1061. * @param params
  1062. */
  1063. AdManager.prototype.HideSingleNativeAd = function (params) {
  1064. if (this._curAdAgent) {
  1065. this._curAdAgent.HideSingleNativeAd && this._curAdAgent.HideSingleNativeAd(params);
  1066. }
  1067. };
  1068. /**
  1069. * 显示模版广告
  1070. * @param parmas
  1071. */
  1072. AdManager.prototype.showCustomAd = function (params) {
  1073. if (!this.checkShowAdTime()) {
  1074. Utils_1.utils.showLog("显示原生模版广告时间未达限制!");
  1075. return;
  1076. }
  1077. if (this._curAdAgent) {
  1078. this._curAdAgent.showCustomAd && this._curAdAgent.showCustomAd(params);
  1079. }
  1080. };
  1081. /**
  1082. * 隐藏模版广告
  1083. * @param parmas
  1084. */
  1085. AdManager.prototype.hideCustomAd = function (params) {
  1086. if (this._curAdAgent) {
  1087. this._curAdAgent.hideCustomAd && this._curAdAgent.hideCustomAd(params);
  1088. }
  1089. };
  1090. /**
  1091. * 显示模版弹窗广告
  1092. * level: 当前关卡数
  1093. * closeCallFunc:Function 关闭后的回调
  1094. */
  1095. AdManager.prototype.showCustomAdPanel = function (level, closeCallFunc) {
  1096. Utils_1.utils.showLog("显示模版弹窗广告");
  1097. if (!Utils_1.utils._isConfigInit) {
  1098. Utils_1.utils.showLog("warn:" + "组件配置未初始化!");
  1099. return null;
  1100. }
  1101. var customAdInfo = null;
  1102. if (PlatUtils_1.default.IsWechat) {
  1103. customAdInfo = Utils_1.utils.config.wechatconfig.getCustomAdInfoInfo(100);
  1104. if (!customAdInfo) {
  1105. closeCallFunc && closeCallFunc();
  1106. Utils_1.utils.showLog("服务器未配置模版弹窗广告");
  1107. return;
  1108. }
  1109. }
  1110. else {
  1111. closeCallFunc && closeCallFunc();
  1112. Utils_1.utils.showLog("服务器未配置模版弹窗广告");
  1113. return;
  1114. }
  1115. var custom_panel_show_ad_level = Utils_1.utils.getConfigByKey("custom_panel_show_ad_level");
  1116. if (custom_panel_show_ad_level && level % custom_panel_show_ad_level != 0) {
  1117. closeCallFunc && closeCallFunc();
  1118. Utils_1.utils.showLog("服务器配置间隔" + custom_panel_show_ad_level + "关显示模版弹窗广告!");
  1119. return;
  1120. }
  1121. if (Utils_1.utils.config.otherconfig.yzCustomAdPanel) {
  1122. if (this._curAdAgent) {
  1123. this._curAdAgent.createCustomADBanner();
  1124. }
  1125. var node = cc.instantiate(Utils_1.utils.config.otherconfig.yzCustomAdPanel);
  1126. node.getComponent(YzCustomAdPanel_1.default).closeCallFunc = closeCallFunc;
  1127. if (node) {
  1128. if (this._customAdPanel && cc.isValid(this._customAdPanel)) {
  1129. this._customAdPanel.destroy();
  1130. }
  1131. this._customAdPanel = node;
  1132. this._customAdPanel.zIndex = 9999;
  1133. cc.director.getScene().addChild(node, 1000);
  1134. return node;
  1135. }
  1136. }
  1137. else {
  1138. Utils_1.utils.showLog("未找到预制体 CustomAdPanel, 请查看CommonUtils组件上是否赋值!");
  1139. }
  1140. return null;
  1141. };
  1142. AdManager = __decorate([
  1143. ccclass
  1144. ], AdManager);
  1145. return AdManager;
  1146. }());
  1147. exports.default = AdManager;
  1148. cc._RF.pop();