c2dfdd08-ee66-4a46-8bd8-b1e6e3d2a190.js
12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
"use strict";
cc._RF.push(module, 'c2dfd0I7mZKRovYsebj0qGQ', 'WardrobeViewPresenter');
// script/game/ui/presenter/bedroom/WardrobeViewPresenter.ts
"use strict";
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 });
const simba_cc_resutils_1 = require("simba-cc-resutils");
const PresenterBase_1 = require("../../../../common/classbase/PresenterBase");
const GameConstData_1 = require("../../../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../../../common/gameplay/managers/UIManager");
const GameConfig_1 = require("../../../../GameConfig");
const BedRoomCatModelManager_1 = require("../../../model/BedRoomCatModelManager");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const SuitItem_1 = require("../../SuitItem");
const WardrobeView_1 = require("../../view/type/WardrobeView");
const AlertDialogViewPresenter_1 = require("../AlertDialogViewPresenter");
let WardrobeViewPresenter = /** @class */ (() => {
let WardrobeViewPresenter = class WardrobeViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this._suitId = 0;
this._nextStep = -1;
this._wardrobeIntroductionString = "通过完成任务,收集碎片,收集完所有碎片就可以解锁梵优的新衣服啦!";
this.onWearBtnClickCallBack = () => {
BedRoomCatModelManager_1.BedRoomCatModelManager.changeUsingSuitId(this._suitId);
this.checkWearBtnStatus(this._suitId);
UIManager_1.UIManager.showSceneToast("已穿戴当前套装,约会人物立绘将替换为当前套装!", 0.5);
let isShow = BedRoomCatModelManager_1.BedRoomCatModelManager.checkIsShowSuitShareBtnBySuitId(this._suitId);
if (isShow) {
this.onShareBtnClickCallBack();
}
};
this.onShareBtnClickCallBack = () => {
let temp = {
dataptr: { bgPath: GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wardrobeBg", rolePath: GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + this._suitId },
titlecontent: "提示",
content: "小主穿戴了服装,快去分享给小伙伴吧,分享可得4个猫粮哦~",
ishasad: false,
istwobtn: true,
adconfig: "default",
hasBanner: false,
callback: (type, ret) => {
if (ret || GameConfig_1.channel === "dummy") {
//保存分享存档
BedRoomCatModelManager_1.BedRoomCatModelManager.saveSuitShareStatusBySuitId(this._suitId);
this.checkShareBtnStatus(this._suitId);
//分享奖励
BedRoomCatModelManager_1.BedRoomCatModelManager.addCatFoodNumberByFoodId(1, 4);
UIManager_1.UIManager.showSceneToast("猫粮数量+4");
}
},
isShareScreen: true
};
UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
};
this.onTabBtnClickCallBack = async (suitId) => {
this._suitId = suitId;
this.view.getStayTunedNode().active = false;
this.view.getScrollViewContentNode().removeAllChildren();
let suitButtons = this.view.getSuitButtons();
for (let i = 0; i < suitButtons.length; i++) {
if (i == suitId - 1) {
suitButtons[i].normalSprite = this.view.getSuitButtonSprites()[1];
}
else {
suitButtons[i].normalSprite = this.view.getSuitButtonSprites()[0];
}
}
for (let i = 0; i < suitButtons.length; i++) {
if (i == suitId - 1) {
suitButtons[i].getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "tabBtn", cc.SpriteFrame);
}
else {
suitButtons[i].getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "tabBtnGray", cc.SpriteFrame);
}
}
//套装3为未开发套装,暂时特殊处理
if (suitId == 3) {
this.view.getStayTunedNode().active = true;
this.view.getWearBtn().node.active = false;
this.view.getShareBtn().node.active = false;
this.view.getRolePortrait().node.active = false;
this.view.getRolePortraitLock().node.active = true;
this.view.getRolePortraitLockLabel().string = "敬请期待";
this.view.getRolePortrait().spriteFrame = undefined;
this.view.getRolePortraitLock().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + "3lock", cc.SpriteFrame);
return;
}
//套装1居中适配,在前后各加一个空的预制体
if (suitId == 1) {
let item = cc.instantiate(this.view.getSuitItemNull());
item.parent = this.view.getScrollViewContentNode();
}
let suitConfigs = BedRoomCatModelManager_1.BedRoomCatModelManager.getSuitConfigBySuitId(suitId);
for (let i = 0; i < suitConfigs.length; i++) {
let item = cc.instantiate(this.view.getSuitItem());
if (suitConfigs[i].isUnlock) {
BedRoomCatModelManager_1.BedRoomCatModelManager.saveUnlockClothingBySuitId(suitConfigs[i].suitId, suitConfigs[i].clothingId);
}
let unlockClothing = BedRoomCatModelManager_1.BedRoomCatModelManager.getUnlockClothingBySuitId(suitId);
let showLockRootNode = unlockClothing.indexOf(suitConfigs[i].clothingId) == -1;
item.getComponent(SuitItem_1.default).setData(suitConfigs[i], showLockRootNode);
item.parent = this.view.getScrollViewContentNode();
}
//套装1居中适配,在前后各加一个空的预制体
if (suitId == 1) {
let item = cc.instantiate(this.view.getSuitItemNull());
item.parent = this.view.getScrollViewContentNode();
}
this.checkWearBtnStatus(suitId);
this.checkShareBtnStatus(suitId);
this.updateRedDot();
};
this.onBackBtnClickCallBack = () => {
this.view.close();
};
}
onOpen(props) {
super.onOpen(props);
this._viewProps = props;
this._viewProps.onWearBtnClickCallBack = this.onWearBtnClickCallBack;
this._viewProps.onShareBtnClickCallBack = this.onShareBtnClickCallBack;
this._viewProps.onTabBtnClickCallBack = this.onTabBtnClickCallBack;
this._viewProps.onBackBtnClickCallBack = this.onBackBtnClickCallBack;
this.view.setProps(this._viewProps);
this.onShow();
}
onShow() {
super.onShow();
this.setIntroductionIconTouchEvent();
this.onTabBtnClickCallBack(1);
}
onClose() {
super.onClose();
}
onEnterBackground() {
super.onEnterBackground();
}
onEnterForeground() {
super.onEnterForeground();
}
setIntroductionIconTouchEvent() {
let introductionIconNode = this.view.getIntroductionIconNode();
let introductionNode = this.view.getIntroductionNode();
introductionIconNode.on(cc.Node.EventType.TOUCH_START, function (event) {
introductionNode.active = true;
}, this);
introductionIconNode.on(cc.Node.EventType.TOUCH_END, function (event) {
introductionNode.active = false;
}, this);
introductionIconNode.on(cc.Node.EventType.TOUCH_CANCEL, function (event) {
introductionNode.active = false;
}, this);
}
updateRedDot() {
for (let i = 1; i < 4; i++) {
let suitStatus = BedRoomCatModelManager_1.BedRoomCatModelManager.checkSuitStatus(i);
let suitIsClicked = BedRoomCatModelManager_1.BedRoomCatModelManager.getSuitIsClicked(i);
if (suitStatus !== BedRoomCatModelManager_1.SuitStatus.Lock && !suitIsClicked) {
this.view.getRedDotNodes()[i - 1].active = true;
}
else {
this.view.getRedDotNodes()[i - 1].active = false;
}
}
}
async checkWearBtnStatus(suitId) {
let suitStatus = BedRoomCatModelManager_1.BedRoomCatModelManager.checkSuitStatus(suitId);
if (suitStatus !== BedRoomCatModelManager_1.SuitStatus.Lock) {
BedRoomCatModelManager_1.BedRoomCatModelManager.saveSuitIsClicked(suitId);
}
switch (suitStatus) {
case BedRoomCatModelManager_1.SuitStatus.Lock:
this.view.getWearBtn().node.active = false;
this.view.getRolePortrait().node.active = false;
this.view.getRolePortraitLock().node.active = true;
this.view.getRolePortraitLockLabel().string = "收集完所有碎片才可解锁哦";
this.view.getRolePortrait().spriteFrame = undefined;
this.view.getRolePortraitLock().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId + "lock", cc.SpriteFrame);
break;
case BedRoomCatModelManager_1.SuitStatus.Unlock:
this.view.getWearBtn().node.active = true;
this.view.getWearBtn().interactable = true;
this.view.getRolePortrait().node.active = true;
this.view.getRolePortraitLock().node.active = false;
this.view.getRolePortrait().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId, cc.SpriteFrame);
this.view.getRolePortraitLock().spriteFrame = undefined;
this.view.getWearBtn().getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wearBtn", cc.SpriteFrame);
break;
case BedRoomCatModelManager_1.SuitStatus.Wear:
this.view.getWearBtn().node.active = true;
this.view.getWearBtn().interactable = false;
this.view.getRolePortrait().node.active = true;
this.view.getRolePortraitLock().node.active = false;
this.view.getRolePortrait().spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitId, cc.SpriteFrame);
this.view.getRolePortraitLock().spriteFrame = undefined;
this.view.getWearBtn().getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "wearedBtn", cc.SpriteFrame);
break;
default:
break;
}
}
checkShareBtnStatus(suitId) {
let isShow = BedRoomCatModelManager_1.BedRoomCatModelManager.checkIsShowSuitShareBtnBySuitId(suitId);
this.view.getShareBtn().node.active = isShow;
}
};
WardrobeViewPresenter.uuid = "WardrobeViewPresenter";
WardrobeViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(WardrobeView_1.WardrobeViewType)
], WardrobeViewPresenter);
return WardrobeViewPresenter;
})();
exports.default = WardrobeViewPresenter;
cc._RF.pop();