f4901417-cfce-42e5-8ecf-10ab0076fb0c.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. "use strict";
  2. cc._RF.push(module, 'f4901QXz85C5Y7PEKsAdvsM', 'UpgradeMgr');
  3. // scripts/Game/UpgradeMgr.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. Object.defineProperty(exports, "__esModule", { value: true });
  25. exports.upgradeMgr = exports.SkillType = void 0;
  26. var CocosZ_1 = require("../Framework/CocosZ");
  27. var Constant_1 = require("../Framework/Constant");
  28. var bullet_1 = require("./bullet");
  29. var gameMgr_1 = require("./gameMgr");
  30. var jingyan_1 = require("./jingyan");
  31. var ZombieBase_1 = require("./ZombieBase");
  32. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  33. var SkillType;
  34. (function (SkillType) {
  35. SkillType[SkillType["\u6574\u88C5\u5F85\u53D1"] = 0] = "\u6574\u88C5\u5F85\u53D1";
  36. SkillType[SkillType["\u7784\u51C6"] = 1] = "\u7784\u51C6";
  37. SkillType[SkillType["\u5F3A\u5316"] = 2] = "\u5F3A\u5316";
  38. SkillType[SkillType["\u77AC\u65A9"] = 3] = "\u77AC\u65A9";
  39. SkillType[SkillType["\u5F3A\u529B\u5C04\u51FB"] = 4] = "\u5F3A\u529B\u5C04\u51FB";
  40. SkillType[SkillType["\u7A83\u9B42\u5F39\u5939"] = 5] = "\u7A83\u9B42\u5F39\u5939";
  41. SkillType[SkillType["\u79D1\u6280\u5B50\u5F39"] = 6] = "\u79D1\u6280\u5B50\u5F39";
  42. SkillType[SkillType["\u7AD9\u59FF\u5C04\u51FB"] = 7] = "\u7AD9\u59FF\u5C04\u51FB";
  43. SkillType[SkillType["\u5B50\u5F39\u788E\u7247"] = 8] = "\u5B50\u5F39\u788E\u7247";
  44. SkillType[SkillType["\u53CC\u53D1"] = 9] = "\u53CC\u53D1";
  45. SkillType[SkillType["\u8C22\u5E55"] = 10] = "\u8C22\u5E55";
  46. SkillType[SkillType["\u67AA\u6797\u5F39\u96E8"] = 11] = "\u67AA\u6797\u5F39\u96E8";
  47. SkillType[SkillType["\u75BE\u8D70"] = 12] = "\u75BE\u8D70";
  48. SkillType[SkillType["\u8DD1\u52A8\u5C04\u51FB"] = 13] = "\u8DD1\u52A8\u5C04\u51FB";
  49. SkillType[SkillType["\u610F\u6C14\u98CE\u53D1"] = 14] = "\u610F\u6C14\u98CE\u53D1";
  50. SkillType[SkillType["\u62A4\u7532\u9774\u5B50"] = 15] = "\u62A4\u7532\u9774\u5B50";
  51. SkillType[SkillType["\u78C1\u573A"] = 16] = "\u78C1\u573A";
  52. SkillType[SkillType["\u7075\u80FD\u8865\u7ED9"] = 17] = "\u7075\u80FD\u8865\u7ED9";
  53. SkillType[SkillType["\u5BB9\u5149\u7115\u53D1"] = 18] = "\u5BB9\u5149\u7115\u53D1";
  54. SkillType[SkillType["\u9E70\u773C"] = 19] = "\u9E70\u773C";
  55. SkillType[SkillType["\u751F\u547D\u529B"] = 20] = "\u751F\u547D\u529B";
  56. SkillType[SkillType["\u518D\u751F"] = 21] = "\u518D\u751F";
  57. SkillType[SkillType["\u8FDB\u5316"] = 22] = "\u8FDB\u5316";
  58. SkillType[SkillType["\u8403\u53D6"] = 23] = "\u8403\u53D6";
  59. SkillType[SkillType["\u706B\u7130\u7CBE\u901A"] = 24] = "\u706B\u7130\u7CBE\u901A";
  60. SkillType[SkillType["\u96F7\u7535\u7CBE\u901A"] = 25] = "\u96F7\u7535\u7CBE\u901A";
  61. SkillType[SkillType["\u51B0\u971C\u7CBE\u901A"] = 26] = "\u51B0\u971C\u7CBE\u901A";
  62. SkillType[SkillType["\u53CC\u91CD\u9644\u9B54"] = 27] = "\u53CC\u91CD\u9644\u9B54";
  63. SkillType[SkillType["\u9F99\u5375"] = 28] = "\u9F99\u5375";
  64. SkillType[SkillType["\u901A\u7075\u5315\u9996"] = 29] = "\u901A\u7075\u5315\u9996";
  65. SkillType[SkillType["\u901A\u7075\u9570\u5200"] = 30] = "\u901A\u7075\u9570\u5200";
  66. SkillType[SkillType["\u795E\u5723\u5B88\u62A4"] = 31] = "\u795E\u5723\u5B88\u62A4";
  67. SkillType[SkillType["\u98DE\u8F6E"] = 32] = "\u98DE\u8F6E";
  68. SkillType[SkillType["\u95EA\u7535"] = 33] = "\u95EA\u7535";
  69. SkillType[SkillType["\u71C3\u70E7\u74F6"] = 34] = "\u71C3\u70E7\u74F6";
  70. })(SkillType = exports.SkillType || (exports.SkillType = {}));
  71. exports.upgradeMgr = null;
  72. var UpgradeMgr = /** @class */ (function (_super) {
  73. __extends(UpgradeMgr, _super);
  74. function UpgradeMgr() {
  75. var _this = _super !== null && _super.apply(this, arguments) || this;
  76. _this.bulletPrefab = null;
  77. _this.zombieKillNum = 0;
  78. _this.bossKillId = [];
  79. // 经验层
  80. _this.jingyanLayer = null;
  81. // 经验预制体
  82. _this.jingyanPre = null;
  83. // 经验触碰距离
  84. _this.jingyanRange = 200;
  85. // 升级经验
  86. _this._jingyanArr = [5, 10, 20, 25, 30, 40, 50, 60, 60, 70, 80, 90, 100, 110, 120, 130, 150, 170, 200, 220, 250, 280, 300, 350, 400, 500, 1000]; // 经验数组
  87. // private _jingyanArr: number[] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];// 经验数组
  88. // 已拥有技能
  89. _this.upgradeSkillArr = [
  90. 0, 0, 0, 0, 0,
  91. 0, 0, 0, 0, 0,
  92. 0, 0, 0, 0, 0,
  93. 0, 0, 0, 0, 0,
  94. 0, 0, 0, 0, 0,
  95. 0, 0, 0, 0, 0,
  96. 0, 0, 0, 0, 0
  97. ];
  98. _this.upgradeSkillMaxLevelArr = [
  99. 1, 1, 1, 1, 1,
  100. 1, 1, 1, 1, 1,
  101. 1, 1, 1, 1, 1,
  102. 1, 1, 1, 1, 1,
  103. 1, 1, 1, 1, 1,
  104. 1, 1, 1, 1, 1,
  105. 1, 1, 3, 3, 3,
  106. ];
  107. // 技能属性
  108. _this.skill_14 = 1; //增强倍率(伤害和移动速度)
  109. _this.skill_18 = 0; //加速时间
  110. _this.skill_magic = 0; //附魔技能的数量
  111. _this._maxLevel = 25; // 最大等级
  112. _this._curLevel = 0; // 当前等级
  113. _this._curMaxJingyan = _this._jingyanArr[_this.curLevel];
  114. _this._curJingyan = 0; // 当前经验
  115. _this.canUpgrade = true;
  116. _this.skillImgArr = [];
  117. _this._canAccelerate = true;
  118. _this._bishou = null;
  119. _this.hudun = null;
  120. _this._zaishengCdTime = 0;
  121. _this._feilun = null;
  122. _this._posArr = [
  123. [[500, 0]],
  124. [[500, 0], [-500, 0]],
  125. [[500, 0], [-300, 400], [-300, -400]],
  126. [[500, 0], [-500, 0], [0, 500], [0, -500]]
  127. ];
  128. _this._shandianCount = 0;
  129. _this._shandianNum = [1, 1, 3, 5];
  130. _this._shandiCdTime = 0;
  131. _this._fireCount = 0;
  132. _this._fireNum = [1, 1, 2, 3];
  133. _this._fireCdTime = 0;
  134. return _this;
  135. }
  136. Object.defineProperty(UpgradeMgr.prototype, "curLevel", {
  137. get: function () { return this._curLevel; },
  138. set: function (v) {
  139. if (v < 0)
  140. v = 0;
  141. else if (v > this._maxLevel)
  142. v = this._maxLevel;
  143. // 升级
  144. if (v >= this._curLevel) {
  145. this._curLevel = v;
  146. gameMgr_1.gameMgr.model6_levelLabel.string = "" + this._curLevel;
  147. // 升级效果
  148. this.upgradeEffect();
  149. // 弹窗
  150. CocosZ_1.cocosz.pauseCount++;
  151. CocosZ_1.cocosz.uiMgr.openPanel(Constant_1.PanelName.UIUpgradePanel);
  152. this._curJingyan -= this._curMaxJingyan;
  153. this._curMaxJingyan = this._jingyanArr[this.curLevel];
  154. }
  155. },
  156. enumerable: false,
  157. configurable: true
  158. });
  159. Object.defineProperty(UpgradeMgr.prototype, "curJingyan", {
  160. get: function () { return this._curJingyan; },
  161. set: function (v) {
  162. if (v < 0)
  163. v = 0;
  164. this._curJingyan = v;
  165. },
  166. enumerable: false,
  167. configurable: true
  168. });
  169. /** 初始化监听 */
  170. UpgradeMgr.prototype.onLoad = function () {
  171. exports.upgradeMgr = this;
  172. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMessageHandler, this);
  173. // 经验预制体
  174. this.jingyanPre = CocosZ_1.cocosz.resMgr.getRes("jingyan", cc.Prefab);
  175. // 添加经验层
  176. this.jingyanLayer = new cc.Node();
  177. this.jingyanLayer.name = "jingyanLayer";
  178. this.jingyanLayer.zIndex = Constant_1.ZindexLayer.zinedx_jingyan;
  179. this.jingyanLayer.setPosition(cc.Vec2.ZERO);
  180. this.jingyanLayer.setParent(this.node);
  181. };
  182. UpgradeMgr.prototype.start = function () { };
  183. UpgradeMgr.prototype.onDestroy = function () {
  184. exports.upgradeMgr = null;
  185. cc.game.targetOff(this);
  186. };
  187. UpgradeMgr.prototype.update = function (dt) {
  188. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.model6_jingyanBar) {
  189. var from = gameMgr_1.gameMgr.model6_jingyanBar.progress;
  190. var to = this.curJingyan / this._curMaxJingyan;
  191. if (to == 0) {
  192. to = 0.001;
  193. }
  194. gameMgr_1.gameMgr.model6_jingyanBar.progress = cc.misc.lerp(from, to, 0.2);
  195. }
  196. // 经验值满足,且可以升级
  197. if (this.canUpgrade && !CocosZ_1.cocosz.isPause && this.curLevel < this._maxLevel && this._curJingyan >= this._curMaxJingyan) {
  198. this.curLevel += 1;
  199. }
  200. };
  201. /** 是否拥有技能 */
  202. UpgradeMgr.prototype.isHaveSkill = function (id) {
  203. return this.upgradeSkillArr[id] > 0 ? true : false;
  204. };
  205. /** 设置技能UI */
  206. UpgradeMgr.prototype.setSkillImg = function (id) {
  207. var str = "zombieSkill_icon_" + id + (this.upgradeSkillMaxLevelArr[id] > 1 ? ("_" + this.upgradeSkillArr[id]) : "");
  208. var icon = CocosZ_1.cocosz.resMgr.getRes(str, cc.SpriteFrame);
  209. if (icon && gameMgr_1.gameMgr.model6_skillScrollView_content && gameMgr_1.gameMgr.model6_skillScrollView_content.isValid) {
  210. if (!this.skillImgArr[id] && gameMgr_1.gameMgr.model6_skillScrollView_item) {
  211. this.skillImgArr[id] = cc.instantiate(gameMgr_1.gameMgr.model6_skillScrollView_item);
  212. this.skillImgArr[id].active = true;
  213. this.skillImgArr[id].setParent(gameMgr_1.gameMgr.model6_skillScrollView_content);
  214. // 滑动到最右边
  215. if (gameMgr_1.gameMgr.model6_skillScrollView_content.width > gameMgr_1.gameMgr.model6_skillScrollView.node.width) {
  216. gameMgr_1.gameMgr.model6_skillScrollView.scrollToRight();
  217. }
  218. }
  219. if (this.skillImgArr[id]) {
  220. var sprite = this.skillImgArr[id].getComponent(cc.Sprite);
  221. if (sprite)
  222. sprite.spriteFrame = icon;
  223. }
  224. }
  225. };
  226. /** 设置技能cd */
  227. UpgradeMgr.prototype.setSkillCD = function (id, time) {
  228. if (this.skillImgArr[id]) {
  229. var skillCD_1 = this.skillImgArr[id].getChildByName("skillCD");
  230. if (skillCD_1) {
  231. skillCD_1.active = true;
  232. skillCD_1.opacity = 255;
  233. cc.tween(skillCD_1.children[0].getComponent(cc.Sprite))
  234. .set({ fillRange: 1 })
  235. .to(time, { fillRange: 0 })
  236. .call(function () { skillCD_1.opacity = 0; })
  237. .start();
  238. var num_1 = time;
  239. var timeLabel_1 = skillCD_1.children[1].getComponent(cc.Label);
  240. cc.tween(skillCD_1)
  241. .call(function () { timeLabel_1.string = num_1.toString(); num_1--; })
  242. .delay(1)
  243. .union()
  244. .repeat(time)
  245. .start();
  246. }
  247. }
  248. };
  249. /** 获得技能 */
  250. UpgradeMgr.prototype.getSkill = function (id) {
  251. var _this = this;
  252. this.upgradeSkillArr[id]++;
  253. this.setSkillImg(id);
  254. switch (id) {
  255. case SkillType.整装待发: {
  256. if (gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.curWeapon) {
  257. gameMgr_1.gameMgr.playerTs.curWeapon.bulletNum += 4;
  258. }
  259. break;
  260. }
  261. case SkillType.瞄准: {
  262. if (gameMgr_1.gameMgr.playerTs) {
  263. gameMgr_1.gameMgr.playerTs.atkRate *= 1.25;
  264. }
  265. break;
  266. }
  267. case SkillType.强化: {
  268. if (gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.curWeapon) {
  269. gameMgr_1.gameMgr.playerTs.curWeapon.bulletNum += 2;
  270. gameMgr_1.gameMgr.playerTs.atkRate *= 1.1;
  271. }
  272. break;
  273. }
  274. case SkillType.瞬斩: {
  275. break;
  276. }
  277. case SkillType.强力射击: {
  278. if (gameMgr_1.gameMgr.playerTs) {
  279. gameMgr_1.gameMgr.playerTs.atkRate *= 1.2;
  280. }
  281. break;
  282. }
  283. case SkillType.窃魂弹夹: {
  284. break;
  285. }
  286. case SkillType.科技子弹: {
  287. if (gameMgr_1.gameMgr.playerTs) {
  288. gameMgr_1.gameMgr.playerTs.atkSpeedRate -= 0.1;
  289. }
  290. break;
  291. }
  292. case SkillType.站姿射击: {
  293. var can_1 = true;
  294. this.schedule(function () {
  295. if (can_1 && gameMgr_1.gameMgr.playerTs.moveDir.mag() == 0) {
  296. can_1 = false;
  297. gameMgr_1.gameMgr.playerTs.atkRate *= 1.3;
  298. }
  299. else if (!can_1 && gameMgr_1.gameMgr.playerTs.moveDir.mag() > 0) {
  300. can_1 = true;
  301. gameMgr_1.gameMgr.playerTs.atkRate /= 1.3;
  302. }
  303. }, 0.1);
  304. break;
  305. }
  306. case SkillType.子弹碎片: {
  307. break;
  308. }
  309. case SkillType.双发: {
  310. if (gameMgr_1.gameMgr.playerTs) {
  311. gameMgr_1.gameMgr.playerTs.atkBulletNum += 1;
  312. }
  313. break;
  314. }
  315. case SkillType.谢幕: {
  316. break;
  317. }
  318. case SkillType.枪林弹雨: {
  319. if (gameMgr_1.gameMgr.playerTs) {
  320. gameMgr_1.gameMgr.playerTs.atkBulletNum *= 2;
  321. }
  322. break;
  323. }
  324. case SkillType.疾走: {
  325. if (gameMgr_1.gameMgr.playerTs) {
  326. gameMgr_1.gameMgr.playerTs.speedRate *= 1.1;
  327. }
  328. break;
  329. }
  330. case SkillType.跑动射击: {
  331. var can_2 = true;
  332. this.schedule(function () {
  333. if (can_2 && gameMgr_1.gameMgr.playerTs.isAtk) {
  334. can_2 = false;
  335. gameMgr_1.gameMgr.playerTs.speedRate *= 1.2;
  336. }
  337. else if (!can_2 && !gameMgr_1.gameMgr.playerTs.isAtk) {
  338. can_2 = true;
  339. gameMgr_1.gameMgr.playerTs.speedRate /= 1.2;
  340. }
  341. }, 0.1);
  342. break;
  343. }
  344. case SkillType.意气风发: {
  345. // 每10秒增加10%的伤害和移动速度
  346. this.schedule(function () {
  347. if (gameMgr_1.gameMgr.playerTs) {
  348. var k = _this.skill_14 + 0.1;
  349. if (k > 1.4)
  350. k = 1.4;
  351. else if (k < 1)
  352. k = 1;
  353. gameMgr_1.gameMgr.playerTs.atkRate *= (k / _this.skill_14);
  354. gameMgr_1.gameMgr.playerTs.speedRate *= (k / _this.skill_14);
  355. _this.skill_14 = k;
  356. }
  357. }, 10);
  358. break;
  359. }
  360. case SkillType.护甲靴子: {
  361. break;
  362. }
  363. case SkillType.磁场: {
  364. this.jingyanRange += 200;
  365. break;
  366. }
  367. case SkillType.灵能补给: {
  368. this.jingyanRange += 50;
  369. break;
  370. }
  371. case SkillType.容光焕发: {
  372. this.jingyanRange += 50;
  373. break;
  374. }
  375. case SkillType.鹰眼: {
  376. this.jingyanRange += 50;
  377. cc.tween(gameMgr_1.gameMgr.mainCamera).to(1, { zoomRatio: 0.6 }).start();
  378. break;
  379. }
  380. case SkillType.生命力: {
  381. if (gameMgr_1.gameMgr.playerTs) {
  382. gameMgr_1.gameMgr.playerTs.totleHp += 1;
  383. gameMgr_1.gameMgr.playerTs.HP = gameMgr_1.gameMgr.playerTs.totleHp;
  384. this.scheduleOnce(function () { gameMgr_1.gameMgr.playerTs.recoverEffect(); }, 1);
  385. }
  386. break;
  387. }
  388. case SkillType.再生: {
  389. this.schedule(function () { _this._updateZaisheng(); }, 1);
  390. break;
  391. }
  392. case SkillType.进化: {
  393. if (gameMgr_1.gameMgr.playerTs) {
  394. gameMgr_1.gameMgr.playerTs.atkRate *= 1.1;
  395. gameMgr_1.gameMgr.playerTs.totleHp += 1;
  396. gameMgr_1.gameMgr.playerTs.HP += 1;
  397. this.scheduleOnce(function () { gameMgr_1.gameMgr.playerTs.recoverEffect(); }, 1);
  398. }
  399. break;
  400. }
  401. case SkillType.萃取: {
  402. break;
  403. }
  404. case SkillType.火焰精通: {
  405. break;
  406. }
  407. case SkillType.冰霜精通: {
  408. break;
  409. }
  410. case SkillType.双重附魔: {
  411. break;
  412. }
  413. case SkillType.通灵匕首: {
  414. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_bishou", cc.Prefab);
  415. if (pre && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs) {
  416. this._bishou = cc.instantiate(pre);
  417. this._bishou.setParent(this.node);
  418. this._bishou.zIndex = cc.macro.MAX_ZINDEX;
  419. this._bishou.active = false;
  420. this.updateBishou();
  421. }
  422. break;
  423. }
  424. case SkillType.神圣守护: {
  425. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_hudun", cc.Prefab);
  426. if (pre && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs) {
  427. this.hudun = cc.instantiate(pre);
  428. this.hudun.setParent(gameMgr_1.gameMgr.playerTs.node);
  429. this.hudun.setPosition(0, 0);
  430. this.hudun.zIndex = cc.macro.MAX_ZINDEX - 1;
  431. break;
  432. }
  433. }
  434. case SkillType.飞轮: {
  435. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_feilun", cc.Prefab);
  436. if (pre) {
  437. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs) {
  438. this._feilun && this._feilun.isValid && this._feilun.destroy();
  439. this._feilun = cc.instantiate(pre);
  440. this._feilun.setParent(gameMgr_1.gameMgr.playerTs.node);
  441. this._feilun.setPosition(cc.Vec2.ZERO);
  442. this._feilun.active = true;
  443. this._feilun.zIndex = cc.macro.MAX_ZINDEX;
  444. this.updateFeilun(this.upgradeSkillArr[SkillType.飞轮]);
  445. }
  446. }
  447. break;
  448. }
  449. case SkillType.闪电: {
  450. if (this.upgradeSkillArr[SkillType.闪电] == 1) {
  451. this.schedule(this.updateShandian, 1);
  452. }
  453. break;
  454. }
  455. case SkillType.燃烧瓶: {
  456. if (this.upgradeSkillArr[SkillType.燃烧瓶] == 1) {
  457. this.schedule(this.updateFire, 1);
  458. }
  459. break;
  460. }
  461. }
  462. };
  463. /** 消息 */
  464. UpgradeMgr.prototype._onGameMessageHandler = function (event) {
  465. var _this = this;
  466. switch (event.type) {
  467. case Constant_1.default.E_Jingyan_Finish: {
  468. if (this.isHaveSkill(SkillType.灵能补给)) {
  469. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && Math.random() < 0.01) {
  470. gameMgr_1.gameMgr.playerTs.curWeapon.curBullet += 1;
  471. }
  472. }
  473. else if (this.isHaveSkill(SkillType.容光焕发)) {
  474. if (this.skill_18 < 3) {
  475. if (this.skill_18 == 0) {
  476. this.accelerate();
  477. }
  478. this.skill_18++;
  479. }
  480. }
  481. break;
  482. }
  483. case Constant_1.default.E_Zombie_Hart: {
  484. if (event.node && event.node.isValid) {
  485. if (this.isHaveSkill(SkillType.瞬斩) && this.canAddMagic(event.node, SkillType.瞬斩)) {
  486. this.skill_effect_3(event.node);
  487. }
  488. else {
  489. var skillArr = [];
  490. if (this.isHaveSkill(SkillType.火焰精通) && this.canAddMagic(event.node, SkillType.火焰精通)) {
  491. skillArr.push(SkillType.火焰精通);
  492. }
  493. /* if (this.isHaveSkill(SkillType.雷电精通) && this.canAddMagic(event.node, SkillType.雷电精通)) {
  494. skillArr.push(SkillType.雷电精通);
  495. } */
  496. if (this.isHaveSkill(SkillType.冰霜精通) && this.canAddMagic(event.node, SkillType.冰霜精通)) {
  497. skillArr.push(SkillType.冰霜精通);
  498. }
  499. // 随机技能
  500. if (skillArr.length) {
  501. var skillIndex = Math.floor(Math.random() * skillArr.length);
  502. var skillId = skillArr[skillIndex];
  503. switch (skillId) {
  504. case SkillType.火焰精通: {
  505. this.skill_effect_24(event.node);
  506. break;
  507. }
  508. /* case SkillType.雷电精通: {
  509. this.skill_effect_25(event.node);
  510. break;
  511. } */
  512. case SkillType.冰霜精通: {
  513. this.skill_effect_26(event.node);
  514. break;
  515. }
  516. }
  517. }
  518. }
  519. }
  520. break;
  521. }
  522. case Constant_1.default.E_Zombie_Death: {
  523. if (event.node) {
  524. if (this.isHaveSkill(SkillType.子弹碎片) && event.from) {
  525. var angle = 30 * Math.random();
  526. this.createBullet(event.node, 30 + angle, 40);
  527. this.createBullet(event.node, 150 + angle, 40);
  528. this.createBullet(event.node, 270 + angle, 40);
  529. }
  530. else if (this.isHaveSkill(SkillType.萃取)) {
  531. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.HP < gameMgr_1.gameMgr.playerTs.totleHp && Math.random() < 0.05) {
  532. gameMgr_1.gameMgr.playerTs.HP += 1;
  533. gameMgr_1.gameMgr.playerTs.recoverEffect();
  534. }
  535. }
  536. // 统计击杀
  537. var ts = event.node.getComponent(ZombieBase_1.default);
  538. if (ts) {
  539. this.zombieKillNum++;
  540. if (ts.isBoss) {
  541. this.bossKillId.push(ts.zombieId);
  542. if (gameMgr_1.gameMgr.bossArr.length == 0) {
  543. gameMgr_1.gameMgr.win();
  544. }
  545. }
  546. }
  547. }
  548. break;
  549. }
  550. case Constant_1.default.E_Bullet_Last: {
  551. if (this.isHaveSkill(SkillType.谢幕)) {
  552. if (gameMgr_1.gameMgr.playerTs) {
  553. this.createBullet(event.node, 36 * 1, 40);
  554. this.createBullet(event.node, 36 * 3, 40);
  555. this.createBullet(event.node, 36 * 5, 40);
  556. this.createBullet(event.node, 36 * 7, 40);
  557. this.createBullet(event.node, 36 * 9, 40);
  558. this.scheduleOnce(function () {
  559. _this.createBullet(event.node, 36 * 2, 40);
  560. _this.createBullet(event.node, 36 * 4, 40);
  561. _this.createBullet(event.node, 36 * 6, 40);
  562. _this.createBullet(event.node, 36 * 8, 40);
  563. _this.createBullet(event.node, 36 * 10, 40);
  564. }, 0);
  565. }
  566. }
  567. break;
  568. }
  569. case Constant_1.default.E_Bullet_Reload: {
  570. if (this.isHaveSkill(SkillType.窃魂弹夹)) {
  571. if (gameMgr_1.gameMgr.playerTs) {
  572. gameMgr_1.gameMgr.playerTs.atkRate *= 1.3;
  573. this.scheduleOnce(function () {
  574. gameMgr_1.gameMgr.playerTs.atkRate /= 1.3;
  575. }, 1);
  576. }
  577. }
  578. break;
  579. }
  580. case Constant_1.default.E_Player_Hart: {
  581. if (this.isHaveSkill(SkillType.意气风发)) {
  582. this.skill_14 = 1;
  583. }
  584. break;
  585. }
  586. case Constant_1.default.E_Player_Death: {
  587. if (this.hudun) {
  588. this.hudun.opacity = 0;
  589. }
  590. break;
  591. }
  592. }
  593. };
  594. /** 经验 */
  595. UpgradeMgr.prototype.createJingyan = function (pos) {
  596. if (this.jingyanPre && this.jingyanLayer) {
  597. var jingyan = gameMgr_1.gameMgr.nodeGet("jingyan", this.jingyanPre);
  598. var ts = jingyan.getComponent(jingyan_1.default);
  599. if (ts) {
  600. ts.init();
  601. }
  602. jingyan.setPosition(pos);
  603. jingyan.setParent(this.jingyanLayer);
  604. }
  605. };
  606. /** 升级效果 */
  607. UpgradeMgr.prototype.upgradeEffect = function () {
  608. if (gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.isValid) {
  609. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_sjgx", cc.Prefab);
  610. if (pre) {
  611. var node = cc.instantiate(pre);
  612. node.setPosition(cc.Vec2.ZERO);
  613. node.setParent(gameMgr_1.gameMgr.playerTs.node);
  614. // node.zIndex = -1;
  615. // 升级音效
  616. gameMgr_1.gameMgr.playEffect("LevelUp");
  617. }
  618. }
  619. };
  620. /** 子弹 */
  621. UpgradeMgr.prototype.createBullet = function (node, angle, atkNum) {
  622. if (this.bulletPrefab) {
  623. var dir = cc.v2(1, 0).rotateSelf(cc.misc.degreesToRadians(angle));
  624. var bullet_2 = cc.instantiate(this.bulletPrefab);
  625. bullet_2.parent = this.node;
  626. bullet_2.setPosition(node.getPosition());
  627. bullet_2.angle = angle;
  628. var pos1 = bullet_2.getPosition();
  629. var pos2 = pos1.add(dir.mul(1000));
  630. cc.tween(bullet_2)
  631. .to(pos2.sub(pos1).mag() / 2500, { position: cc.v3(pos2) })
  632. .call(function () {
  633. var ts = bullet_2.getComponent(bullet_1.default);
  634. if (ts.boomEffect) {
  635. var boom = cc.instantiate(ts.boomEffect);
  636. boom.parent = ts.node.parent;
  637. boom.setPosition(ts.node.getPosition());
  638. boom.zIndex = Constant_1.ZindexLayer.zindex_bomb;
  639. var curBullet = boom.getComponent(bullet_1.default);
  640. curBullet.atk = ts.atk;
  641. curBullet.atker = ts.atker;
  642. curBullet.id = ts.id;
  643. gameMgr_1.gameMgr.playEffect("explo", boom);
  644. if (ts.hitEffect) {
  645. var pos = bullet_2.getPosition();
  646. var node_1 = cc.instantiate(ts.hitEffect);
  647. node_1.parent = bullet_2.parent;
  648. node_1.setPosition(pos);
  649. node_1.zIndex = Constant_1.ZindexLayer.zindex_effect_hit;
  650. }
  651. }
  652. bullet_2.destroy();
  653. })
  654. .start();
  655. var ts = bullet_2.getComponent(bullet_1.default);
  656. ts.id = 1;
  657. ts.atker = null;
  658. ts.atk = atkNum;
  659. ts.dir = dir;
  660. }
  661. };
  662. /** 获得经验加速1秒(可累计) */
  663. UpgradeMgr.prototype.accelerate = function () {
  664. var _this = this;
  665. if (this.skill_18 == 0) {
  666. if (this._canAccelerate) {
  667. this._canAccelerate = false;
  668. // 开始加速
  669. if (gameMgr_1.gameMgr.playerTs)
  670. gameMgr_1.gameMgr.playerTs.speedRate *= 1.5;
  671. }
  672. else {
  673. this._canAccelerate = true;
  674. // 结束加速
  675. if (gameMgr_1.gameMgr.playerTs)
  676. gameMgr_1.gameMgr.playerTs.speedRate /= 1.5;
  677. return;
  678. }
  679. }
  680. this.scheduleOnce(function () {
  681. _this.skill_18--;
  682. _this.accelerate();
  683. }, 1);
  684. };
  685. /** 魔法伤害倍率 */
  686. UpgradeMgr.prototype.magic_hart_rate = function () {
  687. if (this.isHaveSkill(SkillType.双重附魔) && this.skill_magic > 1) {
  688. return 1.5;
  689. }
  690. else {
  691. return 1;
  692. }
  693. };
  694. /** 能否添加魔法(审判,火焰,雷电,冰冻) */
  695. UpgradeMgr.prototype.canAddMagic = function (enemy, id) {
  696. if (enemy && enemy.isValid) {
  697. var zombieTs = enemy.getComponent(ZombieBase_1.default);
  698. if (zombieTs) {
  699. // 血量小于0
  700. if (zombieTs.HP <= 0) {
  701. return false;
  702. }
  703. // 已存在瞬斩
  704. for (var i = 0; i < enemy.childrenCount; i++) {
  705. if (enemy.children[i].name == "zombieSkill_" + SkillType.瞬斩) {
  706. return false;
  707. }
  708. }
  709. if (id >= 0) {
  710. if (id == SkillType.瞬斩) {
  711. // 是否达到试用条件
  712. if (zombieTs.isBoss || (zombieTs.totleHp > 0 && zombieTs.HP / zombieTs.totleHp > 0.4)) {
  713. return false;
  714. }
  715. }
  716. else {
  717. // 已存在火焰和冰霜
  718. for (var i = 0; i < enemy.childrenCount; i++) {
  719. if (enemy.children[i].name.includes("zombieSkill"))
  720. return false;
  721. }
  722. if (zombieTs.isBoss) {
  723. if (id == SkillType.火焰精通) {
  724. return Math.random() < 0.2 ? true : false;
  725. }
  726. else if (id == SkillType.冰霜精通) {
  727. return Math.random() < 0.2 ? true : false;
  728. }
  729. }
  730. }
  731. }
  732. else {
  733. return false;
  734. }
  735. }
  736. else {
  737. return false;
  738. }
  739. }
  740. else {
  741. return false;
  742. }
  743. return true;
  744. };
  745. /** 瞬斩 */
  746. UpgradeMgr.prototype.skill_effect_3 = function (enemy) {
  747. if (enemy && enemy.isValid) {
  748. var zombieTs_1 = enemy.getComponent(ZombieBase_1.default);
  749. if (zombieTs_1) {
  750. // 技能效果
  751. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_3", cc.Prefab);
  752. if (pre) {
  753. var node_2 = cc.instantiate(pre);
  754. node_2.setPosition(0, 0);
  755. node_2.setParent(enemy);
  756. // 销毁
  757. zombieTs_1.moveDir = cc.Vec2.ZERO;
  758. zombieTs_1.canMoveDir = false;
  759. zombieTs_1.updateMove();
  760. cc.tween(zombieTs_1)
  761. .delay(0.5)
  762. .call(function () {
  763. if (zombieTs_1 && zombieTs_1.isValid) {
  764. zombieTs_1.hart(zombieTs_1.HP, null, null, false, false, cc.Color.RED);
  765. }
  766. })
  767. .delay(0.5)
  768. .call(function () {
  769. if (node_2 && node_2.isValid) {
  770. node_2.destroy();
  771. }
  772. })
  773. .start();
  774. }
  775. }
  776. }
  777. };
  778. /** 火焰精通 */
  779. UpgradeMgr.prototype.skill_effect_24 = function (enemy) {
  780. var _this = this;
  781. if (enemy && enemy.isValid) {
  782. var zombieTs_2 = enemy.getComponent(ZombieBase_1.default);
  783. if (zombieTs_2) {
  784. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_24", cc.Prefab);
  785. if (pre) {
  786. // 添加火焰动画
  787. var node_3 = cc.instantiate(pre);
  788. node_3.setPosition(0, 0 /* -enemy.height / 2 * enemy.scaleY */);
  789. node_3.setParent(enemy);
  790. node_3.zIndex = cc.macro.MAX_ZINDEX;
  791. zombieTs_2.fire_start();
  792. // 伤害
  793. cc.tween(node_3)
  794. .delay(0.2)
  795. .call(function () {
  796. if (zombieTs_2.isValid && zombieTs_2.HP > 0) {
  797. zombieTs_2.hart(5 * _this.magic_hart_rate(), null, null, false, false, cc.Color.RED);
  798. }
  799. else {
  800. node_3.destroy();
  801. }
  802. })
  803. .union()
  804. .repeat(20)
  805. .call(function () {
  806. zombieTs_2.fire_end();
  807. node_3.destroy();
  808. })
  809. .start();
  810. gameMgr_1.gameMgr.playEffect("ranshao", enemy, 1);
  811. }
  812. }
  813. }
  814. };
  815. /** 冰霜精通 */
  816. UpgradeMgr.prototype.skill_effect_26 = function (enemy) {
  817. if (enemy && enemy.isValid) {
  818. var zombieTs_3 = enemy.getComponent(ZombieBase_1.default);
  819. if (zombieTs_3 /* && !zombieTs.isBoss() */) {
  820. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_26", cc.Prefab);
  821. if (pre) {
  822. var node_frozen_1 = cc.instantiate(pre);
  823. node_frozen_1.setPosition(0, 0);
  824. node_frozen_1.setParent(enemy);
  825. node_frozen_1.zIndex = cc.macro.MAX_ZINDEX;
  826. if (zombieTs_3.zombieId >= 8) {
  827. node_frozen_1.scale = 4;
  828. }
  829. else {
  830. node_frozen_1.scale = 2;
  831. }
  832. // 冰冻
  833. if (zombieTs_3.isValid) {
  834. zombieTs_3.frozenStart();
  835. var t = zombieTs_3.isBoss ? 0.5 : 2;
  836. this.scheduleOnce(function () {
  837. if (zombieTs_3 && zombieTs_3.isValid) {
  838. zombieTs_3.frozenEnd();
  839. }
  840. // 销毁
  841. if (node_frozen_1 && node_frozen_1.isValid) {
  842. node_frozen_1.destroy();
  843. }
  844. }, t);
  845. }
  846. // 音效
  847. gameMgr_1.gameMgr.playEffect("bingdong", enemy, 1);
  848. }
  849. }
  850. }
  851. };
  852. /** 通灵匕首 */
  853. UpgradeMgr.prototype.updateBishou = function () {
  854. var _this = this;
  855. if (this._bishou && this._bishou.isValid && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs) {
  856. if (gameMgr_1.gameMgr.playerTs.atkTarget && gameMgr_1.gameMgr.playerTs.atkTarget.isValid) {
  857. // 匕首属性
  858. var bulletTs = this._bishou.getComponent(bullet_1.default);
  859. bulletTs.isHartMusic = false;
  860. bulletTs.hitAudio = "hurt";
  861. bulletTs.atk = 50 * gameMgr_1.gameMgr.playerTs.atkRate;
  862. bulletTs.atkedArr = [];
  863. // 当前
  864. var from = gameMgr_1.gameMgr.playerTs.node.getPosition();
  865. // 目标
  866. var div = gameMgr_1.gameMgr.playerTs.atkTarget.getPosition().subSelf(from);
  867. var dis = div.mag();
  868. if (dis < 400) {
  869. div.normalizeSelf().mulSelf(400);
  870. }
  871. var p2 = from.add(cc.v2(1, 0).mulSelf(400).rotateSelf(this._bishou.angle / 180 * Math.PI));
  872. var to = from.add(div);
  873. var t = div.mag() / 800;
  874. if (false == this._bishou.active) {
  875. this._bishou.active = true;
  876. this._bishou.setPosition(from);
  877. }
  878. cc.tween(this._bishou)
  879. .bezierTo(t, from, p2, to)
  880. .call(function () { _this.updateBishou(); })
  881. .start();
  882. }
  883. else {
  884. this._bishou.active = false;
  885. this.scheduleOnce(function () { _this.updateBishou(); }, 1);
  886. }
  887. }
  888. };
  889. /** 神圣护盾 */
  890. UpgradeMgr.prototype.updateHudun = function () {
  891. var _this = this;
  892. if (this.hudun && this.hudun.active) {
  893. this.hudun.active = false;
  894. // 破裂音效
  895. gameMgr_1.gameMgr.playEffect("ShieldDestroy");
  896. // cd
  897. this.setSkillCD(SkillType.神圣守护, 60);
  898. this.scheduleOnce(function () {
  899. if (gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.isValid) {
  900. _this.hudun.active = true;
  901. if (gameMgr_1.gameMgr.playerTs.HP) {
  902. _this.hudun.opacity = 255;
  903. }
  904. else {
  905. _this.hudun.opacity = 0;
  906. }
  907. }
  908. }, 60);
  909. }
  910. };
  911. /** 再生 */
  912. UpgradeMgr.prototype._updateZaisheng = function () {
  913. if (this._zaishengCdTime > 0) {
  914. this._zaishengCdTime--;
  915. return;
  916. }
  917. if (CocosZ_1.cocosz.isPause)
  918. return;
  919. if (gameMgr_1.gameMgr.playerTs && !gameMgr_1.gameMgr.playerTs.isDeath && gameMgr_1.gameMgr.playerTs.HP < gameMgr_1.gameMgr.playerTs.totleHp) {
  920. gameMgr_1.gameMgr.playerTs.HP += 1;
  921. gameMgr_1.gameMgr.playerTs.recoverEffect();
  922. this._zaishengCdTime = 90;
  923. this.setSkillCD(SkillType.再生, this._zaishengCdTime);
  924. }
  925. };
  926. /** 飞轮 */
  927. UpgradeMgr.prototype.updateFeilun = function (level) {
  928. // 根据等级设置飞轮数量
  929. if (this._feilun && this._feilun.isValid && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs) {
  930. cc.tween(this._feilun).by(10, { angle: -360 * 5 }).repeatForever().start();
  931. // 飞轮
  932. var level2NumArr = [1, 2, 3, 4];
  933. var num = level2NumArr[level];
  934. var _loop_1 = function (i) {
  935. var icon = this_1._feilun.children[i];
  936. if (icon) {
  937. if (i < num) {
  938. icon.active = true;
  939. if (level == 3) {
  940. var sprFrame = this_1._feilun.getChildByName("back").getComponent(cc.Sprite).spriteFrame;
  941. icon.getComponent(cc.Sprite).spriteFrame = sprFrame;
  942. }
  943. icon.setPosition(this_1._posArr[level][i][0], this_1._posArr[level][i][1]);
  944. cc.tween(icon)
  945. .call(function () {
  946. gameMgr_1.gameMgr.playEffect("chilunStart");
  947. icon.getComponent(cc.Collider).enabled = true;
  948. })
  949. .to(1, { scale: 2.5 })
  950. .delay(8)
  951. .to(1, { scale: 0 })
  952. .call(function () { icon.getComponent(cc.Collider).enabled = false; })
  953. .delay(2)
  954. .union()
  955. .repeatForever()
  956. .start();
  957. var bulletTs = icon.getComponent(bullet_1.default);
  958. if (bulletTs) {
  959. bulletTs.isHartMusic = false;
  960. bulletTs.hitAudio = "chilun";
  961. bulletTs.atk = 80 + 20 * level * gameMgr_1.gameMgr.playerTs.atkRate;
  962. }
  963. }
  964. else {
  965. icon.active = false;
  966. }
  967. }
  968. };
  969. var this_1 = this;
  970. for (var i = 0; i < 4; i++) {
  971. _loop_1(i);
  972. }
  973. }
  974. };
  975. /** 闪电 */
  976. UpgradeMgr.prototype.updateShandian = function () {
  977. if (this._shandiCdTime > 0) {
  978. this._shandiCdTime--;
  979. return;
  980. }
  981. if (CocosZ_1.cocosz.isPause)
  982. return;
  983. var level = this.upgradeSkillArr[SkillType.闪电];
  984. if (this._shandianCount == 0) {
  985. this._shandianCount = this._shandianNum[level];
  986. }
  987. // 能够添加闪电的敌人
  988. var enemyArr = [];
  989. var _loop_2 = function (i) {
  990. var can = true;
  991. var node = gameMgr_1.gameMgr.playerTs.atkList[i];
  992. node.children.forEach(function (n) {
  993. if (n.name == "zombieSkill_shandian") {
  994. can = false;
  995. }
  996. });
  997. if (can) {
  998. enemyArr.push(node);
  999. }
  1000. };
  1001. for (var i = gameMgr_1.gameMgr.playerTs.atkList.length - 1; i >= 0; i--) {
  1002. _loop_2(i);
  1003. }
  1004. if (enemyArr.length) {
  1005. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_shandian", cc.Prefab);
  1006. if (pre) {
  1007. var enemy = enemyArr.shift();
  1008. if (enemy && enemy.isValid) {
  1009. this._shandianCount--;
  1010. // 添加雷电动画
  1011. var node_4 = cc.instantiate(pre);
  1012. node_4.setPosition(0, -enemy.height / 2 * enemy.scaleY);
  1013. node_4.setParent(enemy);
  1014. node_4.zIndex = cc.macro.MAX_ZINDEX;
  1015. // 动画皮肤
  1016. if (level == 3) {
  1017. var spAni = node_4.getComponent(sp.Skeleton);
  1018. if (spAni) {
  1019. spAni.setSkin("y");
  1020. }
  1021. }
  1022. // 销毁
  1023. this.schedule(function () { if (node_4 && node_4.isValid) {
  1024. node_4.destroy();
  1025. } }, 1);
  1026. // 伤害
  1027. var zombieTs = enemy.getComponent(ZombieBase_1.default);
  1028. if (zombieTs) {
  1029. if (zombieTs.isValid && zombieTs.HP > 0) {
  1030. zombieTs.hart(200 * this.magic_hart_rate(), null, null, false, false, cc.Color.RED);
  1031. }
  1032. }
  1033. // 音效
  1034. gameMgr_1.gameMgr.playEffect("LuoLei", enemy);
  1035. }
  1036. }
  1037. else {
  1038. CocosZ_1.cocosz.resMgr.getRes("prefab_zombie_skill/zombieSkill_shandian", cc.Prefab);
  1039. }
  1040. }
  1041. if (this._shandianCount == 0) {
  1042. this._shandiCdTime = 3 + level;
  1043. this.setSkillCD(SkillType.闪电, this._shandiCdTime);
  1044. }
  1045. };
  1046. /** 燃烧瓶 */
  1047. UpgradeMgr.prototype.updateFire = function () {
  1048. if (this._fireCdTime > 0) {
  1049. this._fireCdTime--;
  1050. return;
  1051. }
  1052. if (CocosZ_1.cocosz.isPause)
  1053. return;
  1054. var level = this.upgradeSkillArr[SkillType.燃烧瓶];
  1055. this._fireCount = this._fireNum[level];
  1056. if (!CocosZ_1.cocosz.isPause && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.atkTarget && gameMgr_1.gameMgr.playerTs.atkTarget.isValid) {
  1057. var pre = CocosZ_1.cocosz.resMgr.getRes("zombieSkill_fire", cc.Prefab);
  1058. if (pre) {
  1059. var div = gameMgr_1.gameMgr.playerTs.atkTarget.getPosition().subSelf(gameMgr_1.gameMgr.playerTs.node.getPosition());
  1060. div.normalizeSelf().mulSelf(400);
  1061. var _loop_3 = function (i) {
  1062. var radian = ((this_2._fireCount - 1) / 2 - i) * (Math.PI / 2);
  1063. var from = gameMgr_1.gameMgr.playerTs.node.getPosition();
  1064. var to = from.add(cc.v2(div).rotateSelf(radian));
  1065. var p2 = cc.v2((from.x + to.x) / 2, from.y + 900);
  1066. var fire = cc.instantiate(pre);
  1067. fire.children[1].active = (level == 3 ? false : true);
  1068. fire.children[2].active = (level == 3 ? true : false);
  1069. fire.setPosition(from);
  1070. fire.setParent(gameMgr_1.gameMgr.map);
  1071. fire.zIndex = cc.macro.MAX_ZINDEX;
  1072. cc.tween(fire)
  1073. .parallel(cc.tween().bezierTo(1, from, p2, to), cc.tween().to(1, { angle: 720 * (div.x > 0 ? 1 : -1) }))
  1074. .call(function () {
  1075. fire.zIndex = Constant_1.ZindexLayer.zinedx_floorSkill;
  1076. fire.children[1].active = fire.children[2].active = false;
  1077. fire.children[0].active = true;
  1078. // 子弹碰撞体
  1079. fire.getComponent(cc.Collider).enabled = true;
  1080. // 子弹属性
  1081. var buttleTs = fire.getComponent(bullet_1.default);
  1082. buttleTs.isHartMusic = false;
  1083. buttleTs.atk = 11;
  1084. buttleTs.hartInterval = 0.2;
  1085. // 燃烧动画
  1086. var spAni = fire.children[0].getComponent(sp.Skeleton);
  1087. spAni.setSkin(level == 3 ? "l" : "h");
  1088. spAni.setAnimation(0, "k", false);
  1089. spAni.setAnimation(0, "ranshao", true);
  1090. // 燃烧瓶破碎音效
  1091. gameMgr_1.gameMgr.playEffect("Ranshaopingposui", fire);
  1092. gameMgr_1.gameMgr.playEffect("ranshao", fire);
  1093. })
  1094. .delay(3)
  1095. .to(0.3, { opacity: 50 })
  1096. .call(function () { fire.destroy(); })
  1097. .start();
  1098. };
  1099. var this_2 = this;
  1100. for (var i = 0; i < this._fireCount; i++) {
  1101. _loop_3(i);
  1102. }
  1103. }
  1104. this._fireCdTime = 4;
  1105. this.setSkillCD(SkillType.燃烧瓶, 4);
  1106. }
  1107. };
  1108. __decorate([
  1109. property(cc.Prefab)
  1110. ], UpgradeMgr.prototype, "bulletPrefab", void 0);
  1111. UpgradeMgr = __decorate([
  1112. ccclass
  1113. ], UpgradeMgr);
  1114. return UpgradeMgr;
  1115. }(cc.Component));
  1116. exports.default = UpgradeMgr;
  1117. cc._RF.pop();