776c1bfaf358ee3c47c0bd6c18759dc997cff279.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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, _dec6, _class2, _class3, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _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", "GMap", undefined);
  38. __checkObsolete__(['_decorator', 'MeshRenderer', 'Node', 'UITransform', '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. }), _dec6 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
  76. error: Error()
  77. }), autoBind) : autoBind)({
  78. type: Node,
  79. tooltip: "进去的大门"
  80. }), _dec(_class2 = (_class3 = class GMap extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
  81. error: Error()
  82. }), BaseExp) : BaseExp) {
  83. constructor() {
  84. super(...arguments);
  85. _initializerDefineProperty(this, "ambush_points", _descriptor, this);
  86. _initializerDefineProperty(this, "enemy_born_area", _descriptor2, this);
  87. _initializerDefineProperty(this, "miidle_inline", _descriptor3, this);
  88. _initializerDefineProperty(this, "miidle_outline", _descriptor4, this);
  89. _initializerDefineProperty(this, "doors", _descriptor5, this);
  90. //埋伏点配置数组
  91. this.ambushPoints = [];
  92. //游戏速度
  93. this.game_speed = 1;
  94. }
  95. start() {
  96. /*测试时使用 玩家坐标转换
  97. let n: Node = this.node.getChildByName('player_points');
  98. let pwww:Vec3 = Utils.convertPosition(this.node.getChildByName("player"),n);
  99. console.log("GGGGGGG = " + pwww);*/
  100. //区域隐藏
  101. var nodes = this.ambush_points.children.flatMap(child => child.children);
  102. [this.enemy_born_area].concat(nodes).forEach(e => {
  103. var m = e.getComponent(MeshRenderer);
  104. if (m) {
  105. m.enabled = false;
  106. }
  107. });
  108. }
  109. /**
  110. * 游戏速度
  111. */
  112. multiplySpeed() {
  113. return this.game_speed;
  114. }
  115. /**
  116. * 解析埋伏点
  117. */
  118. parseAmbushPoints() {
  119. this.ambushPoints = this.ambush_points.children.map(ambushNode => {
  120. var point = new AmbushPoint();
  121. point.isVacancy = false; //从节点结构获取坐标配置
  122. point.standPosArr = ambushNode.children.filter(e => e.name.startsWith('stand_')).map(node => node.worldPosition.clone());
  123. point.ambushPosArr = ambushNode.children.filter(e => e.name.startsWith('bunker_')).map(node => node.worldPosition.clone());
  124. point.escapePosArr = ambushNode.children.filter(e => e.name.startsWith('escape_')).map(node => node.worldPosition.clone());
  125. return point;
  126. });
  127. }
  128. /**
  129. * 根据敌人信息得到敌人行走路径
  130. * @param eData 敌人数据
  131. * @param size 预制体大小
  132. * @returns
  133. */
  134. getPaths(eData) {
  135. var bornPos = this.getRandomBornPosition(); //进入外门时的坐标
  136. var outerPos = this.getRandomPos(eData, this.miidle_outline); //进入内门时的坐标
  137. var innerPos = this.getRandomPos(eData, this.miidle_inline); //行走路径
  138. var paths = [bornPos, outerPos, innerPos]; //最后一个点特殊处理 包含(站位点、埋伏点、逃跑点) 随机一个埋伏点
  139. var ambush = this.getAmbushClas();
  140. ambush.isVacancy = true;
  141. eData.ambush = ambush; //随机一个站立点到最后坐标
  142. var endPos = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  143. error: Error()
  144. }), Utils) : Utils).randomArray(ambush.standPosArr)[0];
  145. endPos.x += (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  146. error: Error()
  147. }), Utils) : Utils).getRandomFloat(1, 0.2);
  148. paths.push(endPos); //测试时使用
  149. /*paths.forEach(e => {
  150. console.log("FFFFFF = " + this.node.getComponent(UITransform).convertToNodeSpaceAR(e));
  151. });*/
  152. return paths;
  153. }
  154. /**
  155. * 得到一个站位点
  156. */
  157. getAmbushClas() {
  158. if (!this.ambushPoints || this.ambushPoints.length <= 0) {
  159. //埋伏点类解析
  160. this.parseAmbushPoints();
  161. } //获取所有可用的埋伏点(未被占用的)
  162. var availablePoints = this.ambushPoints.filter(p => !p.isVacancy);
  163. if (availablePoints.length > 0) {
  164. //随机返回一个可用埋伏点
  165. return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  166. error: Error()
  167. }), Utils) : Utils).randomArray(availablePoints)[0];
  168. } // 当所有点位都被占用时,随机返回任意一个
  169. if (this.ambushPoints.length > 0) {
  170. return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  171. error: Error()
  172. }), Utils) : Utils).randomArray(this.ambushPoints)[0];
  173. }
  174. return null;
  175. }
  176. /**
  177. * 根据两个坐标点产生一个两个坐标点之前的随机点
  178. */
  179. getRandomPos(eData, target) {
  180. //只有坦克走中间
  181. var isTan = eData.id == 20003;
  182. if (isTan) {
  183. return target.worldPosition.clone();
  184. }
  185. var basePos = target.children[0].worldPosition.clone();
  186. if (target.children.length >= 2) {
  187. var pos1 = target.children[0].worldPosition.clone();
  188. var pos2 = target.children[1].worldPosition.clone(); //生成0-1的随机比例因子
  189. var ratio = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
  190. error: Error()
  191. }), Utils) : Utils).getRandomFloat(0, 1); //分别在x和z轴进行线性插值 这儿为了看起来暂时保留x轴上的距离随机
  192. basePos.x = pos1.x + (pos2.x - pos1.x) * ratio; //y轴就是左边的间隔的距离
  193. basePos.z = pos1.z + (pos2.z - pos1.z) * ratio;
  194. }
  195. return basePos;
  196. }
  197. /**
  198. * 获取随机出生点位置
  199. */
  200. getRandomBornPosition() {
  201. if (!this.enemy_born_area) return Vec3.ZERO; //获取3D节点的世界缩放
  202. var worldScale = this.enemy_born_area.getWorldScale(); //使用X和Z轴缩放作为区域尺寸
  203. var areaWidth = worldScale.x;
  204. var areaDepth = worldScale.z; //在XZ平面生成随机坐标(Y轴保持地面高度)
  205. var randomX = (Math.random() - 0.5) * areaWidth;
  206. var randomZ = (Math.random() - 0.5) * areaDepth; //基于节点原点位置生成世界坐标 保持与出生区域相同高度
  207. var basePos = this.enemy_born_area.worldPosition;
  208. return new Vec3(basePos.x + randomX, basePos.y, basePos.z + randomZ);
  209. }
  210. /**
  211. * 还原数据
  212. */
  213. resetData() {
  214. this.ambushPoints.forEach(e => {
  215. e.isVacancy = false;
  216. });
  217. }
  218. }, (_descriptor = _applyDecoratedDescriptor(_class3.prototype, "ambush_points", [_dec2], {
  219. configurable: true,
  220. enumerable: true,
  221. writable: true,
  222. initializer: function initializer() {
  223. return null;
  224. }
  225. }), _descriptor2 = _applyDecoratedDescriptor(_class3.prototype, "enemy_born_area", [_dec3], {
  226. configurable: true,
  227. enumerable: true,
  228. writable: true,
  229. initializer: function initializer() {
  230. return null;
  231. }
  232. }), _descriptor3 = _applyDecoratedDescriptor(_class3.prototype, "miidle_inline", [_dec4], {
  233. configurable: true,
  234. enumerable: true,
  235. writable: true,
  236. initializer: function initializer() {
  237. return null;
  238. }
  239. }), _descriptor4 = _applyDecoratedDescriptor(_class3.prototype, "miidle_outline", [_dec5], {
  240. configurable: true,
  241. enumerable: true,
  242. writable: true,
  243. initializer: function initializer() {
  244. return null;
  245. }
  246. }), _descriptor5 = _applyDecoratedDescriptor(_class3.prototype, "doors", [_dec6], {
  247. configurable: true,
  248. enumerable: true,
  249. writable: true,
  250. initializer: function initializer() {
  251. return null;
  252. }
  253. })), _class3)) || _class2));
  254. _cclegacy._RF.pop();
  255. _crd = false;
  256. }
  257. };
  258. });
  259. //# sourceMappingURL=776c1bfaf358ee3c47c0bd6c18759dc997cff279.js.map