c44dc8b944d5a8dcb5bd22bb5f8cd03624d749df.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, MeshRenderer, Node, Vec3, BaseExp, autoBind, Utils, AmbushPoint, _dec, _dec2, _dec3, _dec4, _dec5, _class2, _class3, _descriptor, _descriptor2, _descriptor3, _descriptor4, _crd, ccclass, property, GMap;
  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 _reportPossibleCrUseOfautoBind(extras) {
  11. _reporterNs.report("autoBind", "../extend/AutoBind", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfUtils(extras) {
  14. _reporterNs.report("Utils", "../utils/Utils", _context.meta, extras);
  15. }
  16. _export("AmbushPoint", void 0);
  17. return {
  18. setters: [function (_unresolved_) {
  19. _reporterNs = _unresolved_;
  20. }, function (_cc) {
  21. _cclegacy = _cc.cclegacy;
  22. __checkObsolete__ = _cc.__checkObsolete__;
  23. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  24. _decorator = _cc._decorator;
  25. MeshRenderer = _cc.MeshRenderer;
  26. Node = _cc.Node;
  27. Vec3 = _cc.Vec3;
  28. }, function (_unresolved_2) {
  29. BaseExp = _unresolved_2.BaseExp;
  30. }, function (_unresolved_3) {
  31. autoBind = _unresolved_3.autoBind;
  32. }, function (_unresolved_4) {
  33. Utils = _unresolved_4.Utils;
  34. }],
  35. execute: function () {
  36. _crd = true;
  37. _cclegacy._RF.push({}, "5d55d9VPhhHtoESZOqLjFhK", "Map", undefined);
  38. __checkObsolete__(['_decorator', 'MeshRenderer', 'Node', 'Vec3']);
  39. ({
  40. ccclass,
  41. property
  42. } = _decorator); //埋伏点接口类
  43. _export("AmbushPoint", AmbushPoint = class AmbushPoint {
  44. constructor() {
  45. //埋伏点位置节点数组
  46. this.standPosArr = [];
  47. //掩体点位置节点
  48. this.ambushPosArr = [];
  49. //逃跑点位置节点
  50. this.escapePosArr = [];
  51. //是否已经有人在此站位了
  52. this.isVacancy = false;
  53. }
  54. });
  55. _export("GMap", GMap = (_dec = ccclass('GMap'), _dec2 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  56. error: Error()
  57. }), autoBind) : autoBind)({
  58. type: Node,
  59. tooltip: "埋伏点配置节点"
  60. }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  61. error: Error()
  62. }), autoBind) : autoBind)({
  63. type: Node,
  64. tooltip: "敌人出生区域"
  65. }), _dec4 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  66. error: Error()
  67. }), autoBind) : autoBind)({
  68. type: Node,
  69. tooltip: "进门内线,用于敌人是否在门内"
  70. }), _dec5 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  71. error: Error()
  72. }), autoBind) : autoBind)({
  73. type: Node,
  74. tooltip: "进门外线,用于敌人是否在门外"
  75. }), _dec(_class2 = (_class3 = class GMap extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
  76. error: Error()
  77. }), BaseExp) : BaseExp) {
  78. constructor() {
  79. super(...arguments);
  80. _initializerDefineProperty(this, "ambush_points", _descriptor, this);
  81. _initializerDefineProperty(this, "enemy_born_area", _descriptor2, this);
  82. _initializerDefineProperty(this, "miidle_inline", _descriptor3, this);
  83. _initializerDefineProperty(this, "miidle_outline", _descriptor4, this);
  84. //埋伏点配置数组
  85. this.ambushPoints = [];
  86. }
  87. start() {
  88. //区域隐藏
  89. [this.enemy_born_area].concat(this.ambush_points.children).forEach(e => {
  90. e.getComponent(MeshRenderer).enabled = false;
  91. }); //埋伏点类解析
  92. this.parseAmbushPoints();
  93. }
  94. /**
  95. * 解析埋伏点
  96. */
  97. parseAmbushPoints() {
  98. this.ambushPoints = this.ambush_points.children.map(ambushNode => {
  99. var point = new AmbushPoint();
  100. point.isVacancy = false; //从节点结构获取坐标配置
  101. point.standPosArr = ambushNode.children.filter(e => e.name.startsWith('stand_')).map(node => node.position.clone());
  102. point.ambushPosArr = ambushNode.children.filter(e => e.name.startsWith('bunker_')).map(node => node.position.clone());
  103. point.escapePosArr = ambushNode.children.filter(e => e.name.startsWith('escape_')).map(node => node.position.clone());
  104. return point;
  105. });
  106. }
  107. /**
  108. * 根据敌人信息得到敌人行走路径
  109. * @param eData 敌人数据
  110. * @param size 预制体大小
  111. * @returns
  112. */
  113. getPaths(eData) {
  114. var bornPos = this.getRandomBornPosition(); //进入内门时的坐标
  115. var innerPos = this.getRandomPos(eData, this.miidle_inline); //进入外门时的坐标
  116. var outerPos = this.getRandomPos(eData, this.miidle_outline); //行走路径
  117. var paths = [bornPos, innerPos, outerPos]; //最后一个点特殊处理 包含(站位点、埋伏点、逃跑点) 随机一个埋伏点
  118. var ambush = this.getAmbushClas();
  119. eData.ambush = ambush; //随机一个站立点到最后坐标
  120. var endPos = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  121. error: Error()
  122. }), Utils) : Utils).randomArray(ambush.standPosArr)[0];
  123. paths.push(endPos);
  124. return paths;
  125. }
  126. /**
  127. * 得到一个站位点
  128. */
  129. getAmbushClas() {
  130. //获取所有可用的埋伏点(未被占用的)
  131. var availablePoints = this.ambushPoints.filter(p => !p.isVacancy);
  132. if (availablePoints.length > 0) {
  133. //随机返回一个可用埋伏点
  134. return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  135. error: Error()
  136. }), Utils) : Utils).randomArray(availablePoints)[0];
  137. } // 当所有点位都被占用时,随机返回任意一个
  138. if (this.ambushPoints.length > 0) {
  139. return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  140. error: Error()
  141. }), Utils) : Utils).randomArray(this.ambushPoints)[0];
  142. }
  143. return null;
  144. }
  145. /**
  146. * 根据两个坐标点产生一个两个坐标点之前的随机点
  147. */
  148. getRandomPos(eData, target) {
  149. //只有坦克走中间
  150. var isTan = eData.id == 20003;
  151. var pos = target.position.clone();
  152. if (target.children.length >= 2) {
  153. var pos1 = target.children[0].position.clone();
  154. var pos2 = target.children[1].position.clone();
  155. var r = isTan ? 0.5 : Math.random();
  156. var randomX = r * (pos2.x - pos1.x) + pos1.x;
  157. var randomZ = r * (pos2.z - pos1.z) + pos1.z; //这儿为了看起来暂时保留x轴上的距离随机
  158. pos.x = randomX * 0.5; //y轴就是左边的间隔的距离
  159. pos.z = randomZ;
  160. }
  161. return pos;
  162. }
  163. /**
  164. * 获取随机出生点位置
  165. */
  166. getRandomBornPosition() {
  167. if (!this.enemy_born_area) return Vec3.ZERO; //获取3D节点的世界缩放
  168. var worldScale = this.enemy_born_area.getWorldScale(); //使用X和Z轴缩放作为区域尺寸
  169. var areaWidth = worldScale.x;
  170. var areaDepth = worldScale.z; //在XZ平面生成随机坐标(Y轴保持地面高度)
  171. var randomX = (Math.random() - 0.5) * areaWidth;
  172. var randomZ = (Math.random() - 0.5) * areaDepth; //基于节点原点位置生成世界坐标 保持与出生区域相同高度
  173. var basePos = this.enemy_born_area.worldPosition;
  174. return new Vec3(basePos.x + randomX, basePos.y, basePos.z + randomZ);
  175. }
  176. }, (_descriptor = _applyDecoratedDescriptor(_class3.prototype, "ambush_points", [_dec2], {
  177. configurable: true,
  178. enumerable: true,
  179. writable: true,
  180. initializer: function initializer() {
  181. return null;
  182. }
  183. }), _descriptor2 = _applyDecoratedDescriptor(_class3.prototype, "enemy_born_area", [_dec3], {
  184. configurable: true,
  185. enumerable: true,
  186. writable: true,
  187. initializer: function initializer() {
  188. return null;
  189. }
  190. }), _descriptor3 = _applyDecoratedDescriptor(_class3.prototype, "miidle_inline", [_dec4], {
  191. configurable: true,
  192. enumerable: true,
  193. writable: true,
  194. initializer: function initializer() {
  195. return null;
  196. }
  197. }), _descriptor4 = _applyDecoratedDescriptor(_class3.prototype, "miidle_outline", [_dec5], {
  198. configurable: true,
  199. enumerable: true,
  200. writable: true,
  201. initializer: function initializer() {
  202. return null;
  203. }
  204. })), _class3)) || _class2));
  205. _cclegacy._RF.pop();
  206. _crd = false;
  207. }
  208. };
  209. });
  210. //# sourceMappingURL=c44dc8b944d5a8dcb5bd22bb5f8cd03624d749df.js.map