FarmLevelStoreItem.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /** 农场仓库Item */
  2. import { ProductType } from "../../../game/data/GameData";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class FarmLevelStoreItem extends cc.Component {
  6. @property({ type: cc.Label, displayName: '数量' })
  7. lbl_num: cc.Label = null;
  8. @property({ type: cc.Sprite, displayName: '物品名称' })
  9. sp_name: cc.Sprite = null;
  10. @property({ type: cc.Sprite, displayName: '物品图片' })
  11. sp_food: cc.Sprite = null;
  12. itemData = null;
  13. /**
  14. * list_data
  15. * @param data item数据
  16. */
  17. public async setItemData(bData) {
  18. let times = gData.gameData.getProductMakeTimesById(bData.picture);
  19. this.lbl_num.string = `${times}`;
  20. let plantPath = '';
  21. let namePath = '';
  22. if (bData.tab == ProductType.nzw) {
  23. plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
  24. namePath = 'game/coregame/texture/plant_icons/nameIcon/plant_name_';
  25. }
  26. else {
  27. plantPath = 'game/coregame/texture/factory_icons/factory_';
  28. namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
  29. }
  30. this.sp_food.spriteFrame = await mk.loader.load(plantPath + bData.picture, cc.SpriteFrame);
  31. this.sp_name.spriteFrame = await mk.loader.load(namePath + bData.picture, cc.SpriteFrame);
  32. }
  33. }