3f370921-7ebd-4276-95fc-f638c7b64b3c.js
10.2 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
"use strict";
cc._RF.push(module, '3f370khfr1CdpX89jjHtks8', 'RewardLevelItem');
// script/game/ui/RewardLevelItem.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 });
exports.CatRewardStatus = exports.rewardType = void 0;
const simba_cc_resutils_1 = require("simba-cc-resutils");
const simba_config_manager_1 = require("simba-config-manager");
const CCDummyObjects_1 = require("../../common/CCDummyObjects");
const GameConstData_1 = require("../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../common/gameplay/managers/UIManager");
const StoryTbl_1 = require("../../config/StoryTbl");
const SuitConfig_1 = require("../../config/SuitConfig");
const BedRoomCatModelManager_1 = require("../model/BedRoomCatModelManager");
const UnlockItemModelManager_1 = require("../model/UnlockItemModelManager");
const UnlockSpecialPlotModelManager_1 = require("../model/UnlockSpecialPlotModelManager");
const PromptAlertDialogViewPresenter_1 = require("./presenter/bedroom/PromptAlertDialogViewPresenter");
var rewardType;
(function (rewardType) {
rewardType[rewardType["catFood"] = 0] = "catFood";
rewardType[rewardType["canned"] = 1] = "canned";
rewardType[rewardType["clothes"] = 2] = "clothes";
rewardType[rewardType["item"] = 3] = "item";
})(rewardType = exports.rewardType || (exports.rewardType = {}));
var CatRewardStatus;
(function (CatRewardStatus) {
CatRewardStatus[CatRewardStatus["unlock"] = 0] = "unlock";
CatRewardStatus[CatRewardStatus["available"] = 1] = "available";
CatRewardStatus[CatRewardStatus["received"] = 2] = "received";
})(CatRewardStatus = exports.CatRewardStatus || (exports.CatRewardStatus = {}));
const { ccclass, property } = cc._decorator;
let RewardLevelItem = /** @class */ (() => {
let RewardLevelItem = class RewardLevelItem extends cc.Component {
constructor() {
super(...arguments);
this.taskDescriptionLabel = CCDummyObjects_1.DummyLabel;
this.rewardItemsNodes = [];
this.rewardIcons = [];
this.rewardLabels = [];
this._itemId = -1;
this._catRewardConfigTpye = -1;
this._btnNumber = -1;
this._rewardBtnStatus = -1;
this._rewardSturcts = [];
}
async setData(catRewardConfigTpye, btnNumber, rewardTaskDescription, rewardSturcts, rewardBtnStatus, callback) {
this._catRewardConfigTpye = catRewardConfigTpye;
this._btnNumber = btnNumber;
this._rewardSturcts = rewardSturcts;
this._rewardBtnStatus = rewardBtnStatus;
this.taskDescriptionLabel.string = rewardTaskDescription;
this._callFunc = callback;
for (let i = 0; i < rewardSturcts.length; i++) {
let path = "";
let number = "";
switch (rewardSturcts[i].type) {
case rewardType.catFood:
path = GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "catfood";
number = "x" + rewardSturcts[i].numberOrId.toString();
break;
case rewardType.canned:
path = GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "canned";
number = "x" + rewardSturcts[i].numberOrId.toString();
break;
case rewardType.clothes:
path = GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + rewardSturcts[i].numberOrId;
number = "x1";
break;
case rewardType.item:
//获取番外Id对应的物品Id
let cfg = undefined;
cfg = simba_config_manager_1.ConfigManager.getConfig(StoryTbl_1.storyTbl, this._rewardSturcts[i].numberOrId);
if (cfg) {
this._itemId = cfg.itemId;
}
path = GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_ITEM_SPR_DIR + this._itemId;
number = "x1";
break;
default:
break;
}
this.rewardIcons[i].spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(path, cc.SpriteFrame);
this.rewardLabels[i].string = number;
this.rewardItemsNodes[i].active = true;
}
this.setBtnStatus();
}
async setBtnStatus() {
this.rewardBtn.node.active = true;
if (this._rewardBtnStatus == CatRewardStatus.unlock) {
this.rewardBtn.getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "lockBtn", cc.SpriteFrame);
}
else if (this._rewardBtnStatus == CatRewardStatus.available) {
this.rewardBtn.getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "receiveBtn", cc.SpriteFrame);
}
else if (this._rewardBtnStatus == CatRewardStatus.received) {
this.rewardBtn.getComponentInChildren(cc.Sprite).spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SPR_DIR + "receivedBtn", cc.SpriteFrame);
}
}
onBtnClick() {
if (this._rewardBtnStatus == CatRewardStatus.unlock) {
UIManager_1.UIManager.showSceneToast("还未解锁,无法领取哦~");
}
else if (this._rewardBtnStatus == CatRewardStatus.available) {
BedRoomCatModelManager_1.BedRoomCatModelManager.changeCatRewardStatus(this._catRewardConfigTpye, this._btnNumber);
this._rewardBtnStatus = CatRewardStatus.received;
this.setBtnStatus();
for (let i = 0; i < this._rewardSturcts.length; i++) {
switch (this._rewardSturcts[i].type) {
case rewardType.catFood:
BedRoomCatModelManager_1.BedRoomCatModelManager.addCatFoodNumberByFoodId(1, this._rewardSturcts[i].numberOrId);
break;
case rewardType.canned:
BedRoomCatModelManager_1.BedRoomCatModelManager.addCatFoodNumberByFoodId(2, this._rewardSturcts[i].numberOrId);
break;
case rewardType.clothes:
let suitConfigs = simba_config_manager_1.ConfigManager.getAllConfig(SuitConfig_1.suitConfig);
let suitId = -1;
let clothingId = this._rewardSturcts[i].numberOrId;
for (let id in suitConfigs) {
if (suitConfigs[id].clothingId == clothingId) {
suitId = suitConfigs[id].suitId;
}
}
BedRoomCatModelManager_1.BedRoomCatModelManager.saveUnlockClothingBySuitId(suitId, clothingId);
this.showAlertDialogView(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + clothingId, "碎片");
break;
case rewardType.item:
//解锁卧室物品
UnlockItemModelManager_1.UnlockItemModelManager.saveItemIdToGameRecord(this._itemId);
//解锁卧室物品的第一个番外
UnlockSpecialPlotModelManager_1.UnlockSpecialPlotModelManager.saveUnlockedSpecialPlotIdByItemIdToGameRecord(this._rewardSturcts[i].numberOrId);
this.showAlertDialogView(GameConstData_1.GameConstData.GAME_CONST_BEDROOMCAT_ITEM_SPR_DIR + this._itemId, "物品");
break;
default:
break;
}
}
UIManager_1.UIManager.showSceneToast("领取成功~");
}
else if (this._rewardBtnStatus == CatRewardStatus.received) {
UIManager_1.UIManager.showSceneToast("已经领取过了哦~");
}
if (this._callFunc) {
this._callFunc();
}
}
showAlertDialogView(path, name) {
let temp = {
iconSpritePath: path,
contentLabel: "恭喜您解锁新" + name + "!!!",
};
UIManager_1.UIManager.pushPresenter(PromptAlertDialogViewPresenter_1.default, temp);
}
getRewardBtnNode() {
return this.rewardBtn.node;
}
};
__decorate([
property({ type: cc.Label, displayName: "Task description labels" })
], RewardLevelItem.prototype, "taskDescriptionLabel", void 0);
__decorate([
property({ type: [cc.Node], displayName: "Reward items" })
], RewardLevelItem.prototype, "rewardItemsNodes", void 0);
__decorate([
property({ type: [cc.Sprite], displayName: "Reward icons" })
], RewardLevelItem.prototype, "rewardIcons", void 0);
__decorate([
property({ type: [cc.Label], displayName: "Reward labels" })
], RewardLevelItem.prototype, "rewardLabels", void 0);
__decorate([
property({ type: cc.Button, displayName: "Reward button" })
], RewardLevelItem.prototype, "rewardBtn", void 0);
RewardLevelItem = __decorate([
ccclass
], RewardLevelItem);
return RewardLevelItem;
})();
exports.default = RewardLevelItem;
cc._RF.pop();