be9dd4bdd4be05e645ab9c0df067aee908e7a7cd.js 15 KB

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