SuitItem.ts
1.56 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
import { ResUtils } from "simba-cc-resutils";
import { DummyLabel, DummyNode, DummySprite } from "../../common/CCDummyObjects";
import { GameConstData } from "../../common/gameplay/gamedata/GameConstData";
import { UIManager } from "../../common/gameplay/managers/UIManager";
import { SuitConfig } from "../model/BedRoomCatModelManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SuitItem extends cc.Component {
@property({ type: cc.Sprite, displayName: "Icon sprite" })
iconSprite: cc.Sprite = DummySprite;
@property({ type: cc.Label, displayName: "Name label" })
nameLabel: cc.Label = DummyLabel;
@property({ type: cc.Node, displayName: "Lock root node" })
lockRootNode: cc.Node = DummyNode;
@property({ type: cc.Label, displayName: "Unlock condition label" })
unlockConditionLabel: cc.Label = DummyLabel;
private _showLockRootNode: boolean = true;
async setData(suitConfig: SuitConfig, showLockRootNode: boolean) {
this.iconSprite.spriteFrame = await ResUtils.loadRes(GameConstData.GAME_CONST_BEDROOMCAT_SUIT_SPR_DIR + suitConfig.clothingId, cc.SpriteFrame)
this.nameLabel.string = suitConfig.clothingName;
this._showLockRootNode = showLockRootNode;
if (showLockRootNode) {
this.lockRootNode.active = true;
this.unlockConditionLabel.string = suitConfig.unlockCondition;
}
}
onBtnClick() {
if (this._showLockRootNode) {
UIManager.showToast("快去完成任务,领取服装吧!");
return;
}
}
}