FarmLevelUnlockItem.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /** 农场解锁Item */
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class FarmLevelUnlockItem extends cc.Component {
  5. @property({ type: cc.Label, displayName: '状态' })
  6. lbl_State: cc.Label = null;
  7. @property({ type: cc.Label, displayName: '建筑名称' })
  8. lbl_buildName: cc.Label = null;
  9. @property({ type: cc.Sprite, displayName: '建筑图片' })
  10. sp_build: cc.Sprite = null;
  11. itemData = null;
  12. /**
  13. * list_data
  14. * @param data item数据
  15. */
  16. public async setItemData(bData) {
  17. this.itemData = bData;
  18. if (this.itemData.state == 0) {
  19. this.lbl_State.string = '未解锁';
  20. this.lbl_State.node.color = cc.Color.GRAY;
  21. this.sp_build.node.color = cc.Color.BLACK;
  22. }
  23. else {
  24. this.lbl_State.string = '已解锁';
  25. this.lbl_State.node.color = cc.Color.GREEN;
  26. this.sp_build.node.color = cc.Color.WHITE;
  27. }
  28. this.lbl_buildName.string = this.itemData.buildName;
  29. this.sp_build.spriteFrame = await mk.loader.load(this.itemData.buildUrl, cc.SpriteFrame);
  30. }
  31. }