f33c71a8-ea5e-431d-8561-77f1cafbe968.js 3.92 KB
"use strict";
cc._RF.push(module, 'f33c7Go6l5DHYVhd/HK++lo', 'BattleManager');
// scripts/kernel/battle/BattleManager.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.BattleManager = void 0;
var SaveDataManager_1 = require("../../component/SaveDataManager");
var Battle_1 = require("./Battle");
var BattleConst_1 = require("./BattleConst");
var BattleManager = /** @class */ (function (_super) {
    __extends(BattleManager, _super);
    function BattleManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._eventNode = new cc.Node("battleManagerEventNode");
        _this._paused = false;
        /**是否可以滑动控制发射指示器 */
        _this.shootTouchEnable = false;
        return _this;
    }
    Object.defineProperty(BattleManager, "ins", {
        get: function () {
            if (this._ins == null) {
                this._ins = BattleConst_1.getGlobalNode().addComponent(BattleManager);
                BattleConst_1.getGlobalNode().addChild(this._ins.eventNode);
                // this._ins.eventNode.event
            }
            return this._ins;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BattleManager.prototype, "curBattle", {
        get: function () { return this._curBattle; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BattleManager.prototype, "eventNode", {
        /**事件节点,BattleEvent的派发和监听都在此节点进行 */
        get: function () { return this._eventNode; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BattleManager.prototype, "paused", {
        get: function () { return this._paused; },
        set: function (value) {
            this._paused = value;
            if (this.curBattle && this.curBattle.roundRunning) {
                // PhysicsControl.ins.setPhysicsEnable(!value);
            }
        },
        enumerable: false,
        configurable: true
    });
    // private _prefabCollection:cc.Prefab
    BattleManager.prototype.startBattle = function (levelId, callBack, thisObj, prefab) {
        this.shootTouchEnable = false;
        this._paused = false;
        if (this.curBattle) {
            //销毁
            this._curBattle.destroy();
            this._curBattle = null;
        }
        this._curBattle = new Battle_1.Battle();
        this._curBattle.init(levelId, function () {
            callBack.call(thisObj);
        }, this, prefab);
        this.eventNode.emit(BattleConst_1.BattleEvent.BATTLE_START);
    };
    /**直接离开战斗,不会触发战斗结算 */
    BattleManager.prototype.leaveBattle = function () {
        //#region 恢复试用数据
        SaveDataManager_1.SaveDataManager.ins.runtimeData.ballSkinTry = 0;
        SaveDataManager_1.SaveDataManager.ins.runtimeData.goldenAimTry = false;
        SaveDataManager_1.SaveDataManager.ins.saveData();
        //#endregion
        this._curBattle.destroy();
        this._curBattle = null;
    };
    BattleManager.prototype.update = function (dt) {
        // super.update(dt);
        if (this._curBattle && !this._paused) {
            this._curBattle.update(dt);
        }
    };
    return BattleManager;
}(cc.Component));
exports.BattleManager = BattleManager;

cc._RF.pop();