const { ccclass, property } = cc._decorator;

@ccclass
export default class LotteryItem extends cc.Component {

    labelNormal: cc.Label = null;
    labelBottom: cc.Label = null;
    labelPrize: cc.Label = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
    }

    loadData(normal, prize) {
        this.labelNormal = this.node.getChildByName("labelNormal").getComponent(cc.Label)
        this.labelBottom = this.node.getChildByName("labelBottom").getComponent(cc.Label)
        this.labelPrize = this.node.getChildByName("labelPrize").getComponent(cc.Label)
        this.labelNormal.string = normal
        this.labelBottom.string = normal + "奖"
        this.labelPrize.string = prize
    }

    start() {

    }

    showNormal() {
        this.labelNormal.node.active = true
        this.labelBottom.node.active = false
        this.labelPrize.node.active = false
    }

    showResult() {
        this.node.scaleX = 1
        this.node.runAction(cc.sequence(
            cc.scaleTo(0.2, 0, 1),
            cc.callFunc(() => {
                this.labelNormal.node.active = false
                this.labelBottom.node.active = true
                this.labelPrize.node.active = true
            }),
            cc.scaleTo(0.2, 1, 1)
        ))
    }

    setHL() {
        this.node.color = new cc.Color(255, 255, 51, 255)
        this.labelNormal.node.color = new cc.Color(239, 51, 51, 255)
    }

    reset() {
        this.node.color = new cc.Color(255, 255, 255, 255)
        this.labelNormal.node.color = new cc.Color(51, 51, 51, 255)
    }
    // update (dt) {}
}
