7faea8489e2f0a7c6157dd3918e306f443925d26.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6", "__unresolved_7", "__unresolved_8", "__unresolved_9", "__unresolved_10", "__unresolved_11"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Node, SkeletalAnimation, BaseExp, PoolManager, uiMgr, Constants, userIns, autoBind, GunBase, ResUtil, Game, MsgHints, PlayerCamera, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _crd, ccclass, property, PAnimType, Player;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfBaseExp(extras) {
  8. _reporterNs.report("BaseExp", "../core/base/BaseExp", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfPoolManager(extras) {
  11. _reporterNs.report("PoolManager", "../core/manager/PoolManager", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfuiMgr(extras) {
  14. _reporterNs.report("uiMgr", "../core/manager/UIManager", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfConstants(extras) {
  17. _reporterNs.report("Constants", "../data/Constants", _context.meta, extras);
  18. }
  19. function _reportPossibleCrUseOfuserIns(extras) {
  20. _reporterNs.report("userIns", "../data/UserData", _context.meta, extras);
  21. }
  22. function _reportPossibleCrUseOfautoBind(extras) {
  23. _reporterNs.report("autoBind", "../extend/AutoBind", _context.meta, extras);
  24. }
  25. function _reportPossibleCrUseOfGunBase(extras) {
  26. _reporterNs.report("GunBase", "../items/base/GunBase", _context.meta, extras);
  27. }
  28. function _reportPossibleCrUseOfGunfightShootUI(extras) {
  29. _reporterNs.report("GunfightShootUI", "../ui/GunfightShootUI", _context.meta, extras);
  30. }
  31. function _reportPossibleCrUseOfResUtil(extras) {
  32. _reporterNs.report("ResUtil", "../utils/ResUtil", _context.meta, extras);
  33. }
  34. function _reportPossibleCrUseOfGame(extras) {
  35. _reporterNs.report("Game", "./Game", _context.meta, extras);
  36. }
  37. function _reportPossibleCrUseOfMsgHints(extras) {
  38. _reporterNs.report("MsgHints", "../utils/MsgHints", _context.meta, extras);
  39. }
  40. function _reportPossibleCrUseOfPlayerCamera(extras) {
  41. _reporterNs.report("PlayerCamera", "./PlayerCamera", _context.meta, extras);
  42. }
  43. return {
  44. setters: [function (_unresolved_) {
  45. _reporterNs = _unresolved_;
  46. }, function (_cc) {
  47. _cclegacy = _cc.cclegacy;
  48. __checkObsolete__ = _cc.__checkObsolete__;
  49. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  50. _decorator = _cc._decorator;
  51. Node = _cc.Node;
  52. SkeletalAnimation = _cc.SkeletalAnimation;
  53. }, function (_unresolved_2) {
  54. BaseExp = _unresolved_2.BaseExp;
  55. }, function (_unresolved_3) {
  56. PoolManager = _unresolved_3.PoolManager;
  57. }, function (_unresolved_4) {
  58. uiMgr = _unresolved_4.uiMgr;
  59. }, function (_unresolved_5) {
  60. Constants = _unresolved_5.Constants;
  61. }, function (_unresolved_6) {
  62. userIns = _unresolved_6.userIns;
  63. }, function (_unresolved_7) {
  64. autoBind = _unresolved_7.autoBind;
  65. }, function (_unresolved_8) {
  66. GunBase = _unresolved_8.GunBase;
  67. }, function (_unresolved_9) {
  68. ResUtil = _unresolved_9.ResUtil;
  69. }, function (_unresolved_10) {
  70. Game = _unresolved_10.Game;
  71. }, function (_unresolved_11) {
  72. MsgHints = _unresolved_11.default;
  73. }, function (_unresolved_12) {
  74. PlayerCamera = _unresolved_12.PlayerCamera;
  75. }],
  76. execute: function () {
  77. _crd = true;
  78. _cclegacy._RF.push({}, "2ff50wmAl5EppYKqh0ngPHz", "Player", undefined);
  79. __checkObsolete__(['_decorator', 'Node', 'SkeletalAnimation']);
  80. ({
  81. ccclass,
  82. property
  83. } = _decorator); //玩家动作类型
  84. _export("PAnimType", PAnimType = /*#__PURE__*/function (PAnimType) {
  85. PAnimType["idle"] = "idle";
  86. PAnimType["die"] = "die";
  87. PAnimType["reload"] = "reload";
  88. return PAnimType;
  89. }({}));
  90. _export("Player", Player = (_dec = ccclass('Player'), _dec2 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  91. error: Error()
  92. }), autoBind) : autoBind)({
  93. type: Node,
  94. tooltip: "创建枪的位置"
  95. }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  96. error: Error()
  97. }), autoBind) : autoBind)({
  98. type: Node,
  99. tooltip: "玩家头的位置"
  100. }), _dec4 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  101. error: Error()
  102. }), autoBind) : autoBind)({
  103. type: Node,
  104. tooltip: "敌人埋伏点"
  105. }), _dec5 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  106. error: Error()
  107. }), autoBind) : autoBind)({
  108. type: Node,
  109. tooltip: "玩家身子的位置"
  110. }), _dec6 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  111. error: Error()
  112. }), autoBind) : autoBind)({
  113. type: SkeletalAnimation,
  114. tooltip: "玩家人物动画节点"
  115. }), _dec7 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  116. error: Error()
  117. }), autoBind) : autoBind)({
  118. type: _crd && PlayerCamera === void 0 ? (_reportPossibleCrUseOfPlayerCamera({
  119. error: Error()
  120. }), PlayerCamera) : PlayerCamera,
  121. tooltip: "玩家摄像机抖动控制"
  122. }), _dec(_class = (_class2 = class Player extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
  123. error: Error()
  124. }), BaseExp) : BaseExp) {
  125. constructor() {
  126. super(...arguments);
  127. _initializerDefineProperty(this, "gun_pos", _descriptor, this);
  128. _initializerDefineProperty(this, "head", _descriptor2, this);
  129. _initializerDefineProperty(this, "ambush", _descriptor3, this);
  130. _initializerDefineProperty(this, "body", _descriptor4, this);
  131. _initializerDefineProperty(this, "player_skeletal", _descriptor5, this);
  132. _initializerDefineProperty(this, "mainCamera", _descriptor6, this);
  133. /**玩家的位置节点*/
  134. this.playPosNodes = [];
  135. /**玩家当前血量*/
  136. this.curHP = 0;
  137. /**玩家是否死亡*/
  138. this.isDead = false;
  139. /**玩家拥有的枪*/
  140. this.gun = null;
  141. //玩家数据
  142. this.pData = null;
  143. //是否去设置gunfightShootUI的基础信息
  144. this.isCutShoot = false;
  145. //射击ui类
  146. this._shootUI = null;
  147. //是否是换弹夹状态
  148. this.isReloadMagazine = false;
  149. //玩家击杀敌人过后 敌人累加的精准度 玩家每杀3个敌人AI增加1%的精准度
  150. this.addPrecision = 0;
  151. //连续通关 玩家每杀3个敌人AI增加15%的血量 AI增加5%的精准度
  152. this.addhp = 0;
  153. //玩家打敌人爆头的个数
  154. this.headShotNum = 0;
  155. }
  156. //懒获取射击界面
  157. get shootUI() {
  158. if (!this._shootUI) {
  159. this._shootUI = (_crd && uiMgr === void 0 ? (_reportPossibleCrUseOfuiMgr({
  160. error: Error()
  161. }), uiMgr) : uiMgr).getPageComponent((_crd && Constants === void 0 ? (_reportPossibleCrUseOfConstants({
  162. error: Error()
  163. }), Constants) : Constants).popUIs.gunfightShootUI);
  164. }
  165. return this._shootUI;
  166. }
  167. start() {
  168. //隐藏玩家设置的位置坐标节点
  169. (this.playPosNodes = this.node.parent.getChildByName('player_points').children).forEach(e => e.active = false); //隐藏的枪的位置节点
  170. this.gun_pos.children.forEach(e => e.active = false);
  171. this.pData = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  172. error: Error()
  173. }), userIns) : userIns).getCurUseGun(); //创建玩家拥有的枪
  174. this.loadGunName(this.pData.prb_name);
  175. }
  176. /**
  177. * 加载枪
  178. * @param name 枪的名字
  179. * @param isCut 是否是切换枪
  180. */
  181. loadGunName(name, isCut) {
  182. if (isCut === void 0) {
  183. isCut = false;
  184. }
  185. //玩家待机状态
  186. this.player_skeletal.play(PAnimType.idle);
  187. this.pData = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  188. error: Error()
  189. }), userIns) : userIns).getCurUseGun();
  190. this.curHP = this.pData.hp;
  191. if (!isCut && this.gun) return;
  192. if (isCut) {
  193. (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
  194. error: Error()
  195. }), PoolManager) : PoolManager).putNode(this.gun.node);
  196. }
  197. (_crd && ResUtil === void 0 ? (_reportPossibleCrUseOfResUtil({
  198. error: Error()
  199. }), ResUtil) : ResUtil).loadGunRes("player/" + name).then(gunNode => {
  200. if (!gunNode) return;
  201. this.isCutShoot = true;
  202. gunNode.parent = this.node;
  203. this.gun = gunNode.getComponent(_crd && GunBase === void 0 ? (_reportPossibleCrUseOfGunBase({
  204. error: Error()
  205. }), GunBase) : GunBase);
  206. var pos_ui = this.gun_pos.children.find(e => e.name == this.pData.prb_name);
  207. if (!pos_ui) {
  208. (_crd && MsgHints === void 0 ? (_reportPossibleCrUseOfMsgHints({
  209. error: Error()
  210. }), MsgHints) : MsgHints).show("未找到武器没有对应的位置节点");
  211. }
  212. pos_ui = pos_ui || this.gun_pos;
  213. if (pos_ui) {
  214. gunNode.worldPosition = pos_ui.worldPosition.clone();
  215. gunNode.eulerAngles = pos_ui.parent.eulerAngles.clone();
  216. gunNode.scale = pos_ui.scale.clone();
  217. }
  218. this.gun.init(this.pData, this, () => {}, this.reloadMagazine.bind(this));
  219. });
  220. }
  221. /**
  222. * 更换弹匣
  223. */
  224. reloadMagazine(data) {
  225. if (!data || this.isReloadMagazine) return;
  226. this.isReloadMagazine = true;
  227. var time = data.reloadingSpeed * 4 / 1000; //换弹匣动画
  228. this.player_skeletal.play(PAnimType.reload); //获取动画原始时长
  229. var clip = this.player_skeletal.clips.find(c => c.name === PAnimType.reload); //计算需要设置的速度
  230. clip.speed = clip.duration / time;
  231. this.shootUI.reloadMagazineing(time, () => {
  232. this.isReloadMagazine = false;
  233. this.shootUI.gunDataUI();
  234. this.player_skeletal.play(PAnimType.idle);
  235. });
  236. }
  237. /**
  238. * 玩家发射子弹
  239. */
  240. shoot() {
  241. if (!this.gun || this.isReloadMagazine) return;
  242. this.gun.fire();
  243. this.shootUI.crossHairStability();
  244. (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  245. error: Error()
  246. }), Game) : Game).I.player.mainCamera.shake(0.2, 0, 0.1);
  247. }
  248. /**
  249. * 随机切枪
  250. */
  251. randomCutGun() {
  252. var guns = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  253. error: Error()
  254. }), userIns) : userIns).data.guns;
  255. if (guns.length > 1) {
  256. var idx = guns.findIndex(e => e.id == this.pData.id);
  257. var next = (idx + 1) % guns.length;
  258. var cutGun = guns[next];
  259. (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  260. error: Error()
  261. }), userIns) : userIns).changeGun(cutGun.id);
  262. this.loadGunName(cutGun.prb_name, true);
  263. }
  264. }
  265. /**
  266. * 移除枪回收武器
  267. */
  268. removeGun() {
  269. if (!this.gun) return;
  270. this.gun.endFire();
  271. (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
  272. error: Error()
  273. }), PoolManager) : PoolManager).putNode(this.gun.node);
  274. this.gun = null;
  275. }
  276. /**
  277. * 玩家扣掉血
  278. * @param hp 血
  279. * @param eData 敌人数据
  280. */
  281. subHP(hp, eData) {
  282. if ((_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  283. error: Error()
  284. }), Game) : Game).I.isPause || (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  285. error: Error()
  286. }), Game) : Game).I.isGameOver || this.isDead || hp <= 0) {
  287. return;
  288. }
  289. this.curHP -= hp; //这种是伤害超级高直接死亡了 或者血量为小于等于0
  290. if (hp > this.curHP && this.curHP <= 0) {}
  291. this.curHP = this.curHP < 0 ? 0 : this.curHP; //设置血条
  292. var progress = this.curHP / this.pData.hp;
  293. this.shootUI.playerHurtTwinkle(progress); //敌人死亡
  294. if (this.curHP <= 0 && !this.isDead) {
  295. //英雄死亡回收节点 看广告
  296. // Game.I.buildHeros.addAndSubHeros(this,true);
  297. // Game.I.buildHeros.heroDeadPop(this);
  298. this.isDead = true;
  299. (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
  300. error: Error()
  301. }), Game) : Game).I.isGameOver = true;
  302. this.recycle();
  303. this.player_skeletal.play('die');
  304. this.scheduleOnce(() => {
  305. this.player_skeletal.stop();
  306. this.player_skeletal.node.active = false;
  307. }, 2);
  308. }
  309. }
  310. /**
  311. * 根据关卡设置玩家的位置
  312. */
  313. setPlayerPos() {
  314. if (!this.pData) return;
  315. var length = this.playPosNodes.length;
  316. var data = (_crd && userIns === void 0 ? (_reportPossibleCrUseOfuserIns({
  317. error: Error()
  318. }), userIns) : userIns).getCurLevelData();
  319. var safeIndex = Math.min(data.point - 1, length - 1);
  320. var n = this.playPosNodes[safeIndex];
  321. this.node.worldPosition = n.worldPosition.clone();
  322. }
  323. /**
  324. * 回收
  325. */
  326. recycle() {
  327. this.removeGun();
  328. this.isReloadMagazine = false;
  329. this.addPrecision = 0;
  330. this.addhp = 0;
  331. this.headShotNum = 0;
  332. }
  333. /**
  334. * 设置枪的数据
  335. */
  336. update(dt) {
  337. if (this.isCutShoot) {
  338. //设置玩家枪的信息
  339. if (this.shootUI && this.pData) {
  340. this.shootUI.gunDataUI();
  341. this.isCutShoot = false;
  342. }
  343. }
  344. }
  345. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "gun_pos", [_dec2], {
  346. configurable: true,
  347. enumerable: true,
  348. writable: true,
  349. initializer: function initializer() {
  350. return null;
  351. }
  352. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "head", [_dec3], {
  353. configurable: true,
  354. enumerable: true,
  355. writable: true,
  356. initializer: function initializer() {
  357. return null;
  358. }
  359. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "ambush", [_dec4], {
  360. configurable: true,
  361. enumerable: true,
  362. writable: true,
  363. initializer: function initializer() {
  364. return null;
  365. }
  366. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "body", [_dec5], {
  367. configurable: true,
  368. enumerable: true,
  369. writable: true,
  370. initializer: function initializer() {
  371. return null;
  372. }
  373. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "player_skeletal", [_dec6], {
  374. configurable: true,
  375. enumerable: true,
  376. writable: true,
  377. initializer: function initializer() {
  378. return null;
  379. }
  380. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "mainCamera", [_dec7], {
  381. configurable: true,
  382. enumerable: true,
  383. writable: true,
  384. initializer: function initializer() {
  385. return null;
  386. }
  387. })), _class2)) || _class));
  388. _cclegacy._RF.pop();
  389. _crd = false;
  390. }
  391. };
  392. });
  393. //# sourceMappingURL=7faea8489e2f0a7c6157dd3918e306f443925d26.js.map