import { Label } from 'cc';
import { Sprite } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { TD } from '../../../App';
import TbResource, { IconTypeEnum } from '../../../tools/TbResource';
const { ccclass, property } = _decorator;

@ccclass('ResourceIcon')
export class ResourceIcon extends Component {

    //资源品质
    @property(Sprite)
    quality:Sprite;

    //资源图标
    @property(Sprite)
    icon:Sprite;

    //资源数量
    @property(Label)
    num:Label;

    //设置icon
    set(id:number,value:number){

        let config = TD.TbGResource.get(id);

        //设置ICON
        TbResource.loadSpriteIcon(IconTypeEnum.资源,config.icon,this.icon,this);
        //设置品质
        TbResource.loadSpriteIcon(IconTypeEnum.品质,config.quality,this.quality,this);

        this.num.string = ``;
        if(value > 1){
            //显示数量
            this.num.string = `${value}`;
        }

    }

}


