import { StageAttr } from "../../../data/udata/Player";
import StageInfo from "./StageInfo";

/**
 * 道具奖励节点
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class StageInfoGood extends cc.Component {

    @property(cc.Sprite)
    mIcon: cc.Sprite = null;

    @property(cc.Label)
    mGoodCount: cc.Label = null;

    public stageInfo:StageInfo = null;

    onLoad () {
        let goods = this.stageInfo.getGoods();
        

       

        for (let i = 0; i < goods.length; i++) {
            const element = goods[i];
            
        }

    }
    /**
     * 完成的数量
     */
    private getCount(id:number):number{
        let player = this.stageInfo.main.player;
        let stage = player.stage;
        let stageAttr:StageAttr = stage[''+this.stageInfo.stageData.id];
        if(stageAttr == null){
            return 0;
        }
        if(stageAttr.goods == null){
            return 0;
        }
        for (let i = 0; i < stageAttr.goods.length; i++) {
            const element = stageAttr.goods[i];
            if(element.id == id){
                return element.count;
            }
        }
        return 0;
    }


}
