123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- var t = require;
- var e = module;
- var i = exports;
- Object.defineProperty(i, "__esModule", {value: !0});
- const h = t("App"),
- s = t("BaseController"),
- o = t("RedPointMgr"),
- a = t("Toast"),
- n = t("NotificationConst"),
- r = (t("ViewConst"), t("LayerManager"), t("PlatformBase"), t("GameConst")),
- c = t("GameUtils"),
- l = t("CurrencyService"),
- d = t("CostumeConst"),
- u = t("CostumeItem"),
- p = t("CostumeModel");
- let f = null;
- (o.RedPointMgr.types.MergeCostume = "MergeCostume"),
- (o.RedPointMgr.types.RecommendCostume = "RecommendCostume"),
- (i.default = class extends s.default {
- constructor() {
- super(),
- (this._model = null),
- (this._recalMap = []),
- (this._parseFuncMap = null),
- (this.costumeBagView = null),
- (this.costumeInfoView = null),
- (this.costumeStatisticsView = null),
- (f = this).initNotificationEvent(),
- this.setModel(new p.CostumeModel(this)),
- h.default.ViewManager.register(25, {
- prefabName: "CostumeBagView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(26, {
- prefabName: "CostumeInfoView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(27, {
- prefabName: "CostumeMergeView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(33, {
- prefabName: "CostumeRefundView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(34, {
- prefabName: "CotumeUpgradView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(35, {
- prefabName: "CostumeMergeTipView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(46, {
- prefabName: "CostumeStatisticsView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(47, {
- prefabName: "CostumeMergeAniView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- }),
- h.default.ViewManager.register(49, {
- prefabName: "CostumeCoinReturnView",
- zIndex: 100,
- controller: this,
- dir: "costume"
- });
- }
- static get ins() {
- return f;
- }
- initModuleEvent() {}
- initNotificationEvent() {
- h.default.NotificationCenter.addListener(n.NotificationConst.INIT_GAME_FINISH, this.initGame, this);
- }
- log(...t) {
- cc.log("Costume", ...t);
- }
- initGame() {
- this.initModuleEvent(),
- h.default.NotificationCenter.removeListener(n.NotificationConst.INIT_GAME_FINISH, this.initGame, this);
- const e = this._model;
- e.init();
- var i = e.saveData.items;
- let s = i.length;
- for (let t = 0; t < s; t++) {
- const s = i[t],
- o = new u.default(),
- a = e.costumeCfg[s.id];
- o.init(s, a, e.costumeUpgrade, e.costumeMergeCfg), e.addCostumeItem(o);
- }
- for (const h in e.saveData.equipItem) this.equipCostume(e.saveData.equipItem[h]);
- this.calEquipCostumeAttr(), this.checkRedpoint();
- }
- test() {
- const t = this._model,
- e = t.equipItems;
- if (!e[d.CostumeParts.head]) {
- const e = t.getCostumeItemByParts(d.CostumeParts.head);
- e.length && this.equipCostume(e[0].data.uuid);
- }
- if (!e[d.CostumeParts.hand]) {
- const e = t.getCostumeItemByParts(d.CostumeParts.hand);
- e.length && this.equipCostume(e[0].data.uuid);
- }
- if (!e[d.CostumeParts.body]) {
- const e = t.getCostumeItemByParts(d.CostumeParts.body);
- e.length && this.equipCostume(e[0].data.uuid);
- }
- this.log("/-----当前装备:");
- for (const i in this._model.equipItems) this.log(this._model.equipItems[i].toString());
- this.log("当前装备-------/:");
- }
- createNewCostume(t, e = 1, i = 1, s = !0) {
- const o = new u.default(),
- a = this._model,
- n = {id: t, lv: i, grade: e, uuid: a.saveData.uuid++};
- return (
- o.init(n, a.costumeCfg[t], a.costumeUpgrade, a.costumeMergeCfg),
- a.addCostumeItem(o),
- a.saveData.items.push(n),
- s && this.checkRedpoint(),
- o
- );
- }
- getTempCostume(t, e = 1, i = 1) {
- const s = new u.default(),
- o = this._model,
- a = {id: t, lv: i, grade: e, uuid: null};
- return s.init(a, o.costumeCfg[t], o.costumeUpgrade, o.costumeMergeCfg), s;
- }
- lvUp(t) {
- const e = this._model.getCostumeItemByUuid(t);
- if (e) {
- const t = e.cost;
- if (l.default.ins.checkDiamondEnough(t))
- return (
- e.lvUp(),
- l.default.ins.diamondChange(-t),
- e.isEquip && (this.record(d.CostumeAbilityType.base), this.calEquipCostumeAttr()),
- e.recommend || this.checkRecommand(),
- h.default.NotificationCenter.dispatch(r.GameNotificationConst.LV_UP_COSTUME, e),
- h.default.AnalyticMgr.recordDiamondCost(2, -t),
- !0
- );
- a.default.launch("钻石不足");
- } else Log.error("装备不存在:", t);
- return !1;
- }
- upgradeGrade(t) {
- const e = this._model.getCostumeItemByUuid(t);
- if (e) {
- const t = e.gradeCfg.upgrade_cost;
- if (l.default.ins.checkDiamondEnough(t))
- return (
- e.gradeUp(),
- this.refundCostume(e),
- l.default.ins.diamondChange(-t),
- e.isEquip && (this.record(d.CostumeAbilityType.base), this.calEquipCostumeAttr()),
- e.recommend || this.checkRecommand(),
- this.checkRedpoint(!1),
- h.default.NotificationCenter.dispatch(r.GameNotificationConst.LV_UP_COSTUME, e),
- h.default.AnalyticMgr.recordDiamondCost(3, -t),
- !0
- );
- a.default.launch("钻石不足");
- } else Log.error("装备不存在:", t);
- }
- equipCostume(t, e) {
- const i = this._model.getCostumeItemByUuid(t);
- if (i) {
- const t = this._model.equipItems[i.cfg.parts];
- if (
- ((i.isEquip = !0),
- (this._model.equipItems[i.cfg.parts] = i),
- (this._model.saveData.equipItem[i.cfg.parts] = i.data.uuid),
- t)
- ) {
- t.isEquip = !1;
- for (const e in t.attr) this.record(parseInt(e));
- }
- for (const e in i.attr) this.record(parseInt(e));
- e && (this.calEquipCostumeAttr(), this.checkRecommand()),
- h.default.NotificationCenter.dispatch(r.GameNotificationConst.EQUIP_COSTUME, i, t);
- } else Log.error("装备不存在:", t);
- }
- unequipCostume(t, e, i) {
- const s = this._model.equipItems[t];
- if (s) {
- for (const t in s.attr) this.record(parseInt(t));
- return (
- delete this._model.equipItems[t],
- delete this._model.saveData.equipItem[t],
- (s.isEquip = !1),
- i && (this.calEquipCostumeAttr(), this.checkRecommand()),
- e && h.default.NotificationCenter.dispatch(r.GameNotificationConst.UNEQUIP_COSTUME, s),
- s
- );
- }
- Log.error("这个位置没有装备物品:", t, d.CostumeParts[t]);
- }
- record(t) {
- this._recalMap.includes(t) || this._recalMap.push(t);
- }
- refundCostume(t) {
- if (1 < t.data.lv) {
- var e = t.getLvCost(t.data.lv);
- return (
- t.refund(),
- l.default.ins.diamondChange(e),
- t.isEquip && (this.record(d.CostumeAbilityType.base), this.calEquipCostumeAttr()),
- t.recommend && this.checkRecommand(),
- h.default.NotificationCenter.dispatch(r.GameNotificationConst.REFUND_COSTUME, t),
- !0
- );
- }
- }
- checkItemIsRecommand(t) {
- var e = this._model.items;
- t.cfg.parts;
- for (const i of e) i.cfg.parts;
- }
- checkIsCanMerge(e, i) {
- var t = this._model.costumeMergeCfg[e.data.grade],
- s = i.length;
- if (s !== t.costume_count) return !1;
- for (let t = 0; t < s; t++) if (!e.checkIsCanMerge(i[t])) return !1;
- return !0;
- }
- mergeCostume(e, i) {
- if (!this.checkIsCanMerge(e, i)) return null;
- let s = e.getLvCost(e.data.lv),
- o = e.isEquip,
- a = i.length;
- for (let t = 0; t < a; t++) {
- const e = i[t];
- (o = o || e.isEquip), (s += e.getLvCost(e.data.lv)), this.destoryCostumeItem(e);
- }
- return (
- e.gradeUp(),
- o && this.calEquipCostumeAttr(),
- 0 < s && l.default.ins.diamondChange(s),
- this.checkRedpoint(),
- h.default.NotificationCenter.dispatch(r.GameNotificationConst.MERGE_COSTUME, e, i),
- {refundDiamond: s}
- );
- }
- destoryCostumeItem(t) {
- t.isEquip && this.unequipCostume(t.cfg.parts), this._model.removeCostumeItem(t);
- }
- calEquipCostumeAttr() {
- const e = this._model.attr;
- for (let t = d.CostumeParts.head; t <= d.CostumeParts.hand; t++) {
- const i = this._model.equipItems[t],
- h = e.getAttrBute("costume" + t);
- i ? (h.addAttrDict("base", i.attr), h.claFinishAttr()) : h.reset();
- }
- e.claFinishAttr(),
- h.default.NotificationCenter.dispatch(
- r.GameNotificationConst.UPDATE_EQUIP_COSTUME_ATTR,
- this._recalMap
- ),
- (this._recalMap.length = 0);
- }
- onLoadView(t) {}
- onOpenView(t) {
- 46 == t.viewId && this.updateCostumeStatisticInfo();
- }
- checkRecommand() {
- const s = this._model,
- o = s.equipItems,
- a = s.items;
- a.sort(c.sortCostume);
- const n = s.recommendItems;
- for (const h in n) n[h] && ((n[h].recommend = !1), (n[h] = null));
- let r = a.length;
- if (0 !== r) {
- let e = 0,
- i = !1;
- for (let t = 0; t < r; t++) {
- const s = a[t],
- r = s.cfg.parts;
- if (!n[r]) {
- var l = o[r];
- if (
- ((!l ||
- s.data.grade > l.data.grade ||
- (s.data.grade === l.data.grade && s.data.lv > l.data.lv)) &&
- ((s.recommend = !0), l !== s && (i = !0), (n[r] = s), e++),
- 3 === e)
- )
- break;
- }
- }
- h.default.RedPointMgr.next(h.default.RedPointMgr.types.RecommendCostume, i);
- }
- }
- checkRedpoint(i = !0) {
- var s = this._model.items;
- let o = s.length;
- const a = {};
- let n = !1;
- for (let e = 0; e < o; e++) {
- const i = s[e],
- o = i.cfg.parts,
- r = i.getMergeCfg();
- let t = 1e4 * o + 1e3 * i.data.grade;
- 1 === r.ingredient_costume_type && (t += i.cfg.idx),
- a[t]
- ? (a[t].list.push(i), a[t].list.length > r.costume_count && (n = !0))
- : (a[t] = {list: [i], cfg: r});
- }
- h.default.RedPointMgr.next(h.default.RedPointMgr.types.MergeCostume, n), i && this.checkRecommand();
- }
- updateMergeInfo() {
- const i = this._model.items;
- let s = i.length;
- const o = {};
- for (let e = 0; e < s; e++) {
- const s = i[e],
- a = s.cfg.parts,
- n = s.getMergeCfg();
- let t = 1e4 * a + 1e3 * s.data.grade;
- 1 === n.ingredient_costume_type && (t += s.cfg.idx),
- o[t] ? o[t].list.push(s) : (o[t] = {list: [s], cfg: n});
- }
- for (const t in o) {
- const i = o[t],
- s = i.list.length > i.cfg.costume_count;
- for (const o of i.list) o.canMerge = s;
- }
- }
- checkIsCanUpgrade(t) {
- t.getMergeCfg().ingredient_costume_type;
- }
- onCloseView(t) {
- (33 != t.viewId && 34 != t.viewId) ||
- (this.costumeInfoView && this.costumeInfoView.isShow() && this.costumeInfoView.updateData());
- }
- updateCostumeStatisticInfo() {
- let i = {},
- s = [];
- for (let t = d.CostumeParts.head; t <= d.CostumeParts.hand; t++) {
- const n = this._model.equipItems[t];
- if (n) {
- let e = d.getGradeIndexByGrade(n.data.grade);
- if ((3 == e && (e--, s.push(n.getSpecialAbilityStr4())), 0 < e))
- for (let t = 0; t <= e; t++) {
- var o = n.cfg[`special_ability${t + 1}_type`],
- a = n.cfg[`special_ability${t + 1}_value`];
- i[o] || (i[o] = {value: 0, gradeIndex: t}), (i[o].value += a);
- }
- }
- }
- var t;
- this.costumeStatisticsView &&
- ((t = this._model.attr.getAttrValue(d.CostumeAbilityType.base, 0)),
- this.costumeStatisticsView.updateUI(i, s, t));
- }
- });
|