"use strict";
cc._RF.push(module, '16e81AVXRhIKpLf0PXVrKwW', 'DragonNode');
// Script/DragonNode.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 (b.hasOwnProperty(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 __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var MyGlobal_1 = require("./MyGlobal");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var DragonNode = /** @class */ (function (_super) {
    __extends(DragonNode, _super);
    function DragonNode() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DragonNode.prototype.playDragon = function (path) {
        var _this = this;
        cc.resources.loadDir(path, function (error, assets) {
            if (error)
                return;
            if (cc.isValid(_this.node)) {
                var dragonDisplay = _this.node.getComponent(dragonBones.ArmatureDisplay);
                if (assets instanceof Array && assets.length > 0) {
                    for (var index = 0; index < assets.length; index++) {
                        if (assets[index] instanceof dragonBones.DragonBonesAsset) {
                            dragonDisplay.dragonAsset = assets[index];
                        }
                        else if (assets[index] instanceof dragonBones.DragonBonesAtlasAsset) {
                            dragonDisplay.dragonAtlasAsset = assets[index];
                        }
                    }
                    dragonDisplay.armatureName = "Armature";
                    dragonDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE);
                    dragonDisplay.playAnimation("newAnimation", 1);
                    dragonDisplay.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE);
                    dragonDisplay.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, function () {
                        MyGlobal_1.default.GameManager.putDragonNode(_this.node);
                    }, _this);
                }
            }
        });
    };
    DragonNode = __decorate([
        ccclass
    ], DragonNode);
    return DragonNode;
}(cc.Component));
exports.default = DragonNode;

cc._RF.pop();