a963229b-20fb-4f0a-8bd9-d4fcc99c4e91.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. "use strict";
  2. cc._RF.push(module, 'a9632KbIPtPCovZ1PzJnE6R', 'UIOverPage');
  3. // scripts/UI/UIOverPage.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 Constant_1 = require("../Framework/Constant");
  63. var CocosZ_1 = require("../Framework/CocosZ");
  64. var PlatUtils_1 = require("../../common-plugin/Scripts/PlatUtils");
  65. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  66. var YZ_Constant_1 = require("../../common-plugin/Scripts/YZ_Constant");
  67. var gameMgr_1 = require("../Game/gameMgr");
  68. var UpgradeMgr_1 = require("../Game/UpgradeMgr");
  69. // @ts-ignore
  70. var i18n = require('LanguageData');
  71. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  72. var UIOverPage = /** @class */ (function (_super) {
  73. __extends(UIOverPage, _super);
  74. function UIOverPage() {
  75. var _this = _super.call(this, Constant_1.PageName.UIOverPage) || this;
  76. _this._panel = null;
  77. _this._mask = null;
  78. _this._btnContinue = null;
  79. _this._btnHome = null;
  80. _this._isToHome = false;
  81. _this.isValid() && _this.onLoad();
  82. return _this;
  83. }
  84. UIOverPage.prototype.onLoad = function () {
  85. this._mask = cc.find("Mask", this._page);
  86. this._panel = cc.find("Panel", this._page);
  87. this._btnContinue = cc.find("BtnContinue", this._panel);
  88. this._btnContinue.on(cc.Node.EventType.TOUCH_END, this._onBtnClickHandler, this);
  89. this._btnHome = cc.find("BtnHome", this._panel);
  90. this._btnHome.on(cc.Node.EventType.TOUCH_END, this._onBtnClickHandler, this);
  91. };
  92. UIOverPage.prototype.onOpen = function () {
  93. Utils_1.utils.SendEvent("页面-结算-" + (gameMgr_1.gameMgr.isWin ? "胜利" : "失败"));
  94. this.showAd();
  95. this._initPanel();
  96. CocosZ_1.cocosz.dataMgr.TotoalCount_6++;
  97. };
  98. UIOverPage.prototype.onClose = function () {
  99. cc.game.targetOff(this);
  100. Utils_1.utils.hideVivoGamePortalWidget();
  101. Utils_1.utils.hideOppoGameDrawerAdWidget();
  102. Utils_1.utils.adManager.hideBlockAd();
  103. Utils_1.utils.adManager.hideNativeTryGameWidget();
  104. Utils_1.utils.adManager.HideSingleNativeAd();
  105. if (PlatUtils_1.default.IsWechat) {
  106. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Over);
  107. Utils_1.utils.adManager.hideCustomAd({ location: 5 });
  108. Utils_1.utils.adManager.hideCustomAd({ location: 6 });
  109. Utils_1.utils.adManager.hideCustomAd({ location: 7 });
  110. }
  111. else if (PlatUtils_1.default.IsVIVO) {
  112. Utils_1.utils.adManager.hideCustomAd({ location: YZ_Constant_1.BannerLocation.Over });
  113. }
  114. };
  115. UIOverPage.prototype.showAd = function () {
  116. Utils_1.utils.adManager.ShowBanner(YZ_Constant_1.BannerLocation.Over, { width: 0.1, bottom: 1 });
  117. // 显示积木广告
  118. Utils_1.utils.adManager.showBlockAd({ top: 500 });
  119. // 悬浮icon
  120. Utils_1.utils.adManager.showNativeTryGameWidget({ right: 95, top: 500, scale: 1, parent: this._page });
  121. // 原生广告
  122. if (PlatUtils_1.default.IsWechat) {
  123. Utils_1.utils.adManager.showCustomAd({ location: 5 });
  124. Utils_1.utils.adManager.showCustomAd({ location: 6 });
  125. Utils_1.utils.adManager.showCustomAd({ location: 7 });
  126. }
  127. else if (PlatUtils_1.default.IsVIVO) {
  128. Utils_1.utils.adManager.showCustomAd({ location: YZ_Constant_1.BannerLocation.Over });
  129. }
  130. // 互推
  131. Utils_1.utils.showTryGamesWidget({ group: 'default', scale: 1, top: 180, right: 25, parent: this._page, location: YZ_Constant_1.BannerLocation.Over });
  132. Utils_1.utils.showMoreGamesWidget({ group: 'default', scale: 1, top: 300, left: 25, parent: this._page, location: YZ_Constant_1.BannerLocation.Over });
  133. Utils_1.utils.showRecommendGamesList({ group: 'default', scale: 1, parent: this._page, bottom: 1000 });
  134. Utils_1.utils.showVivoGamePortalWidget({ top: 500, location: YZ_Constant_1.BannerLocation.Over });
  135. Utils_1.utils.showOppoGameDrawerAdWidget({ bottom: 500, location: YZ_Constant_1.BannerLocation.Over });
  136. Utils_1.utils.showOppoRecBanner({ bottom: 500, left: 0, location: YZ_Constant_1.BannerLocation.Over });
  137. var result = null;
  138. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.isWin) {
  139. Utils_1.utils.GameWin(CocosZ_1.cocosz.getLevelId().toString());
  140. }
  141. else if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.isFail) {
  142. Utils_1.utils.GameFail(CocosZ_1.cocosz.getLevelId().toString());
  143. }
  144. // //当返回值不为空,并且返回值的node不为空,会返回6个互推节点
  145. if (result && result.node) {
  146. //获取到节点后,将返回值的node节点添加到指定节点上。
  147. result.node.position = cc.v2(0, 0);
  148. this._page.addChild(result.node, 0);
  149. }
  150. };
  151. UIOverPage.prototype.getSkillIDName = function (id) {
  152. return id + (UpgradeMgr_1.upgradeMgr.upgradeSkillMaxLevelArr[id] > 1 ? "_" + (UpgradeMgr_1.upgradeMgr.upgradeSkillArr[id] + 1) : "");
  153. };
  154. UIOverPage.prototype._initPanel = function () {
  155. // 弹窗效果
  156. this._mask.opacity = 0;
  157. cc.tween(this._mask).to(0.2, { opacity: 120 }).start();
  158. this._panel.scale = 0;
  159. cc.tween(this._panel).to(0.3, { scale: 1 }, { easing: "backOut" }).start();
  160. if (UpgradeMgr_1.upgradeMgr && UpgradeMgr_1.upgradeMgr.isValid) {
  161. // boss
  162. var kuang_boss = this._panel.getChildByName("kuang_boss");
  163. if (UpgradeMgr_1.upgradeMgr.bossKillId.length) {
  164. var kuang_boss_layout = kuang_boss.getChildByName("layout");
  165. if (kuang_boss_layout) {
  166. kuang_boss_layout.active = true;
  167. kuang_boss_layout.children.forEach(function (v, i) {
  168. if (UpgradeMgr_1.upgradeMgr.bossKillId.includes(parseInt(v.name))) {
  169. v.active = true;
  170. }
  171. else {
  172. v.active = false;
  173. }
  174. });
  175. }
  176. }
  177. else {
  178. var kuang_boss_no = kuang_boss.getChildByName("no");
  179. if (kuang_boss_no) {
  180. kuang_boss_no.active = true;
  181. }
  182. }
  183. // 技能
  184. var kuang_skill = this._panel.getChildByName("kuang_skill");
  185. if (UpgradeMgr_1.upgradeMgr.upgradeSkillArr.includes(1) || UpgradeMgr_1.upgradeMgr.upgradeSkillArr.includes(2) || UpgradeMgr_1.upgradeMgr.upgradeSkillArr.includes(3)) {
  186. var skill_scrollView = kuang_skill.getChildByName("skillScrollView");
  187. if (skill_scrollView) {
  188. skill_scrollView.active = true;
  189. var skill_content_1 = cc.find("view/content", skill_scrollView);
  190. if (skill_content_1) {
  191. UpgradeMgr_1.upgradeMgr.upgradeSkillArr.forEach(function (level, id) {
  192. if (UpgradeMgr_1.upgradeMgr.upgradeSkillMaxLevelArr[id] == 3) {
  193. // for (let i = 1; i <= level; i++) {
  194. var icon = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_icon_" + id + "_" + level, cc.SpriteFrame);
  195. if (icon) {
  196. var node = new cc.Node();
  197. var sprit = node.addComponent(cc.Sprite);
  198. sprit.spriteFrame = icon;
  199. sprit.sizeMode = cc.Sprite.SizeMode.CUSTOM;
  200. node.setContentSize(70, 70);
  201. skill_content_1.addChild(node);
  202. }
  203. // }
  204. }
  205. else if (level > 0) {
  206. var icon = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_icon_" + id, cc.SpriteFrame);
  207. if (icon) {
  208. var node = new cc.Node();
  209. var sprit = node.addComponent(cc.Sprite);
  210. sprit.spriteFrame = icon;
  211. sprit.sizeMode = cc.Sprite.SizeMode.CUSTOM;
  212. node.setContentSize(70, 70);
  213. skill_content_1.addChild(node);
  214. }
  215. }
  216. });
  217. }
  218. }
  219. }
  220. else {
  221. var kuang_skill_no = kuang_skill.getChildByName("no");
  222. if (kuang_skill_no) {
  223. kuang_skill_no.active = true;
  224. }
  225. }
  226. // 结算信息
  227. var info = cc.find("info", this._panel);
  228. if (info) {
  229. // 标题
  230. cc.log("iswin:", gameMgr_1.gameMgr.isWin, " isFail:", gameMgr_1.gameMgr.isFail);
  231. info.getChildByName('tittle').children[0].active = gameMgr_1.gameMgr.isWin;
  232. info.getChildByName('tittle').children[1].active = gameMgr_1.gameMgr.isFail;
  233. // 历史最佳
  234. // 游戏时间
  235. info.getChildByName('time2').getComponent(cc.Label).string = CocosZ_1.cocosz.StoHMS(CocosZ_1.cocosz.dataMgr.best_time);
  236. // 击杀数
  237. info.getChildByName('kill2').getComponent(cc.Label).string = CocosZ_1.cocosz.dataMgr.best_kill.toString();
  238. // 等级
  239. info.getChildByName('level2').getComponent(cc.Label).string = CocosZ_1.cocosz.dataMgr.best_level.toString();
  240. // 金币
  241. info.getChildByName('coin2').getComponent(cc.Label).string = CocosZ_1.cocosz.dataMgr.best_coin.toString();
  242. // 本局详情
  243. var newRecard1 = info.getChildByName('newRecard1');
  244. var newRecard2 = info.getChildByName('newRecard2');
  245. var newRecard3 = info.getChildByName('newRecard3');
  246. var newRecard4 = info.getChildByName('newRecard4');
  247. // 游戏时间
  248. info.getChildByName('time1').getComponent(cc.Label).string = CocosZ_1.cocosz.StoHMS(gameMgr_1.gameMgr.GameTime);
  249. if (gameMgr_1.gameMgr.GameTime > CocosZ_1.cocosz.dataMgr.best_time) {
  250. info.getChildByName('time1').color = cc.Color.RED;
  251. CocosZ_1.cocosz.dataMgr.best_time = gameMgr_1.gameMgr.GameTime;
  252. newRecard1.active = true;
  253. }
  254. // 击杀数
  255. info.getChildByName('kill1').getComponent(cc.Label).string = UpgradeMgr_1.upgradeMgr.zombieKillNum.toString();
  256. if (UpgradeMgr_1.upgradeMgr.zombieKillNum > CocosZ_1.cocosz.dataMgr.best_kill) {
  257. info.getChildByName('kill1').color = cc.Color.RED;
  258. CocosZ_1.cocosz.dataMgr.best_kill = UpgradeMgr_1.upgradeMgr.zombieKillNum;
  259. newRecard2.active = true;
  260. }
  261. // 等级
  262. info.getChildByName('level1').getComponent(cc.Label).string = UpgradeMgr_1.upgradeMgr.curLevel.toString();
  263. if (UpgradeMgr_1.upgradeMgr.curLevel > CocosZ_1.cocosz.dataMgr.best_level) {
  264. info.getChildByName('level1').color = cc.Color.RED;
  265. CocosZ_1.cocosz.dataMgr.best_level = UpgradeMgr_1.upgradeMgr.curLevel;
  266. newRecard3.active = true;
  267. }
  268. // 金币
  269. var count = UpgradeMgr_1.upgradeMgr.zombieKillNum + UpgradeMgr_1.upgradeMgr.curLevel * 10 + Math.min(500, Math.ceil(gameMgr_1.gameMgr.GameTime / 10));
  270. CocosZ_1.cocosz.dataMgr.CoinCount += count;
  271. info.getChildByName('coin1').getComponent(cc.Label).string = count.toString();
  272. if (count > CocosZ_1.cocosz.dataMgr.best_coin) {
  273. info.getChildByName('coin1').color = cc.Color.RED;
  274. CocosZ_1.cocosz.dataMgr.best_coin = count;
  275. newRecard4.active = true;
  276. }
  277. }
  278. }
  279. };
  280. UIOverPage.prototype._onBtnClickHandler = function (event) {
  281. return __awaiter(this, void 0, void 0, function () {
  282. return __generator(this, function (_a) {
  283. switch (_a.label) {
  284. case 0: return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  285. case 1:
  286. _a.sent();
  287. if (this._isToHome)
  288. return [2 /*return*/];
  289. switch (event.target.name) {
  290. case "BtnContinue": {
  291. // 上报 继续游戏
  292. Utils_1.utils.umaEvent("gamecontinue");
  293. if (CocosZ_1.cocosz.gameMode == 6) {
  294. CocosZ_1.cocosz.gameMgr.gameStart(CocosZ_1.cocosz.dataMgr.TotoalCount_6);
  295. }
  296. break;
  297. }
  298. case "BtnHome": {
  299. // 上报 返回首页
  300. Utils_1.utils.umaEvent("gamereturn");
  301. CocosZ_1.cocosz.sceneMgr.loadScene("Home", function () {
  302. CocosZ_1.cocosz.uiMgr.openPage(Constant_1.PageName.UIHomePage);
  303. });
  304. break;
  305. }
  306. }
  307. return [2 /*return*/];
  308. }
  309. });
  310. });
  311. };
  312. UIOverPage = __decorate([
  313. ccclass
  314. ], UIOverPage);
  315. return UIOverPage;
  316. }(UIPage_1.default));
  317. exports.default = UIOverPage;
  318. cc._RF.pop();