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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. var ATRewardedVideoJSSDK_1 = require("../AnyThinkAds/ATRewardedVideoJSSDK");
  68. var ATAndroidJS2_1 = require("../ATAndroidJS2");
  69. var GlobalManager_1 = require("../GlobalManager");
  70. // @ts-ignore
  71. var i18n = require('LanguageData');
  72. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  73. var UIRevivePanel = /** @class */ (function (_super) {
  74. __extends(UIRevivePanel, _super);
  75. function UIRevivePanel() {
  76. var _this = _super.call(this, Constant_1.PanelName.UIRevivePanel) || this;
  77. _this._mask = null;
  78. _this._panel = null;
  79. _this._timeLabel = null;
  80. _this._proIcon = null;
  81. _this._btnVideo = null;
  82. _this._btnPass = null;
  83. _this.adKey = "zh_ad_type";
  84. _this._tw1 = null;
  85. _this._tw2 = null;
  86. _this.isValid() && _this.onLoad();
  87. return _this;
  88. }
  89. UIRevivePanel.prototype.onLoad = function () {
  90. this._mask = this._page.getChildByName("Mask");
  91. this._panel = this._page.getChildByName("Panel");
  92. this._timeLabel = this._panel.getChildByName("time").getComponent(cc.Label);
  93. this._proIcon = this._panel.getChildByName("shangquan").getComponent(cc.Sprite);
  94. this._btnVideo = this._panel.getChildByName("BtnVideo");
  95. this._btnVideo.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  96. this._btnPass = this._panel.getChildByName("BtnPass");
  97. this._btnPass.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  98. this.initAdForPage();
  99. };
  100. UIRevivePanel.prototype.initAdForPage = function () {
  101. if (cc.sys.os === cc.sys.OS_ANDROID) {
  102. var deviceId = ATAndroidJS2_1.default.getDeviceUserId();
  103. console.log("zh:checkstatus:", ATRewardedVideoJSSDK_1.default.checkAdStatus(ATAndroidJS2_1.default.getPlacementId()));
  104. var setting = {};
  105. setting[ATRewardedVideoJSSDK_1.default.userIdKey] = deviceId;
  106. ATRewardedVideoJSSDK_1.default.loadRewardedVideo(ATAndroidJS2_1.default.getPlacementId(), setting);
  107. }
  108. };
  109. UIRevivePanel.prototype.onOpen = function () {
  110. Utils_1.utils.SendEvent("页面-复活");
  111. this.showAd();
  112. this._initPanel();
  113. CocosZ_1.cocosz.pauseCount++;
  114. };
  115. UIRevivePanel.prototype.onClose = function () {
  116. CocosZ_1.cocosz.pauseCount--;
  117. };
  118. UIRevivePanel.prototype.showAd = function () { };
  119. UIRevivePanel.prototype._initPanel = function () {
  120. var _this = this;
  121. var opacityBack = this._mask.opacity;
  122. this._mask.opacity = 0;
  123. cc.tween(this._mask).to(0.2, { opacity: opacityBack }).start();
  124. this._panel.scale = 0;
  125. cc.tween(this._panel)
  126. .to(0.3, { scale: 1 }, { easing: "backOut" })
  127. .start();
  128. var count = 9;
  129. this._tw1 = cc.tween(this._timeLabel)
  130. .delay(1)
  131. .call(function () {
  132. _this._timeLabel.string = (--count).toString();
  133. })
  134. .union()
  135. .repeat(9)
  136. .call(function () {
  137. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  138. gameMgr_1.gameMgr.fail();
  139. })
  140. .start();
  141. this._tw2 = cc.tween(this._proIcon)
  142. .to(9, { fillRange: 0 })
  143. .start();
  144. };
  145. UIRevivePanel.prototype.stopTween = function () {
  146. if (CocosZ_1.cocosz.gameMode == 6) {
  147. this._tw1 && this._tw1.stop();
  148. this._tw2 && this._tw2.stop();
  149. }
  150. };
  151. /**
  152. * 所有按钮点击事件
  153. * @param event
  154. * @param data
  155. */
  156. UIRevivePanel.prototype._onBtnClickedHandler = function (event, data) {
  157. return __awaiter(this, void 0, void 0, function () {
  158. var _this = this;
  159. return __generator(this, function (_a) {
  160. CocosZ_1.cocosz.audioMgr.playBtnEffect();
  161. this.stopTween();
  162. switch (event.target.name) {
  163. case "BtnVideo": {
  164. Utils_1.utils.umaEvent("gamefuhuo");
  165. // 分享
  166. if (this._btnVideo.getChildByName("share") && this._btnVideo.getChildByName("share").active) {
  167. Utils_1.utils.SendEvent("分享-复活");
  168. CocosZ_1.cocosz.share(function () {
  169. Utils_1.utils.SendEvent("分享-复活-成功");
  170. _this._reLive();
  171. }, function () {
  172. Utils_1.utils.SendEvent("分享-复活-失败");
  173. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  174. gameMgr_1.gameMgr.fail();
  175. });
  176. }
  177. // 视频
  178. else if (this._btnVideo.getChildByName("video") && this._btnVideo.getChildByName("video").active) {
  179. Utils_1.utils.SendEvent("视频-复活-播放1");
  180. // 注册方法 , this.ClickClose.bind(this));
  181. GlobalManager_1.default.getInstance().registerMethod('event_fuHuo', this._reLive.bind(this));
  182. cc.sys.localStorage.setItem(this.adKey, 'event_fuHuo');
  183. if (ATRewardedVideoJSSDK_1.default.hasAdReady(ATAndroidJS2_1.default.getPlacementId())) {
  184. console.log('zh:AD ready for idx2');
  185. ATRewardedVideoJSSDK_1.default.showAd(ATAndroidJS2_1.default.getPlacementId());
  186. }
  187. else {
  188. console.log('zh:AD not ready for idx2');
  189. this._reLive();
  190. }
  191. if (2 > 1) {
  192. return [2 /*return*/];
  193. }
  194. //下面是原先的
  195. CocosZ_1.cocosz.watchAD(function () {
  196. Utils_1.utils.SendEvent("视频-复活-成功1");
  197. _this._reLive();
  198. }, function () {
  199. Utils_1.utils.SendEvent("视频-复活-失败1");
  200. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  201. gameMgr_1.gameMgr.fail();
  202. });
  203. }
  204. // 失败
  205. else {
  206. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  207. gameMgr_1.gameMgr.fail();
  208. }
  209. break;
  210. }
  211. case "BtnPass": {
  212. Utils_1.utils.umaEvent("gamesurr");
  213. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  214. gameMgr_1.gameMgr.fail();
  215. break;
  216. }
  217. }
  218. return [2 /*return*/];
  219. });
  220. });
  221. };
  222. /**
  223. * 复活事件
  224. */
  225. UIRevivePanel.prototype._reLive = function () {
  226. console.log('zh:复活被触发');
  227. Msg_1.default.Show(i18n.t("msg.fhcg")); //复活成功
  228. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIRevivePanel);
  229. gameMgr_1.gameMgr.revive();
  230. };
  231. UIRevivePanel = __decorate([
  232. ccclass
  233. ], UIRevivePanel);
  234. return UIRevivePanel;
  235. }(UIPage_1.default));
  236. exports.default = UIRevivePanel;
  237. cc._RF.pop();