b75a0e27-fe5d-43c1-86b8-b6d7742683a6.js 8.46 KB
"use strict";
cc._RF.push(module, 'b75a04n/l1DwYa4ttd0JoOm', 'MapView');
// scripts/kernel/battle/map/MapView.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapView = void 0;
var SaveDataManager_1 = require("../../../component/SaveDataManager");
var Global_1 = require("../../../Global");
var ObjBaseView_1 = require("../../../prefabs/ObjBaseView");
var TableDefine_1 = require("../../table/TableDefine");
var BattleConst_1 = require("../BattleConst");
var RectBlockData_1 = require("./RectBlockData");
var MapView = /** @class */ (function (_super) {
    __extends(MapView, _super);
    function MapView() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._rectBlcokUidList = [];
        return _this;
    }
    Object.defineProperty(MapView.prototype, "colliderLayer", {
        get: function () { return this._colliderLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "blockImgLayer", {
        /**砖块图层 */
        get: function () { return this._blockImgLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "blockIconLayer", {
        /**砖块的图标图层 */
        get: function () { return this._blockIconLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "effectLayer", {
        /**砖块的效果特效图层 */
        get: function () { return this._effectLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "lightLayer", {
        /**砖块的高亮图层 */
        get: function () { return this._lightLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "txtLayer", {
        /**数字图层 */
        get: function () { return this._txtLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "txtUpLayer", {
        /** 遮住数字的图层*/
        get: function () { return this._txtUpLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "ballLayer", {
        /**弹球 */
        get: function () { return this._ballLayer; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "prefabCollection", {
        get: function () { return this._prefabCollection; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MapView.prototype, "testBall", {
        get: function () { return this._testBall; },
        enumerable: false,
        configurable: true
    });
    MapView.prototype.init = function (data, prefabCollection, preview) {
        var _this = this;
        this._mapData = data;
        this._prefabCollection = prefabCollection;
        var height = data.mapGridSize.y * data.gridSize.y;
        this.setContentSize(data.mapGridSize.x * data.gridSize.x, height);
        this._colliderLayer = this.createLayer('colliderLayer');
        this.addChild(this._colliderLayer);
        this._blockImgLayer = this.createLayer('blockImgLayer');
        this.addChild(this._blockImgLayer);
        this._blockIconLayer = this.createLayer('blockIconLayer');
        this.addChild(this._blockIconLayer);
        this._effectLayer = this.createLayer('effectLayer');
        this.addChild(this._effectLayer);
        this._lightLayer = this.createLayer('lightLayer');
        this.addChild(this._lightLayer);
        this._txtLayer = this.createLayer('txtLayer');
        this.addChild(this._txtLayer);
        this._txtUpLayer = this.createLayer('txtUpLayer');
        this.addChild(this._txtUpLayer);
        this._ballLayer = this.createLayer('ballLayer');
        this.addChild(this._ballLayer);
        var foo;
        var cmpt;
        data.objData.forEach(function (obj, index, map) {
            foo = null;
            if (obj.type == BattleConst_1.ObjType.PLUS_ONE || obj.type == BattleConst_1.ObjType.SPLITER) {
                foo = cc.instantiate(prefabCollection.getChildByName('dotSkill'));
            }
            else if (obj.type >= BattleConst_1.ObjType.LANCER_1 && obj.type <= BattleConst_1.ObjType.LANCER_3) {
                foo = cc.instantiate(prefabCollection.getChildByName('laser'));
            }
            else if (obj.type == BattleConst_1.ObjType.BIG_BOMB || obj.type == BattleConst_1.ObjType.BIG_BOMB_33) {
                foo = cc.instantiate(prefabCollection.getChildByName('bigBomb'));
                ;
            }
            else if (obj.type == BattleConst_1.ObjType.TRANGLE_1 || obj.type == BattleConst_1.ObjType.TRANGLE_2 || obj.type == BattleConst_1.ObjType.TRANGLE_3 || obj.type == BattleConst_1.ObjType.TRANGLE_4) {
                var fff = obj.type - 2;
                foo = cc.instantiate(prefabCollection.getChildByName('trangleBlock' + fff.toString()));
            }
            else if (obj.type == BattleConst_1.ObjType.POT) {
                foo = cc.instantiate(prefabCollection.getChildByName('pot'));
            }
            else if (obj.type == BattleConst_1.ObjType.ROTATER) {
                foo = cc.instantiate(prefabCollection.getChildByName('rotater'));
            }
            else if (obj.type == BattleConst_1.ObjType.STATIC_IRON) {
                foo = cc.instantiate(prefabCollection.getChildByName('staticNail'));
            }
            else if (obj.type == BattleConst_1.ObjType.PATROL) {
                foo = cc.instantiate(prefabCollection.getChildByName('patrol'));
            }
            else {
                if (obj instanceof RectBlockData_1.RectBlockData) {
                    if (!_this._rectBlcokUidList.includes(obj.uid)) {
                        _this._rectBlcokUidList.push(obj.uid);
                        foo = cc.instantiate(prefabCollection.getChildByName('rectBlock'));
                        ;
                    }
                }
                else {
                    foo = cc.instantiate(prefabCollection.getChildByName('block'));
                    ;
                }
            }
            if (foo) {
                var cmpt_1 = foo.getComponent(ObjBaseView_1.default);
                cmpt_1.init(obj, _this);
                preview && cmpt_1.onPreview();
            }
        }, this);
        this._testBall = cc.instantiate(prefabCollection.getChildByName('testBall'));
        this._ballLayer.addChild(this._testBall);
    };
    MapView.prototype.createLayer = function (name) {
        var layer = new cc.Node(name);
        layer.setContentSize(this._mapData.mapGridSize.x * this._mapData.gridSize.x, this._mapData.mapGridSize.y * this._mapData.gridSize.y);
        return layer;
    };
    MapView.prototype.playBlockParticle = function (node) {
        var parPrefab = this._prefabCollection.getChildByName('parBlockBoom');
        var par = cc.instantiate(parPrefab);
        par.setPosition(node.position);
        par.active = false;
        var skinId = SaveDataManager_1.SaveDataManager.ins.runtimeData.ballSkinCurrent;
        SaveDataManager_1.SaveDataManager.ins.runtimeData.ballSkinTry > 0 && (skinId = SaveDataManager_1.SaveDataManager.ins.runtimeData.ballSkinTry);
        var ballSkin = Global_1.tMgr.getConfig(TableDefine_1.TableName.BALL_SKIN, skinId);
        cc.resources.load('battle/' + ballSkin.Particle, cc.SpriteFrame, function (error, asset) {
            if (!error) {
                par.active = true;
                par.getComponent(cc.ParticleSystem).custom = true;
                par.getComponent(cc.ParticleSystem).spriteFrame = asset;
                par.getComponent(cc.ParticleSystem).resetSystem();
            }
        });
        // par.getComponent(cc.ParticleSystem).resetSystem();
        this._effectLayer.addChild(par);
    };
    return MapView;
}(cc.Node));
exports.MapView = MapView;

cc._RF.pop();