83dfc505-a7bf-422b-98cb-1d54ffadc821.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. "use strict";
  2. cc._RF.push(module, '83dfcUFp79CK5jLHVT/rcgh', 'UIWeaponLevelPanel');
  3. // scripts/UI/UIWeaponLevelPanel.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 Utils_1 = require("../../common-plugin/Scripts/Utils");
  62. var CocosZ_1 = require("../Framework/CocosZ");
  63. var Constant_1 = require("../Framework/Constant");
  64. var Msg_1 = require("../Framework/Msg");
  65. var UIPage_1 = require("../Framework/UIPage");
  66. var gameDate_1 = require("../Game/gameDate");
  67. var weapon_1 = require("../Game/weapon");
  68. // @ts-ignore
  69. var i18n = require('LanguageData');
  70. var ccclass = cc._decorator.ccclass;
  71. var UIWeaponLevelPanel = /** @class */ (function (_super) {
  72. __extends(UIWeaponLevelPanel, _super);
  73. function UIWeaponLevelPanel() {
  74. var _this = _super.call(this, Constant_1.PanelName.UIWeaponLevelPanel) || this;
  75. _this._panel = null;
  76. _this.weapon = null;
  77. _this.weaponId = 0;
  78. _this.isRange = true;
  79. _this.isValid() && _this.onLoad();
  80. return _this;
  81. }
  82. UIWeaponLevelPanel.prototype.onLoad = function () {
  83. this._panel = this._page.getChildByName("Panel");
  84. this.weapon = this._panel.getChildByName("weapon").getComponent(cc.Sprite);
  85. var btnNames = ["BtnPass", "BtnVideo"];
  86. for (var i = 0; i < btnNames.length; i++) {
  87. var btn = cc.find(btnNames[i], this._panel);
  88. if (btn) {
  89. btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickedHandler, this);
  90. }
  91. }
  92. };
  93. UIWeaponLevelPanel.prototype.onOpen = function () {
  94. Utils_1.utils.SendEvent("页面-武器升级");
  95. // 暂停游戏逻辑
  96. CocosZ_1.cocosz.pauseCount++;
  97. var weaponName = "";
  98. var level = 0;
  99. var rangeLevel = CocosZ_1.cocosz.dataMgr.getGunInfo(CocosZ_1.cocosz.dataMgr.CurRange).Level;
  100. var meleeLevel = CocosZ_1.cocosz.dataMgr.getGunInfo(CocosZ_1.cocosz.dataMgr.CurMelee).Level;
  101. if (rangeLevel < 3) {
  102. // 显示远程
  103. this.isRange = true;
  104. this.weaponId = CocosZ_1.cocosz.dataMgr.CurRange;
  105. weaponName = weapon_1.default.WeaponName[this.weaponId];
  106. level = rangeLevel;
  107. this.weapon.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("w_" + weaponName, cc.SpriteFrame);
  108. }
  109. else if (meleeLevel < 3) {
  110. // 显示近程
  111. this.isRange = false;
  112. this.weaponId = CocosZ_1.cocosz.dataMgr.CurMelee;
  113. weaponName = weapon_1.default.WeaponName[this.weaponId];
  114. level = meleeLevel;
  115. this.weapon.spriteFrame = CocosZ_1.cocosz.resMgr.getRes("w_" + weaponName, cc.SpriteFrame);
  116. }
  117. else {
  118. // 直接关闭
  119. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIWeaponLevelPanel);
  120. return;
  121. }
  122. // 显示数据
  123. var info = gameDate_1.default.Weapon[weaponName];
  124. var txt1 = cc.find("kuang/txt1", this._panel);
  125. if (txt1) {
  126. var richText = txt1.getComponent(cc.RichText);
  127. if (richText) {
  128. var curNum = info.atk[level];
  129. var nextNum = info.atk[3];
  130. var difNum = nextNum - curNum;
  131. richText.string = "<outline color=black width=2><color=white>" + (i18n.t("try.gjl") + ": " + curNum) + "</c><color=green}>" + (difNum > 0 ? (" +" + difNum) : "") + "</c></outline>";
  132. }
  133. }
  134. var txt2 = cc.find("kuang/txt2", this._panel);
  135. if (txt2) {
  136. var richText = txt2.getComponent(cc.RichText);
  137. if (richText) {
  138. var curNum = 1 / info.atkSpeed[level];
  139. var nextNum = 1 / info.atkSpeed[3];
  140. var difNum = nextNum - curNum;
  141. richText.string = "<outline color=black width=2><color=white>" + (i18n.t("try.gjpl") + ": " + curNum) + "</c><color=green}>" + (difNum > 0 ? (" +" + difNum) : "") + "</c></outline>";
  142. }
  143. }
  144. var txt3 = cc.find("kuang/txt3", this._panel);
  145. if (txt3) {
  146. var richText = txt3.getComponent(cc.RichText);
  147. if (richText) {
  148. var curNum = info.atkRange;
  149. richText.string = "<outline color=black width=2><color=white>" + (i18n.t("try.gjfw") + ": " + curNum) + "</c></outline>";
  150. }
  151. }
  152. var txt4 = cc.find("kuang/txt4", this._panel);
  153. if (txt4) {
  154. var richText = txt4.getComponent(cc.RichText);
  155. if (richText) {
  156. var curNum = info.bulletTotal[level];
  157. var nextNum = info.bulletTotal[3];
  158. var difNum = nextNum - curNum;
  159. richText.string = "<outline color=black width=2><color=white>" + (i18n.t("try.dyl") + ": " + (this.isRange ? curNum : "♾")) + "</c><color=green}>" + (difNum > 0 ? (" +" + difNum) : "") + "</c></outline>";
  160. }
  161. }
  162. };
  163. UIWeaponLevelPanel.prototype.onClose = function () {
  164. CocosZ_1.cocosz.gameMgr.gameStart(CocosZ_1.cocosz.curLevel);
  165. };
  166. /**
  167. * 所有按钮点击事件
  168. * @param event
  169. * @param data
  170. */
  171. UIWeaponLevelPanel.prototype._onBtnClickedHandler = function (event, data) {
  172. return __awaiter(this, void 0, void 0, function () {
  173. var _this = this;
  174. return __generator(this, function (_a) {
  175. switch (_a.label) {
  176. case 0:
  177. //播放按钮点击音效
  178. return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  179. case 1:
  180. //播放按钮点击音效
  181. _a.sent();
  182. switch (event.target.name) {
  183. case "BtnPass": {
  184. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIWeaponLevelPanel);
  185. break;
  186. }
  187. case "BtnVideo": {
  188. Utils_1.utils.SendEvent("视频-弹窗武器升级-播放");
  189. CocosZ_1.cocosz.watchAD(function () {
  190. // 视频成功
  191. Utils_1.utils.SendEvent("视频-弹窗武器升级-成功");
  192. var info = CocosZ_1.cocosz.dataMgr.getGunInfo(_this.weaponId);
  193. info.Level = 3; // 升到最高级别
  194. CocosZ_1.cocosz.dataMgr.setGunInfo(_this.weaponId, info);
  195. Msg_1.default.Show(i18n.t("msg.sjcg")); //升级成功
  196. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIWeaponLevelPanel);
  197. }, function () {
  198. // 视频失败
  199. Utils_1.utils.SendEvent("视频-弹窗武器升级-失败");
  200. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UIWeaponLevelPanel);
  201. });
  202. break;
  203. }
  204. }
  205. return [2 /*return*/];
  206. }
  207. });
  208. });
  209. };
  210. UIWeaponLevelPanel = __decorate([
  211. ccclass
  212. ], UIWeaponLevelPanel);
  213. return UIWeaponLevelPanel;
  214. }(UIPage_1.default));
  215. exports.default = UIWeaponLevelPanel;
  216. cc._RF.pop();