45557cc6-bc91-4c3a-aeec-a1d86a165170.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. "use strict";
  2. cc._RF.push(module, '45557zGvJFMOq7sodhqFlFw', 'UIPausePanel');
  3. // scripts/UI/UIPausePanel.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. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  25. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  26. return new (P || (P = Promise))(function (resolve, reject) {
  27. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  29. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  30. step((generator = generator.apply(thisArg, _arguments || [])).next());
  31. });
  32. };
  33. var __generator = (this && this.__generator) || function (thisArg, body) {
  34. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  35. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36. function verb(n) { return function (v) { return step([n, v]); }; }
  37. function step(op) {
  38. if (f) throw new TypeError("Generator is already executing.");
  39. while (_) try {
  40. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  41. if (y = 0, t) op = [op[0] & 2, t.value];
  42. switch (op[0]) {
  43. case 0: case 1: t = op; break;
  44. case 4: _.label++; return { value: op[1], done: false };
  45. case 5: _.label++; y = op[1]; op = [0]; continue;
  46. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  47. default:
  48. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  49. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  50. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  51. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  52. if (t[2]) _.ops.pop();
  53. _.trys.pop(); continue;
  54. }
  55. op = body.call(thisArg, _);
  56. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  57. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  58. }
  59. };
  60. Object.defineProperty(exports, "__esModule", { value: true });
  61. var PlatUtils_1 = require("../../common-plugin/Scripts/PlatUtils");
  62. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  63. var YZ_Constant_1 = require("../../common-plugin/Scripts/YZ_Constant");
  64. var CocosZ_1 = require("../Framework/CocosZ");
  65. var Constant_1 = require("../Framework/Constant");
  66. var TweenEffect_1 = require("../Framework/TweenEffect");
  67. var UIPage_1 = require("../Framework/UIPage");
  68. var gameMgr_1 = require("../Game/gameMgr");
  69. var UpgradeMgr_1 = require("../Game/UpgradeMgr");
  70. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  71. var UIPausePanel = /** @class */ (function (_super) {
  72. __extends(UIPausePanel, _super);
  73. function UIPausePanel() {
  74. var _this = _super.call(this, Constant_1.PanelName.UIPausePanel) || this;
  75. _this._mask = null;
  76. _this._panel = null;
  77. _this.isValid() && _this.onLoad();
  78. return _this;
  79. }
  80. UIPausePanel.prototype.onLoad = function () {
  81. this._mask = this._page.getChildByName("mask");
  82. this._panel = this._page.getChildByName("Panel");
  83. var btnNames = ["BtnRestart", "BtnResume", "BtnHome"];
  84. for (var i = 0; i < btnNames.length; i++) {
  85. var btn = cc.find(btnNames[i], this._panel);
  86. btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  87. }
  88. };
  89. UIPausePanel.prototype.onOpen = function () {
  90. Utils_1.utils.SendEvent("页面-暂停");
  91. this.showAd();
  92. TweenEffect_1.default.panel_mask_opacity(this._mask);
  93. TweenEffect_1.default.panel_open_moveY(this._panel);
  94. CocosZ_1.cocosz.pauseCount++;
  95. };
  96. UIPausePanel.prototype.onClose = function () {
  97. if (PlatUtils_1.default.IsVIVO) {
  98. Utils_1.utils.adManager.hideCustomAd({ location: YZ_Constant_1.BannerLocation.Pause });
  99. }
  100. CocosZ_1.cocosz.pauseCount--;
  101. };
  102. UIPausePanel.prototype.showAd = function () {
  103. if (CocosZ_1.cocosz.isShowAd) {
  104. if (PlatUtils_1.default.IsVIVO) {
  105. Utils_1.utils.adManager.showCustomAd({ location: YZ_Constant_1.BannerLocation.Pause });
  106. }
  107. }
  108. };
  109. /**
  110. * 所有按钮点击事件
  111. * @param event
  112. * @param data
  113. */
  114. UIPausePanel.prototype._onBtnClickedHandler = function (event, data) {
  115. return __awaiter(this, void 0, void 0, function () {
  116. return __generator(this, function (_a) {
  117. switch (_a.label) {
  118. case 0:
  119. //播放按钮点击音效
  120. return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  121. case 1:
  122. //播放按钮点击音效
  123. _a.sent();
  124. switch (event.target.name) {
  125. case "BtnRestart": {
  126. gameMgr_1.gameMgr.isFail = true;
  127. gameMgr_1.gameMgr.unscheduleAllCallbacks();
  128. UpgradeMgr_1.upgradeMgr && UpgradeMgr_1.upgradeMgr.unscheduleAllCallbacks();
  129. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIPausePanel);
  130. if (CocosZ_1.cocosz.gameMode == 6) {
  131. CocosZ_1.cocosz.gameMgr.gameStart(CocosZ_1.cocosz.dataMgr.TotoalCount_6);
  132. }
  133. break;
  134. }
  135. case "BtnResume": {
  136. cc.tween(this._panel)
  137. .to(0.5, { y: this._panel.y + 1000 }, { easing: "sineOut" })
  138. .call(function () {
  139. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIPausePanel);
  140. })
  141. .start();
  142. break;
  143. }
  144. case "BtnHome": {
  145. gameMgr_1.gameMgr.isFail = true;
  146. gameMgr_1.gameMgr.unscheduleAllCallbacks();
  147. UpgradeMgr_1.upgradeMgr && UpgradeMgr_1.upgradeMgr.unscheduleAllCallbacks();
  148. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIPausePanel);
  149. CocosZ_1.cocosz.sceneMgr.loadScene("Home", (function () {
  150. CocosZ_1.cocosz.uiMgr.openPage(Constant_1.PageName.UIHomePage);
  151. }));
  152. break;
  153. }
  154. }
  155. return [2 /*return*/];
  156. }
  157. });
  158. });
  159. };
  160. UIPausePanel = __decorate([
  161. ccclass
  162. ], UIPausePanel);
  163. return UIPausePanel;
  164. }(UIPage_1.default));
  165. exports.default = UIPausePanel;
  166. cc._RF.pop();