import { uimanger } from '../UIManger'; import { ChooseHeroUpdate } from './ChooseHeroUpdate'; import { ChooseHeroUpQuality } from './ChooseHeroUpQuality'; const { ccclass, property } = cc._decorator; export enum TRAINBLOCKSTATUS { NULL = 'null', // LOCKED = 'locked', FREE = 'free', TRAINING = 'training', COMPLETE = 'complete', } export enum BoxType { UpLevel, UpQuality, } @ccclass export default class Academy_block extends cc.Component { @property(cc.Node) bg: cc.Node = null; @property(cc.Node) addsign: cc.Node = null; @property(cc.Label) title: cc.Label = null; @property(cc.Label) timeLabel: cc.Label = null; @property(cc.Node) okTag: cc.Node = null; @property([cc.SpriteFrame]) allbgs: cc.SpriteFrame[] = []; // 0 null 1 finish 2 training @property({ type: cc.Enum(BoxType) }) boxtype: BoxType = BoxType.UpLevel; public status = TRAINBLOCKSTATUS.FREE; protected onLoad(): void { this.setStatus(this.status); } 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.addsign.active = true; this.title.string = 'FREE'; this.timeLabel.node.active = false; this.okTag.active = false; break; case TRAINBLOCKSTATUS.TRAINING: this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[2]; this.addsign.active = false; this.title.string = 'TRAINING'; this.timeLabel.node.active = true; this.okTag.active = false; break; case TRAINBLOCKSTATUS.COMPLETE: this.bg.getComponent(cc.Sprite).spriteFrame = this.allbgs[1]; this.addsign.active = false; this.title.string = 'FINISH'; this.timeLabel.string = '00:00:00'; this.okTag.active = true; break; } } onClick(event, param) { var data = { boxIndex: param, }; switch (this.status) { case TRAINBLOCKSTATUS.FREE: if (this.boxtype == BoxType.UpLevel) { uimanger.showUI(ChooseHeroUpdate.prefabPath, data); } else { uimanger.showUI(ChooseHeroUpQuality.prefabPath, data); } break; case TRAINBLOCKSTATUS.TRAINING: break; case TRAINBLOCKSTATUS.COMPLETE: break; } } }