f624a1a2-fd09-48b9-90db-4c5187409b97.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. "use strict";
  2. cc._RF.push(module, 'f624aGi/QlIuZDbTFGHQJuX', 'UIRevivePanel');
  3. // scripts/UI/UIRevivePanel.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 UIPage_1 = require("../Framework/UIPage");
  62. var Msg_1 = require("../Framework/Msg");
  63. var Constant_1 = require("../Framework/Constant");
  64. var CocosZ_1 = require("../Framework/CocosZ");
  65. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  66. var gameMgr_1 = require("../Game/gameMgr");
  67. // @ts-ignore
  68. var i18n = require('LanguageData');
  69. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  70. var UIRevivePanel = /** @class */ (function (_super) {
  71. __extends(UIRevivePanel, _super);
  72. function UIRevivePanel() {
  73. var _this = _super.call(this, Constant_1.PanelName.UIRevivePanel) || this;
  74. _this._mask = null;
  75. _this._panel = null;
  76. _this._timeLabel = null;
  77. _this._proIcon = null;
  78. _this._btnVideo = null;
  79. _this._btnPass = null;
  80. _this._tw1 = null;
  81. _this._tw2 = null;
  82. _this.isValid() && _this.onLoad();
  83. return _this;
  84. }
  85. UIRevivePanel.prototype.onLoad = function () {
  86. this._mask = this._page.getChildByName("Mask");
  87. this._panel = this._page.getChildByName("Panel");
  88. this._timeLabel = this._panel.getChildByName("time").getComponent(cc.Label);
  89. this._proIcon = this._panel.getChildByName("shangquan").getComponent(cc.Sprite);
  90. this._btnVideo = this._panel.getChildByName("BtnVideo");
  91. this._btnVideo.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  92. this._btnPass = this._panel.getChildByName("BtnPass");
  93. this._btnPass.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  94. };
  95. UIRevivePanel.prototype.onOpen = function () {
  96. Utils_1.utils.SendEvent("页面-复活");
  97. this.showAd();
  98. this._initPanel();
  99. CocosZ_1.cocosz.pauseCount++;
  100. };
  101. UIRevivePanel.prototype.onClose = function () {
  102. CocosZ_1.cocosz.pauseCount--;
  103. };
  104. UIRevivePanel.prototype.showAd = function () { };
  105. UIRevivePanel.prototype._initPanel = function () {
  106. var _this = this;
  107. var opacityBack = this._mask.opacity;
  108. this._mask.opacity = 0;
  109. cc.tween(this._mask).to(0.2, { opacity: opacityBack }).start();
  110. this._panel.scale = 0;
  111. cc.tween(this._panel)
  112. .to(0.3, { scale: 1 }, { easing: "backOut" })
  113. .start();
  114. var count = 9;
  115. this._tw1 = cc.tween(this._timeLabel)
  116. .delay(1)
  117. .call(function () {
  118. _this._timeLabel.string = (--count).toString();
  119. })
  120. .union()
  121. .repeat(9)
  122. .call(function () {
  123. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  124. gameMgr_1.gameMgr.fail();
  125. })
  126. .start();
  127. this._tw2 = cc.tween(this._proIcon)
  128. .to(9, { fillRange: 0 })
  129. .start();
  130. };
  131. UIRevivePanel.prototype.stopTween = function () {
  132. if (CocosZ_1.cocosz.gameMode == 6) {
  133. this._tw1 && this._tw1.stop();
  134. this._tw2 && this._tw2.stop();
  135. }
  136. };
  137. /**
  138. * 所有按钮点击事件
  139. * @param event
  140. * @param data
  141. */
  142. UIRevivePanel.prototype._onBtnClickedHandler = function (event, data) {
  143. return __awaiter(this, void 0, void 0, function () {
  144. var _this = this;
  145. return __generator(this, function (_a) {
  146. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  147. this.stopTween();
  148. switch (event.target.name) {
  149. case "BtnVideo": {
  150. Utils_1.utils.umaEvent("gamefuhuo");
  151. // 分享
  152. if (this._btnVideo.getChildByName("share") && this._btnVideo.getChildByName("share").active) {
  153. Utils_1.utils.SendEvent("分享-复活");
  154. CocosZ_1.cocosz.share(function () {
  155. Utils_1.utils.SendEvent("分享-复活-成功");
  156. _this._reLive();
  157. }, function () {
  158. Utils_1.utils.SendEvent("分享-复活-失败");
  159. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  160. gameMgr_1.gameMgr.fail();
  161. });
  162. }
  163. // 视频
  164. else if (this._btnVideo.getChildByName("video") && this._btnVideo.getChildByName("video").active) {
  165. Utils_1.utils.SendEvent("视频-复活-播放1");
  166. CocosZ_1.cocosz.watchAD(function () {
  167. Utils_1.utils.SendEvent("视频-复活-成功1");
  168. _this._reLive();
  169. }, function () {
  170. Utils_1.utils.SendEvent("视频-复活-失败1");
  171. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  172. gameMgr_1.gameMgr.fail();
  173. });
  174. }
  175. // 失败
  176. else {
  177. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  178. gameMgr_1.gameMgr.fail();
  179. }
  180. break;
  181. }
  182. case "BtnPass": {
  183. Utils_1.utils.umaEvent("gamesurr");
  184. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  185. gameMgr_1.gameMgr.fail();
  186. break;
  187. }
  188. }
  189. return [2 /*return*/];
  190. });
  191. });
  192. };
  193. /**
  194. * 复活事件
  195. */
  196. UIRevivePanel.prototype._reLive = function () {
  197. Msg_1.default.Show(i18n.t("msg.fhcg")); //复活成功
  198. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  199. gameMgr_1.gameMgr.revive();
  200. };
  201. UIRevivePanel = __decorate([
  202. ccclass
  203. ], UIRevivePanel);
  204. return UIRevivePanel;
  205. }(UIPage_1.default));
  206. exports.default = UIRevivePanel;
  207. cc._RF.pop();