import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
import { zhao_xi_jie_item_data } from '../../../data/data';
import { gameManager } from '../gameManager';
const { ccclass, property } = _decorator;

@ccclass('shouji_item')
export class shouji_item extends Component {
    @property(Node) spr_select_status:Node = null;
    @property(Node) icon:Node = null;
    private mData:zhao_xi_jie_item_data = null;
    private mCallBack = null;
    public initSingleTipView(data:zhao_xi_jie_item_data,call){
        this.mData = data;
        this.mCallBack = call;
        this.node.on(Node.EventType.TOUCH_START,()=>{
            if(this.mCallBack!=null){
                this.mCallBack(this)
            }
        })
        this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.mData.res);
    }

    public initAllTipView(data:zhao_xi_jie_item_data){
        this.mData = data;
        this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.mData.res);
    }

    public getData(){
        return this.mData;
    }

    public onSelect(){
        this.spr_select_status.active = true;
    }

    public unSelect(){
        this.spr_select_status.active = false;
    }

    public showTipIcon(){
        this.icon.active = true;
    }
}


