var t = require; var e = module; var i = exports; var 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}); const o = t("App"), a = t("Actions"), n = t("SubTree"), l = t("GameText"), r = t("BaseController"), h = t("EffectUtils"), c = t("ViewAni"), d = t("ConfigManager"), u = t("NotificationConst"), p = (t("ViewConst"), t("LayerManager"), t("CurrencyService")), f = t("MachineService"), g = t("MapService"), m = t("SystemOpenConst"), _ = t("SystemOpenController"), y = t("B3Tree1"), v = t("GuideModel"); class U extends r.default { constructor() { super(), (this._model = null), (this.godGuide = null), (this.isSkip = null), (this.curId = null), (this.tree = null), (this.blackboard = null), (this.notification = null), (this.cb = null), (this.param = null), (this._typerTimer = null), (this._isTest = !1), (this.eventRefMap = {}), (this.isCheckCd = !1), this.setModel(new v.GuideModel(this)), o.default.SaveManage.add(this._model, "GUIDE_DATA", !0, !0), this.addEventKeyMap(v.GuideConst), o.default.ViewManager.register(15, {prefabName: "GodGuide", zIndex: 200, dir: "guide", controller: this}), o.default.NotificationCenter.addListener(u.NotificationConst.INIT_GAME_FINISH, this.init, this); } init() { o.default.NotificationCenter.removeListener(u.NotificationConst.INIT_GAME_FINISH, this.init, this), this.initModuleEvent(), this.initNotificationEvent(), this.initData(); } initData() { o.default.SaveManage.load("GUIDE_DATA"), this.loadTree(); } setIsCanPlayAni(t) { (c.default.isCanPlayAni = t), (U.isGuide = !t); } listenNotifiaction(t) { this.notification && "" != this.notification && ((this.param = null), o.default.NotificationCenter.removeListener(this.notification, this.listenNotifiaction, this)), o.default.TimerManager.remove(this.listenNotifiaction, this), this.godGuide.clearCheckPosFuncTimer(), this.tick(); } wait(t, e, i) { e && "" != e && ((this.notification = e), (this.param = i), o.default.NotificationCenter.addListener(e, this.listenNotifiaction, this)), t && o.default.TimerManager.doTimer(t, 1, this.listenNotifiaction, this); } showStory(n) { this.clearTyperTimer(); let r = this.godGuide.getStoryObj(), t = r.items[r.index++]; (t.node.active = !0), (r.label.string = ""), (t.img.frameIndex = 1); var e = () => { let a = n.i18 ? l.GameText.getTextByStr(n.i18) : n.str; if ( (cc .tween(t.img.node) .call(() => { t.img.frameIndex = 0; }) .delay(0.7) .call(() => { t.img.frameIndex = 1; }) .delay(0.7) .union() .repeatForever() .start(), n.typerAniTime) ) { this.godGuide._targetNode = r.node; let e = a.split("|"), i = e.length, s = 0, o = !0, t = () => { let t = e[s]; (o = !1), (this._typerTimer = h.default.instance.typerEffect( r.label, t.replace(/\\n/g, "\n"), n.typerAniTime, () => { (o = !0), i === ++s ? this.typerFinish() : (r.label.string = t); }, this )); }; t(), r.node.on( cc.Node.EventType.TOUCH_END, () => { this.clearTyperTimer(), i === s ? (this.typerFinish(), (this.godGuide._targetNode = null), (r.label.string = e[e.length - 1])) : o ? t() : ((o = !0), (r.label.string = e[s]), s++); }, this ); } else (r.label.string = a.replace(/\\n/g, "\n")), this.typerFinish(); }; r.index % 2 ? (t.node.x = -860) : (t.node.x = 860), cc.tween(t.node).to(0.7, {x: 0}, {easing: cc.easing.cubicOut}).call(e).start(); } hideStory() { this.clearTyperTimer(); let t = this.godGuide.getStoryObj(); cc.tween(t.node) .to(0.7, {x: -cc.winSize.width}, {easing: cc.easing.cubicOut}) .call(() => { (t.node.active = !1), this.tick(); }) .start(); } removeStory() { this.clearTyperTimer(); let t = this.godGuide.getStoryObj(); cc.tween(t.node) .to(0.5, {x: -cc.winSize.width}, {easing: cc.easing.cubicOut}) .call(() => { t.node.active = !1; }) .start(); } typerFinish() { o.default.TimerManager.setFrameOut(1, this.waitTouch, this), this.godGuide.getStoryObj().node.off(cc.Node.EventType.TOUCH_END), (this._typerTimer = null); } clearTyperTimer() { this._typerTimer && (o.default.TimerManager.remove(this._typerTimer, null), (this._typerTimer = null)); } waitTouch(t) { this.godGuide._targetNode || (this.godGuide._targetNode = this.godGuide.node), t && this.godGuide.node.once(cc.Node.EventType.TOUCH_END, this.onTouchTarget, this), this.godGuide._targetNode.once(cc.Node.EventType.TOUCH_END, this.onTouchTarget, this); } onTouchTarget() { this.godGuide._targetNode && ((this.godGuide._targetNode = null), this.godGuide.clearCheckPosFuncTimer(), o.default.TimerManager.setFrameOut( 1, () => { this.tick(); }, this )); } locatorTouchNode(t, e, i, s = 0) { this.godGuide.find( t, t => { (this.godGuide._targetNode = t), i(), this.tick(); }, s, e ); } locatorTouchNodeAsync(e, i) { return s(this, void 0, void 0, function* () { var t = yield this.godGuide.findAsync(e); (this.godGuide._targetNode = t), i && i(), this.tick(); }); } hideMask() { this.godGuide && this.godGuide.hideMask(); } showMask(t) { this.godGuide.showMask(t), (this.godGuide._targetNode = this.godGuide.node); } showSkip(t, e) { t && e ? o.default.TimerManager.doTimer(e, 1, this.delayShowSkip, this) : (o.default.TimerManager.remove(this.delayShowSkip, this), this.godGuide.showSkip(t)); } delayShowSkip() { this.godGuide.showSkip(1); } setStep(t, e = this.curId) { this._model.setStep(this.curId, t), -1 === t && (this.godGuide.stepFinish(this.curId), o.default.NotificationCenter.dispatch(u.NotificationConst.GUIDE_STEP_FINISH, e)); } openGuideView() { h.default.instance.queueExecutor.regist(() => { this.setIsCanPlayAni(!1), o.default.NotificationCenter.dispatch(u.NotificationConst.START_GUIDE), o.default.TimerManager.doTimer( 1, 1, () => { o.default.ViewManager.open(15, !0), h.default.instance.queueExecutor.finishFunc(); }, this ); }, this); } skinGuide(t) { return s(this, void 0, void 0, function* () { yield o.default.TimerManager.sleep(500), o.default.ViewManager.close(15), t ? this.testSkinGuide() : -1 < this.curId && (this._model.setStep(this.curId, -1), (this.blackboard = new y.b3.Blackboard()), this.godGuide.reset(), this.tick()); }); } checkStep(t) { return this.isSkip && this._model.setStep(this.curId, -1), this._model.checkStep(this.curId, t); } showArrow(t) {} showTip(t) { this.godGuide.showText(t, () => { o.default.TimerManager.setFrameOut(1, this.tick, this); }); } hideTip() { this.godGuide.hideText(); } testSkinGuide() { (this.isSkip = !0), (this.blackboard = new y.b3.Blackboard()), this.tick(); } loadTree() { this.tree = new y.b3.BehaviorTree(); let i = o.default.ConfigManager.getConfig("guideConf"); if (i.trees) { const s = /^\(?\d+\)/; n.default.setSubTreeLoadFunc(t => { for (const e of i.trees) if (e.title.replace(s, "") === t.properties.path || e.properties.path === t.properties.path) { t.loadDataFinish(e); break; } }); for (const t of i.trees) if ("主树" == t.title || (t.properties && "主树" == t.properties.path)) { this.tree.load(t, a.Actions); break; } } else this.tree.load(i, a.Actions); this.blackboard = new y.b3.Blackboard(); } tick() { this.tree && (this.tree.tick(this, this.blackboard) === y.b3.RUNNING ? this.setIsCanPlayAni(!1) : U.isGuide && (this.setIsCanPlayAni(!0), o.default.ViewManager.close(15))); } onOpenView(t) { t.viewId, o.default.ViewManager.closeAll([4, 2, 6, 0, 15, 29, 23, 24, 39]), (c.default.isCanPlayAni = !1), o.default.TimerManager.doFrame(1, 1, this.tick, this); } on_OPEN_GUIDE(t) { isNaN(t) || this.setStep(0, t), this.tick(); } addEvent(t, e) { this.eventRefMap[t] ? -1 === this.eventRefMap[t].indexOf(e) && this.eventRefMap[t].push(e) : ((this.eventRefMap[t] = [e]), o.default.NotificationCenter.addListener(t, this.checkIsGuide, this)); } removeEvent(t, e) { !this.eventRefMap[t] || (-1 !== (e = this.eventRefMap[t].indexOf(e)) && (this.eventRefMap[t].splice(e, 1), 0 === this.eventRefMap[t].length && (delete this.eventRefMap[t], o.default.NotificationCenter.removeListener(t, this.checkIsGuide, this)))); } checkNewGuideIsOpen(t) { if (t.mapId && t.mapId !== g.default.ins.curId) return !1; if (this._model.checkIsFinish(t.id)) return !1; if (this.isSkip) return this._model.setStep(t.id, -1), !1; if (t.open) { if (!_.default.ins.checkSystemOpen(m.OpenTypeConst[t.open])) return this.addEvent(u.NotificationConst.SYS_OPEN, t.id), !1; this.removeEvent(u.NotificationConst.SYS_OPEN, t.id); } if (t.machinLvCnt) { if (t.machinLvCnt > f.default.ins.getMachinAllLvCnt()) return this.addEvent(u.NotificationConst.MACHINE_UPDATE, t.id), !1; this.removeEvent(u.NotificationConst.MACHINE_UPDATE, t.id); } if (t.money) { if (!p.default.ins.checkMoneyEnough(t.money)) return this.addEvent(u.NotificationConst.UPDATE_MONEY, t.id), !1; this.removeEvent(u.NotificationConst.UPDATE_MONEY, t.id); } return (this.curId = t.id), Log.trace("进入新手引导:", this.curId), !0; } initModuleEvent() { this.registerFunc(v.GuideConst.OPEN_GUIDE, this.on_OPEN_GUIDE, this), this.registerFunc(v.GuideConst.PLAY_RECORD, this.playRecordNodeTouch, this), this.registerFunc(v.GuideConst.START_RECORD, this.startRecordNodeTouch, this), this.registerFunc(v.GuideConst.STOP_RECORD, this.stopRecordNodeTouch, this), this.registerFunc(v.GuideConst.SKIN_GUIDE, this.skinGuide, this), this.registerFunc(v.GuideConst.NEXT_STEP, this.onNextStep, this), this.registerFunc(v.GuideConst.EXECUTE_FUNC, this.onExecuteFunc, this), this.registerFunc(v.GuideConst.CHECK_IS_GUIDE, this._model.checkIsFinish, this._model), this.registerFunc(v.GuideConst.SET_STEP, this.onSetStep, this), this.registerFunc(v.GuideConst.CHECK_STEP, this.checkStep, this); } onSetStep(t) { delete this._model.saveData[t]; } onNextStep() { this.godGuide.reset(), this.tick(); } finishGuide() {} step6() {} onExecuteFunc(t) { return this[t] && "function" == typeof this[t] ? this[t]() : y.b3.FAILURE; } playRecordNodeTouch(t, e) { this.godGuide.playRecordNodeTouch(); } startRecordNodeTouch() { this.godGuide ? this.godGuide.startRecordNodeTouch() : o.default.ViewManager.open(15); } stopRecordNodeTouch() { this.godGuide.stopRecordNodeTouch(); } setAutorun() {} checkIsGuide() { U.isGuide || this.tick(); } addPet() { this.isCheckCd || ((this.isCheckCd = !0), o.default.TimerManager.doFrame( 2, 1, () => { (this.isCheckCd = !1), this.checkIsGuide(); }, this )); } addItem(t, e, i, s) { (i || s) && this.checkIsGuide(); } initNotificationEvent() { o.default.NotificationCenter.addListener(u.NotificationConst.ENTER_MAP, this.checkIsGuide, this); } removeNotificationEvent() {} } (i.default = U), (U.isGuide = !1), d.registerJSONConf("guideConf", "NewGuideTree");