SignItem.ts
2.09 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
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { tMgr } from "../Global";
import { SignTable, TableName } from "../kernel/table/TableDefine";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SignItem extends cc.Component {
private _day: number;
setDay(day: number) {
this._day = day;
let config = tMgr.getConfig(TableName.SIGN, day) as SignTable;
// this.node.getChildByName('txtTitle').getComponent(Label).string = '第' + day.toString() + '天';
this.node.getChildByName('txtNum').getComponent(cc.Label).string = config.Num.toString();
let color = cc.color();
color.fromHEX('#946648');
this.node.getChildByName('imgTitle').color = color;
if (this._day < 7) {
cc.resources.load(config.Icon, cc.SpriteFrame, (error, asset) => {
if (!error) {
this.node.getChildByName('icon').getComponent(cc.Sprite).spriteFrame = asset as cc.SpriteFrame;
}
})
}
}
setCurrent(flag: boolean) {
if (this._day > 6) {
return;
}
this.node.getChildByName('imgNormal').active = !flag;
this.node.getChildByName('imgCur').active = flag;
if (flag) {
let color = cc.color();
color.fromHEX('#357c44');
this.node.getChildByName('imgTitle').color = color;
}
}
setLock(flag: boolean) {
// if (this._day > 6) {
// this.node.getChildByName('imgNormal').getComponent(cc.Button).interactable = !flag;
// }
// else {
this.node.getChildByName('imgMask').active = flag;
if (flag) {
let color = cc.color();
color.fromHEX('#4a4556');
this.node.getChildByName('imgTitle').color = color;
}
// }
}
}