var t = require; var e = module; var i = exports; var 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; }, s = (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 }), (i.ShopOpenBoxView = void 0); const o = t("App"), a = t("BaseView"), n = t("ControllerConst"), r = (t("ADController"), t("BagConst")), l = t("CostumeConst"), h = t("GameConst"), c = t("ShopConst"), { ccclass: d, property: u, menu: p } = cc._decorator; t = class extends a.default { constructor() { super(...arguments), (this.icon = null), (this.typeIcon = null), (this.bgSpr = null), (this.nameLab = null), (this.ani = null), (this.costBtn = null), (this.costLab = null), (this.costIconNode = null), (this.boxList = []), (this.itemBase = null), (this.data = null), (this.isPlaying = !1), (this.bgType = 1); } initUI() { super.initUI(); } open(t, e) { super.open(), (this.data = e), (this.itemBase = o.default.ControllerManager.applyFunc( n.ControllerConst.Item, r.BagConst.GET_ITEM, this.data.cfg.itemId )), this.openBox(t); } openBox(t) { (this.bgSpr.node.scale = 0), (this.bgSpr.node.y = 30), (this.nameLab.node.active = !1), (this.costBtn.parent.active = !1), (this.nameLab.string = t.getName()), o.default.CommonUtils.setSpriteFrame(l.getRarityUrlByGrade(t.data.grade), this.bgSpr), o.default.CommonUtils.setSpriteFrameByBundle(h.BundleType.MAP_ICON, t.getIcon(), this.icon), o.default.CommonUtils.setSpriteFrameByBundle(h.BundleType.MAP_ICON, t.getTypeIcon(), this.typeIcon); var e = this.data.cfg.icon; for (let t = 0; t < this.boxList.length; t++) this.boxList[t].active = t == e; this.ani.once(cc.Animation.EventType.FINISHED, this.onAniFinished, this), this.updateCost(), this.ani.play("work"), (this.isPlaying = !0); } updateCost() { this.data.cfg.ad ? (this.costBtn.active = !1) : ((this.costBtn.active = !0), this.itemBase.cnt ? ((this.costIconNode.active = !1), (this.costLab.string = `${this.itemBase.cnt}/1`)) : ((this.costIconNode.active = !0), (this.costLab.string = this.data.cfg.diamond.toString()))); } onTouchBg() { this.isPlaying && (this.ani.off(cc.Animation.EventType.FINISHED, this.onAniFinished, this), (this.boxList[0].parent.y = 0), this.onAniFinished()); } onAniFinished() { (this.isPlaying = !1), (this.costBtn.parent.active = !0), (this.nameLab.node.active = !0), cc.tween(this.bgSpr.node).to(0.2, { y: 300, scale: 1 }).start(), this.ani.play("idle"); } onTouchCostBtn() { return s(this, void 0, void 0, function*() { this.itemBase.cnt ? o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, c.ShopConst.USE, this.data) : o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, c.ShopConst.BUY, this.data, 7); }); } }; e([u(cc.Sprite)], t.prototype, "icon", void 0), e([u(cc.Sprite)], t.prototype, "typeIcon", void 0), e([u(cc.Sprite)], t.prototype, "bgSpr", void 0), e([u(cc.Label)], t.prototype, "nameLab", void 0), e([u(cc.Animation)], t.prototype, "ani", void 0), e([u(cc.Node)], t.prototype, "costBtn", void 0), e([u(cc.Label)], t.prototype, "costLab", void 0), e([u(cc.Node)], t.prototype, "costIconNode", void 0), e([u([cc.Node])], t.prototype, "boxList", void 0), (t = e([d], t)), (i.ShopOpenBoxView = t);