123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
- "use strict";
- 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;
- 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 }); }
- 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; }
- 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.'); }
- function _reportPossibleCrUseOfBaseExp(extras) {
- _reporterNs.report("BaseExp", "../core/base/BaseExp", _context.meta, extras);
- }
- function _reportPossibleCrUseOfautoBind(extras) {
- _reporterNs.report("autoBind", "../extend/AutoBind", _context.meta, extras);
- }
- function _reportPossibleCrUseOfUtils(extras) {
- _reporterNs.report("Utils", "../utils/Utils", _context.meta, extras);
- }
- _export("AmbushPoint", void 0);
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- MeshRenderer = _cc.MeshRenderer;
- Node = _cc.Node;
- Vec3 = _cc.Vec3;
- }, function (_unresolved_2) {
- BaseExp = _unresolved_2.BaseExp;
- }, function (_unresolved_3) {
- autoBind = _unresolved_3.autoBind;
- }, function (_unresolved_4) {
- Utils = _unresolved_4.Utils;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "5d55d9VPhhHtoESZOqLjFhK", "Map", undefined);
- __checkObsolete__(['_decorator', 'MeshRenderer', 'Node', 'Vec3']);
- ({
- ccclass,
- property
- } = _decorator); //埋伏点接口类
- _export("AmbushPoint", AmbushPoint = class AmbushPoint {
- constructor() {
- //埋伏点位置节点数组
- this.standPosArr = [];
- //掩体点位置节点
- this.ambushPosArr = [];
- //逃跑点位置节点
- this.escapePosArr = [];
- //是否已经有人在此站位了
- this.isVacancy = false;
- }
- });
- _export("GMap", GMap = (_dec = ccclass('GMap'), _dec2 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "埋伏点配置节点"
- }), _dec3 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "敌人出生区域"
- }), _dec4 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "进门内线,用于敌人是否在门内"
- }), _dec5 = (_crd && autoBind === void 0 ? (_reportPossibleCrUseOfautoBind({
- error: Error()
- }), autoBind) : autoBind)({
- type: Node,
- tooltip: "进门外线,用于敌人是否在门外"
- }), _dec(_class2 = (_class3 = class GMap extends (_crd && BaseExp === void 0 ? (_reportPossibleCrUseOfBaseExp({
- error: Error()
- }), BaseExp) : BaseExp) {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "ambush_points", _descriptor, this);
- _initializerDefineProperty(this, "enemy_born_area", _descriptor2, this);
- _initializerDefineProperty(this, "miidle_inline", _descriptor3, this);
- _initializerDefineProperty(this, "miidle_outline", _descriptor4, this);
- //埋伏点配置数组
- this.ambushPoints = [];
- }
- start() {
- //区域隐藏
- [this.enemy_born_area].concat(this.ambush_points.children).forEach(e => {
- e.getComponent(MeshRenderer).enabled = false;
- }); //埋伏点类解析
- this.parseAmbushPoints();
- }
- /**
- * 解析埋伏点
- */
- parseAmbushPoints() {
- this.ambushPoints = this.ambush_points.children.map(ambushNode => {
- var point = new AmbushPoint();
- point.isVacancy = false; //从节点结构获取坐标配置
- point.standPosArr = ambushNode.children.filter(e => e.name.startsWith('stand_')).map(node => node.position.clone());
- point.ambushPosArr = ambushNode.children.filter(e => e.name.startsWith('bunker_')).map(node => node.position.clone());
- point.escapePosArr = ambushNode.children.filter(e => e.name.startsWith('escape_')).map(node => node.position.clone());
- return point;
- });
- }
- /**
- * 根据敌人信息得到敌人行走路径
- * @param eData 敌人数据
- * @param size 预制体大小
- * @returns
- */
- getPaths(eData) {
- var bornPos = this.getRandomBornPosition(); //进入内门时的坐标
- var innerPos = this.getRandomPos(eData, this.miidle_inline); //进入外门时的坐标
- var outerPos = this.getRandomPos(eData, this.miidle_outline); //行走路径
- var paths = [bornPos, innerPos, outerPos]; //最后一个点特殊处理 包含(站位点、埋伏点、逃跑点) 随机一个埋伏点
- var ambush = this.getAmbushClas();
- eData.ambush = ambush; //随机一个站立点到最后坐标
- var endPos = (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
- error: Error()
- }), Utils) : Utils).randomArray(ambush.standPosArr)[0];
- paths.push(endPos);
- return paths;
- }
- /**
- * 得到一个站位点
- */
- getAmbushClas() {
- //获取所有可用的埋伏点(未被占用的)
- var availablePoints = this.ambushPoints.filter(p => !p.isVacancy);
- if (availablePoints.length > 0) {
- //随机返回一个可用埋伏点
- return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
- error: Error()
- }), Utils) : Utils).randomArray(availablePoints)[0];
- } // 当所有点位都被占用时,随机返回任意一个
- if (this.ambushPoints.length > 0) {
- return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
- error: Error()
- }), Utils) : Utils).randomArray(this.ambushPoints)[0];
- }
- return null;
- }
- /**
- * 根据两个坐标点产生一个两个坐标点之前的随机点
- */
- getRandomPos(eData, target) {
- //只有坦克走中间
- var isTan = eData.id == 20003;
- var pos = target.position.clone();
- if (target.children.length >= 2) {
- var pos1 = target.children[0].position.clone();
- var pos2 = target.children[1].position.clone();
- var r = isTan ? 0.5 : Math.random();
- var randomX = r * (pos2.x - pos1.x) + pos1.x;
- var randomZ = r * (pos2.z - pos1.z) + pos1.z; //这儿为了看起来暂时保留x轴上的距离随机
- pos.x = randomX * 0.5; //y轴就是左边的间隔的距离
- pos.z = randomZ;
- }
- return pos;
- }
- /**
- * 获取随机出生点位置
- */
- getRandomBornPosition() {
- if (!this.enemy_born_area) return Vec3.ZERO; //获取3D节点的世界缩放
- var worldScale = this.enemy_born_area.getWorldScale(); //使用X和Z轴缩放作为区域尺寸
- var areaWidth = worldScale.x;
- var areaDepth = worldScale.z; //在XZ平面生成随机坐标(Y轴保持地面高度)
- var randomX = (Math.random() - 0.5) * areaWidth;
- var randomZ = (Math.random() - 0.5) * areaDepth; //基于节点原点位置生成世界坐标 保持与出生区域相同高度
- var basePos = this.enemy_born_area.worldPosition;
- return new Vec3(basePos.x + randomX, basePos.y, basePos.z + randomZ);
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class3.prototype, "ambush_points", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class3.prototype, "enemy_born_area", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class3.prototype, "miidle_inline", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- }), _descriptor4 = _applyDecoratedDescriptor(_class3.prototype, "miidle_outline", [_dec5], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return null;
- }
- })), _class3)) || _class2));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=c44dc8b944d5a8dcb5bd22bb5f8cd03624d749df.js.map
|