cc.Class({
    extends: cc.Component,

    properties: {
        nodAnimal: cc.Node,
        labNum: cc.Label,
    },

    setNum(str) {
        this.labNum.string = str;
    },

    setSelected() {
        this.labNum.node.active = true;
        this.selected = true;
        this.nodAnimal.scale = 1;
    },

    setUnselected() {
        this.selected = false;
        this.nodAnimal.scale = 0;
    },

    select() {
        if (this.selected) {
            return;
        }

        this.selected = true;
        this.nodAnimal.scale = 0;
        cc.tween(this.nodAnimal)
            .to(0.3, { scale: 1.2 })
            .to(0.1, { scale: 1 })
            .call(() => {
                this.labNum.node.active = true;
            })
            .start();
    },

    unselect() {
        if (!this.selected) {
            return;
        }
        this.selected = false;
        this.nodAnimal.scale = 1;
        this.labNum.node.active = false;
        cc.tween(this.nodAnimal)
            .to(0.1, { scale: 1.2 })
            .to(0.3, { scale: 0 })
            .start();
    },
});
