69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
const { ccclass, property } = cc._decorator;
|
|
|
|
// 训练盒状态
|
|
export enum TRAINBLOCKSTATUS {
|
|
NULL = 'null',
|
|
LOCKED = 'locked',
|
|
FREE = 'free',
|
|
TRAINING = 'training',
|
|
COMPLETE = 'complete',
|
|
}
|
|
|
|
@ccclass
|
|
export default class Academy_block extends cc.Component {
|
|
@property(cc.Node) bg: cc.Node = null;
|
|
@property(cc.Node) sign: cc.Node = null;
|
|
@property(cc.Label) title: cc.Label = null;
|
|
@property(cc.Node) okTag: cc.Node = null;
|
|
|
|
@property([cc.SpriteFrame]) allbgs: cc.SpriteFrame[] = []; // 0 null 1 finish 2 training
|
|
|
|
public status = TRAINBLOCKSTATUS.NULL;
|
|
|
|
setStatus(status: TRAINBLOCKSTATUS) {
|
|
switch (status) {
|
|
case TRAINBLOCKSTATUS.LOCKED:
|
|
// 未解锁
|
|
this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[0];
|
|
this.okTag.active = false;
|
|
this.title.string = 'ADD NEW TRAINING ROOM';
|
|
break;
|
|
case TRAINBLOCKSTATUS.FREE:
|
|
// 空闲
|
|
this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[0];
|
|
this.okTag.active = false;
|
|
this.title.string = 'FREE';
|
|
break;
|
|
case TRAINBLOCKSTATUS.TRAINING:
|
|
// 升级中
|
|
this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[2];
|
|
this.okTag.active = false;
|
|
this.title.string = 'TRAINING';
|
|
break;
|
|
case TRAINBLOCKSTATUS.COMPLETE:
|
|
// 升级完成
|
|
this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[1];
|
|
this.okTag.active = true;
|
|
this.title.string = 'TRAINING COMPLETE';
|
|
break;
|
|
}
|
|
}
|
|
|
|
onClick() {
|
|
switch (this.status) {
|
|
case TRAINBLOCKSTATUS.LOCKED:
|
|
// 未解锁
|
|
break;
|
|
case TRAINBLOCKSTATUS.FREE:
|
|
// 空闲
|
|
break;
|
|
case TRAINBLOCKSTATUS.TRAINING:
|
|
// 升级中
|
|
break;
|
|
case TRAINBLOCKSTATUS.COMPLETE:
|
|
// 升级完成
|
|
break;
|
|
}
|
|
}
|
|
}
|