123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- var t = require;
- var e = module;
- var i = exports;
- 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;
- };
- Object.defineProperty(i, "__esModule", { value: !0 }), (i.UI = void 0);
- const o = t("NotificationConst"),
- s = t("SystemOpenConst"),
- a = t("SystemOpenController"),
- n = t("App"),
- r = t("GameText"),
- l = t("EffectUtils"),
- h = t("Toast"),
- { ccclass: c, property: d, menu: u, executeInEditMode: p } = cc._decorator;
- (t = i.UI || (i.UI = {})),
- (i = class extends cc.Component {
- constructor() {
- super(...arguments),
- (this._systemIndex = ""),
- (this.lock = null),
- (this.unlock = null),
- (this.graySprites = []),
- (this.showType = 0),
- (this.isPlay = !0),
- (this.isInit = !1);
- }
- set systemIndex(t) {
- this._systemIndex = s.OpenTypeConst[t];
- }
- get systemIndex() {
- return s.OpenTypeConst[this._systemIndex];
- }
- set state(t) {
- (this.isOpen = t), this.updateState(this.systemIndex, t);
- }
- get state() {
- return this.isOpen;
- }
- start() {
- var t;
- if (!CC_EDITOR) {
- (this.config = a.default.ins.getConfigByType(this._systemIndex)),
- this.config &&
- ((t = a.default.ins.checkSystemOpen(this.config.index)) ||
- (n.default.NotificationCenter.addListener(
- o.NotificationConst.SYS_OPEN,
- this.updateSys,
- this,
- 200
- ),
- this.node.on(cc.Node.EventType.TOUCH_END, this.onTouch, this)),
- this.updateSys(this.systemIndex, t, !1));
- }
- }
- onTouch() {
- this.isOpen || h.default.launch(r.GameText.getTextByStr("system_con_" + this.config.id));
- }
- onDestroy() {
- n.default.NotificationCenter.removeListener(o.NotificationConst.SYS_OPEN, this.updateSys, this);
- }
- updateSys(e, i, t) {
- if (null == i)
- return (
- n.default.TimerManager.doTimer(
- 500,
- 1,
- () => {
- var t = a.default.ins.checkSystemOpen(this.config.index);
- this.updateSys(this.config.index, t, !1);
- },
- this
- ),
- void this.updateState(e, i)
- );
- if (e == this.systemIndex)
- if ((this.isOpen = i) && t && this.isPlay) {
- if (i && t && this.isPlay) {
- n.default.NotificationCenter.removeListener(o.NotificationConst.SYS_OPEN, this.updateSys, this);
- let t = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
- "" != this.config.pos &&
- "none" != this.config.pos &&
- ((s = {}),
- n.default.CommonUtils.parsePos(s, this.config.pos, "|"),
- (t.x = n.default.CommonUtils.getPosX1(s, cc.winSize.width, 0)),
- (t.y = n.default.CommonUtils.getPosY1(s, cc.winSize.height, 0)));
- var s = {
- id: this.config.id,
- icon: this.config.iconSource,
- desc: this.config.desc,
- pos: t,
- func: () => {
- this.updateState(e, i);
- },
- obj: this
- };
- l.default.instance.playLockAni(s);
- }
- } else this.updateState(e, i);
- }
- updateState(e, i) {
- if (e == this.systemIndex) {
- i && n.default.NotificationCenter.removeListener(o.NotificationConst.SYS_OPEN, this.updateSys, this);
- let t = this.node.getComponent(cc.Button);
- switch ((t && (t.interactable = i), this.showType)) {
- case s.ShowTypeConst.LOCK:
- if (
- (this.lock && (this.lock.active = !i),
- this.unlock && (this.unlock.active = i),
- this.graySprites.length)
- )
- for (const e of this.graySprites)
- i ?
- e.setMaterial(0, cc.Material.getBuiltinMaterial("2d-sprite")) :
- e.setMaterial(0, cc.Material.getBuiltinMaterial("2d-gray-sprite"));
- break;
- case s.ShowTypeConst.HIDE:
- this.node.active = i;
- }
- }
- }
- }),
- e([d], i.prototype, "_systemIndex", void 0),
- e([d({ type: cc.Enum(s.OpenTypeConst) })], i.prototype, "systemIndex", null),
- e(
- [
- d({
- type: cc.Node,
- visible() {
- return this.showType == s.ShowTypeConst.LOCK;
- }
- })
- ],
- i.prototype,
- "lock",
- void 0
- ),
- e([d({ type: cc.Node })], i.prototype, "unlock", void 0),
- e(
- [
- d({
- type: cc.Sprite,
- visible() {
- return this.showType == s.ShowTypeConst.LOCK;
- }
- })
- ],
- i.prototype,
- "graySprites",
- void 0
- ),
- e([d({ type: cc.Enum(s.ShowTypeConst) })], i.prototype, "showType", void 0),
- e([d({})], i.prototype, "isPlay", void 0),
- (i = e([c, p], i)),
- (t.SystemComponent = i);
|