123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- e =
- (this && this.__decorate) ||
- function(t, e, i, s) {
- var o,
- a = arguments.length,
- n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
- else
- for (var r = t.length - 1; 0 <= r; r--)
- (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
- return 3 < a && n && Object.defineProperty(e, i, n), n;
- },
- o =
- (this && this.__awaiter) ||
- function(t, n, r, l) {
- return new(r = r || Promise)(function(i, e) {
- function s(t) {
- try {
- a(l.next(t));
- } catch (t) {
- e(t);
- }
- }
- function o(t) {
- try {
- a(l.throw(t));
- } catch (t) {
- e(t);
- }
- }
- function a(t) {
- var e;
- t.done ?
- i(t.value) :
- ((e = t.value) instanceof r ?
- e :
- new r(function(t) {
- t(e);
- })
- ).then(s, o);
- }
- a((l = l.apply(t, n || [])).next());
- });
- };
- Object.defineProperty(i, "__esModule", { value: !0 });
- const d = t("App"),
- a = t("GridLayer"),
- n = t("AstarHoneycombRoadSeeker"),
- r = t("AStarRoadSeeker"),
- l = t("MapRoadUtils"),
- h = t("RoadNode"),
- c = t("RoadPointLayer"),
- u = t("Toast"),
- p = t("ControllerConst"),
- f = t("NotificationConst"),
- g = (t("ViewConst"), t("PlatformBase"), t("BagConst")),
- m = t("BuffMgr"),
- _ = t("GameConst"),
- y = t("GlobalAttr"),
- v = t("GameView"),
- U = t("AbilityInfoService"),
- Z = t("BaseService"),
- C = t("CurrencyService"),
- b = t("DeskService"),
- S = t("HelperCatService"),
- T = t("MachineService"),
- I = t("OrderService"),
- w = t("RoleService"),
- M = t("StageUpgradeService"),
- D = t("ViewportService"),
- { ccclass: A, property: E } = cc._decorator;
- t = s = class extends Z.default {
- constructor() {
- super(...arguments),
- (this.curBundle = null),
- (this.foodBundle = null),
- (this.gameView = null),
- (this.mapNode = null),
- (this.layer = null),
- (this.uiLayer = null),
- (this.langLayer = null),
- (this._roadDic = {}),
- (this.curCfg = null),
- (this.machineMenu = null),
- (this.define = null),
- (this.curId = -1),
- (this.mapSaveData = null),
- (this.loadingTime = 0);
- }
- onLoad() {
- s.ins = this;
- }
- init() {}
- desotrySelf() {
- (this.layer = null),
- b.default.ins,
- S.default.ins.desotrySelf(),
- m.default.ins.closeRegion(this.curId),
- T.default.ins.destorySelf(),
- this.gameView.node.destroyAllChildren(),
- this.curBundle &&
- (this.curBundle.releaseAll(), cc.assetManager.removeBundle(this.curBundle), (this.curBundle = null)),
- (this.mapNode = null),
- w.default.ins.destroySelf();
- }
- loadMap(c, t = 0) {
- return o(this, void 0, void 0, function*() {
- this.mapNode && this.desotrySelf();
- let t = c < 10 ? "map_0" + c : "map_" + c;
- 1e4 < c && (t = "map_04");
- let e = t,
- i = "food";
- "test" == versionInfo.packVersion ?
- ((e = t),
- (i = "food")) :
- (e = t),
- yield d.default.ResManager.loadDirInBundle(e, ""),
- yield d.default.ResManager.loadDirInBundle(i, ""),
- (this.curCfg = d.default.ConfigManager.getConfig("StageSet")[c]);
- let s = "map_icon_1";
- "test" == versionInfo.packVersion && (s = s),
- yield d.default.ResManager.loadBundle(s),
- (this.curId = c),
- (this.define = d.default.ConfigManager.getConfig("Define")),
- (this.machineMenu = d.default.ConfigManager.getConfig("MachineMenu")),
- (this.curBundle = cc.assetManager.getBundle(t)),
- (this.foodBundle = cc.assetManager.getBundle("food"));
- const o = this.curBundle.get("map/MapNode", cc.Prefab),
- a = (this.mapNode = cc.instantiate(o));
- this.gameView.node.addChild(a),
- (a.y = -a.height),
- (D.default.ins.map = a),
- D.default.ins.initViewportArea();
- var n = this.curBundle.get("map/MapData", cc.JsonAsset).json;
- if (!n) return u.default.launch("缺少地图路径数据!"), void Log.error("缺少地图路径数据!");
- this.setMapData(n), m.default.ins.openNewRegion(c), this.parseMap();
- const r = d.default.ControllerManager.getControllerModel(p.ControllerConst.Game);
- var l,
- h = 1e4 < c ? _.EmMapType.FB : _.EmMapType.MAIN;
- r.data.curMapType === h ?
- (l = r.getCurMapData()).curId !== c ?
- (this.mapSaveData = r.resetMapData(c)) :
- (this.mapSaveData = l) :
- ((r.data.curMapType = h), (this.mapSaveData = r.getCurMapData())),
- M.default.ins.init(),
- I.default.ins.init(),
- w.default.ins.init(),
- T.default.ins.init(),
- b.default.ins.init(),
- C.default.ins.init(),
- U.default.ins.init(),
- S.default.ins.init(),
- y.default.ins.calAll(),
- "test" == versionInfo.packVersion && this.debug(n),
- d.default.NotificationCenter.dispatch(f.NotificationConst.UPDATE_MONEY),
- d.default.NotificationCenter.dispatch(f.NotificationConst.ENTER_MAP),
- (this.loadingTime || d.default.ViewManager.isShow(38)) &&
- ((n = d.default.DateUtils.Now() - this.loadingTime),
- (this.loadingTime = 0),
- 3e3 <= n ?
- d.default.ViewManager.close(38) :
- d.default.TimerManager.doTimer(
- 3e3 - n,
- 1,
- () => {
- d.default.ViewManager.close(38);
- },
- this
- ));
- });
- }
- setMapData(i) {
- l.default.instance.updateMapInfo(i.mapWidth, i.mapHeight, i.nodeWidth, i.nodeHeight, i.type),
- (this._roadDic = {});
- var t = i.roadDataArr.length,
- s = i.roadDataArr[0].length;
- for (let e = 0; e < t; e++) {
- let t = 0;
- for (; t < s; t++) {
- var o = i.roadDataArr[e][t],
- a = l.default.instance.getNodeByDerect(t, e);
- (a.value = o), (this._roadDic[a.cx + "_" + a.cy] = a);
- }
- }
- 2 == i.type ?
- (this._roadSeeker = new n.default(this._roadDic)) :
- (this._roadSeeker = new r.default(this._roadDic));
- }
- parseMap() {
- const t = this.mapNode;
- this.layer = t.getChildByName("layer");
- const e = t.getChildByName("bg2");
- e && (e.zIndex = 4),
- (this.layer.zIndex = 3),
- (this.langLayer = new cc.Node()),
- (this.langLayer.name = "LangLayer"),
- (this.langLayer.zIndex = 3),
- t.addChild(this.langLayer),
- (this.uiLayer = new cc.Node()),
- (this.uiLayer.name = "UILayer"),
- (this.uiLayer.zIndex = 3),
- t.addChild(this.uiLayer);
- const i = t.getChildByName("GridLayer");
- i && i.destroy(),
- y.default.init(),
- w.default.ins.parse(t),
- b.default.ins.parse(t),
- T.default.ins.parse(t.getChildByName("Machines"));
- }
- getPaths(t, e) {
- var i = l.default.instance.getWorldPointByPixel(t.x, t.y),
- t = l.default.instance.getWorldPointByPixel(e.x, e.y),
- i = this._roadDic[i.x + "_" + i.y],
- t = this._roadDic[t.x + "_" + t.y],
- t = this._roadSeeker.seekPath(i, t);
- const s = new h.default();
- return (s.px = e.x), (s.py = e.y), 0 < t.length && t.pop(), t.push(s), t;
- }
- update(t) {
- this.layer && this.layer.children.sort((t, e) => e.y - t.y);
- }
- debug(t) {
- const e = new cc.Node();
- this.mapNode.addChild(e, 1),
- e.addComponent(a.default).drawGrid(t.mapWidth, t.mapHeight, t.nodeWidth, t.nodeHeight, t.type);
- const i = new cc.Node();
- this.mapNode.addChild(i, 2), i.addComponent(c.default).initRoadPointInfo(t), w.default.ins.createTestMan();
- }
- switchMap() {
- const e = this.curCfg.clear_reward_suitcasekey_idx,
- i = this.curCfg.clear_reward_suitcasekey_count,
- s = this.curId + 1,
- o = d.default.ConfigManager.getConfig("StageSet")[s];
- if (0 < i) {
- d.default.ControllerManager.applyFunc(p.ControllerConst.Item, g.BagConst.ADD_TIME, e, i);
- const a = d.default.ControllerManager.applyFunc(p.ControllerConst.Item, g.BagConst.GET_ITEM, e);
- let t = new _.CongratulationData();
- (t.iconUrl = a.getItemPic()),
- (t.name = a.getName()),
- (t.cnt = i),
- (t.type = _.CongratulationType.Pass),
- (t.passIcon = "stage/" + o.stage_icon),
- d.default.ViewManager.open(31, [t], 1, () => {
- d.default.ViewManager.open(38, this.curId),
- (this.loadingTime = d.default.DateUtils.Now()),
- this.loadMap(s, !0);
- });
- } else
- d.default.ViewManager.open(38, this.curId),
- (this.loadingTime = d.default.DateUtils.Now()),
- this.loadMap(s, !0);
- d.default.AnalyticMgr.recordState("level", 1, s);
- }
- getCurRegionCfgs() {
- var t,
- e = d.default.ConfigManager.getConfig("StageSet");
- let i = this.curCfg.region,
- s = [];
- for (t in e)
- if (e[t].region == i) s.push(e[t]);
- else if (e[t].region > i) break;
- return s;
- }
- };
- e([E(v.default)], t.prototype, "gameView", void 0), (t = s = e([A], t)), (i.default = t = s);
|