def63cc7-3962-4c72-91f5-c074d3456e05.js 3.08 KB
"use strict";
cc._RF.push(module, 'def63zHOWJMcpH1wHTTRW4F', 'BlockSkillSwitcherView');
// scripts/prefabs/BlockSkillSwitcherView.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.BlockSkillSwitcherView = void 0;
var BattleConst_1 = require("../kernel/battle/BattleConst");
var GlobalNode_1 = require("../kernel/GlobalNode");
var BlockSkillViewBase_1 = require("./BlockSkillViewBase");
var BlockSkillSwitcherView = /** @class */ (function (_super) {
    __extends(BlockSkillSwitcherView, _super);
    function BlockSkillSwitcherView(owner, mapView) {
        var _this = _super.call(this, owner, mapView) || this;
        _this._open = false;
        _this._aniNode = cc.instantiate(mapView.prefabCollection.getChildByName('switcher'));
        _this._aniNode.active = true;
        _this._aniNode.setPosition(_this._owner.owner.pixelPos);
        mapView.txtUpLayer.addChild(_this._aniNode);
        _this._callbackBind = _this.onLazyUpdate.bind(_this);
        BattleConst_1.getGlobalNode().getComponent(GlobalNode_1.default).schedule(_this._callbackBind, 0.1);
        return _this;
    }
    BlockSkillSwitcherView.prototype.onPositionChange = function (x, y) {
        _super.prototype.onPositionChange.call(this, x, y);
        this._aniNode.setPosition(x, y);
    };
    BlockSkillSwitcherView.prototype.onDead = function () {
        _super.prototype.onDead.call(this);
        BattleConst_1.getGlobalNode().getComponent(GlobalNode_1.default).unschedule(this._callbackBind);
        this._aniNode.destroy();
        this._aniNode = null;
    };
    BlockSkillSwitcherView.prototype.onDestroy = function () {
        _super.prototype.onDestroy.call(this);
        BattleConst_1.getGlobalNode().getComponent(GlobalNode_1.default).unschedule(this._callbackBind);
    };
    BlockSkillSwitcherView.prototype.onLazyUpdate = function () {
        var skill = this._owner.owner.skill;
        if (skill.isOpen != this._open) {
            this._open = skill.isOpen;
            var ani = this._aniNode.getComponent(cc.Animation);
            var state = ani.getAnimationState('ani_switcher');
            state.stop();
            // state.time = (this._open ? 0 : state.clip.duration);
            state.wrapMode = (this._open ? cc.WrapMode.Normal : cc.WrapMode.Reverse);
            state.play();
            // ani.play('ani_switcher');
        }
    };
    return BlockSkillSwitcherView;
}(BlockSkillViewBase_1.BlcokSkillViewBase));
exports.BlockSkillSwitcherView = BlockSkillSwitcherView;

cc._RF.pop();