import { _decorator, Vec3,Node, Sprite, Label} from 'cc';
import ListItem from '../../third/ListItem';
import { ResUtil } from '../../utils/ResUtil';
const { ccclass, property } = _decorator;

//射击界面的任务Item数据
@ccclass('TaskEnemyItem')
export class TaskEnemyItem extends ListItem {
    @property({ type: Sprite, tooltip: "任务敌人头像" })
    public enemy_header: Sprite;
    @property({ type: Label, tooltip: "剩余敌人数量" })
    public num_label: Label;
    @property({ type: Label, tooltip: "敌人名字" })
    public enemy_name_label: Label;

    public data: any = null;

    /**
     * 数据填充 enemyId total count enemyData
     * @param data 敌人数据
     * @param cb 回调
     */
    public  init(data: any,cb?: Function){
        if(!data)return;
        this.data = data;
        //敌人头像
        ResUtil.setSpriteFrame(data.enemyData.headshot,this.enemy_header);
        //剩余敌人数量
        this.num_label.string = `${data.count} / ${data.total}`;
        //敌人名字
        this.enemy_name_label.string = data.enemyData.name_lang;
    }
}