b88578a4-58af-41c8-a657-cbf3335a1b5d.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. "use strict";
  2. cc._RF.push(module, 'b8857ikWK9ByKZXy/MzWhtd', 'SetNormalPanel');
  3. // Script/view/setNormal/SetNormalPanel.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 (Object.prototype.hasOwnProperty.call(b, 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 BaseView_1 = require("../../../lightMVC/core/base/BaseView");
  26. var App_1 = require("../../Manager/App");
  27. var SDK_1 = require("../../sdk/SDK");
  28. var Interstitial_1 = require("../../sdk/vivo/Interstitial");
  29. var TimeControl_1 = require("../../TimeControl");
  30. var ATAndroidJS2_1 = require("../../ATAndroidJS2");
  31. var ATInterstitialJSSDK_1 = require("../../AnyThinkAds/ATInterstitialJSSDK");
  32. var ATAndroidJS2_2 = require("../../ATAndroidJS2");
  33. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  34. var SetNormalPanel = /** @class */ (function (_super) {
  35. __extends(SetNormalPanel, _super);
  36. function SetNormalPanel() {
  37. return _super !== null && _super.apply(this, arguments) || this;
  38. }
  39. SetNormalPanel.prototype.drawView = function () {
  40. var _this = this;
  41. SDK_1.default.Instance.showInterstitial(Interstitial_1.InterstitialType.INTERSTITIAL_GAME_PAUSE);
  42. // 返回
  43. var closeBtn = this.ui.getNode("close");
  44. closeBtn.on(cc.Node.EventType.TOUCH_END, function () {
  45. cc.director.resume();
  46. _this.closeView();
  47. }, this);
  48. var btnBack = this.ui.getNode("btnBackhall");
  49. btnBack.on(cc.Node.EventType.TOUCH_END, function () {
  50. _this.showInterAd("callBackFor_btnBackhall", false, _this.callBackFor_btnBackhall);
  51. // console.log('zh:btnBackhall111 ')
  52. // cc.director.resume();
  53. // cc.director.loadScene("hallScene");
  54. }, this);
  55. this.setMusic();
  56. this.setEffect();
  57. var button_debug = this.ui.getNode("button_debug");
  58. button_debug.on(cc.Node.EventType.TOUCH_END, function () {
  59. console.log('zh:button_debug ');
  60. TimeControl_1.default.instance.currentTili = 1;
  61. App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Tili, TimeControl_1.default.instance.currentTili);
  62. }, this);
  63. };
  64. SetNormalPanel.prototype.callBackFor_btnBackhall = function () {
  65. cc.director.resume();
  66. cc.director.loadScene("hallScene");
  67. };
  68. SetNormalPanel.prototype.debugTest = function () {
  69. };
  70. //设置音乐
  71. SetNormalPanel.prototype.setMusic = function () {
  72. var MusicBtn = this.ui.getNode("music");
  73. var musicOn = MusicBtn.getChildByName('on');
  74. var musicOff = MusicBtn.getChildByName('off');
  75. musicOn.active = (App_1.App.SoundManager.allowPlayBGM) ? true : false;
  76. musicOff.active = (App_1.App.SoundManager.allowPlayBGM) ? false : true;
  77. MusicBtn.on(cc.Node.EventType.TOUCH_END, function () {
  78. App_1.App.SoundManager.allowPlayBGM = !App_1.App.SoundManager.allowPlayBGM;
  79. musicOn.active = (App_1.App.SoundManager.allowPlayBGM) ? true : false;
  80. musicOff.active = (App_1.App.SoundManager.allowPlayBGM) ? false : true;
  81. App_1.App.LocalStorageUtil.setBoolean(App_1.App.LocalStorageUtil.lst_music, App_1.App.SoundManager.allowPlayBGM);
  82. console.log('点击音乐', App_1.App.SoundManager.allowPlayBGM);
  83. }, this);
  84. };
  85. //设置音效
  86. SetNormalPanel.prototype.setEffect = function () {
  87. var EffectBtn = this.ui.getNode("audio");
  88. var effectOn = EffectBtn.getChildByName('on');
  89. var effectOff = EffectBtn.getChildByName('off');
  90. effectOn.active = (App_1.App.SoundManager.allowPlayEffect) ? true : false;
  91. effectOff.active = (App_1.App.SoundManager.allowPlayEffect) ? false : true;
  92. EffectBtn.on(cc.Node.EventType.TOUCH_END, function () {
  93. App_1.App.SoundManager.allowPlayEffect = !App_1.App.SoundManager.allowPlayEffect;
  94. effectOn.active = (App_1.App.SoundManager.allowPlayEffect) ? true : false;
  95. effectOff.active = (App_1.App.SoundManager.allowPlayEffect) ? false : true;
  96. App_1.App.LocalStorageUtil.setBoolean(App_1.App.LocalStorageUtil.lst_effect, App_1.App.SoundManager.allowPlayEffect);
  97. console.log('点击音效', App_1.App.SoundManager.allowPlayEffect);
  98. }, this);
  99. };
  100. SetNormalPanel.path = function () {
  101. return "hallScene/prefabs/SetNormalPanel";
  102. };
  103. /**
  104. * 显示插屏广告
  105. *
  106. * @param adMarkForClose 插屏广告关闭后调用那个方法的具体指示标识
  107. * @param checkClose 是否需要判断关闭事件,有的不需要,如果AD占用游戏时间则为true
  108. * @param callback 插屏广告关闭(加载失败\非ANDROID平台)的回调
  109. */
  110. SetNormalPanel.prototype.showInterAd = function (adMarkForClose, checkClose, callback) {
  111. if (cc.sys.os === cc.sys.OS_ANDROID) {
  112. if (checkClose) {
  113. cc.sys.localStorage.setItem("adMarkForClose", adMarkForClose); //关闭后,调用哪个方法的标识
  114. }
  115. //add判断插屏 开屏等
  116. var pid_inter = ATAndroidJS2_1.default.getPlacementId2(ATAndroidJS2_2.AdType.Inter);
  117. var boo = ATInterstitialJSSDK_1.default.hasAdReady(pid_inter);
  118. if (boo) {
  119. // 暂停游戏
  120. cc.director.pause();
  121. console.log('zh:showInterAd AD OK');
  122. ATInterstitialJSSDK_1.default.showAd(pid_inter);
  123. //因为跨脚本,所以使用全局注册函数调用,后来发现切换APP,导致ad close事件失效
  124. if (!checkClose) { //如果不占用游戏时间
  125. this.safeCallback(callback);
  126. }
  127. }
  128. else {
  129. console.log('zh:showInterAd AD 没有准备好');
  130. //GlobalManager.getInstance().callMethod('initAdForPageInter');
  131. //this.initAdForPageInter();
  132. this.safeCallback(callback);
  133. }
  134. }
  135. else {
  136. this.safeCallback(callback);
  137. }
  138. };
  139. // 辅助方法:安全调用回调函数
  140. SetNormalPanel.prototype.safeCallback = function (callback) {
  141. if (callback) {
  142. callback();
  143. }
  144. };
  145. SetNormalPanel = __decorate([
  146. ccclass
  147. ], SetNormalPanel);
  148. return SetNormalPanel;
  149. }(BaseView_1.BaseView));
  150. exports.default = SetNormalPanel;
  151. cc._RF.pop();