
cc.Class({
    extends: cc.Component,

    properties: {
        cityPic: cc.Sprite,
        current: cc.Node,
        locked: cc.Node,
        nameLabel: cc.Label,
    },

    // onLoad () {},


    init(info) {
        cc.loader.loadRes('./map/' + info.picId, cc.SpriteFrame, (err, spriteFrame) => {
            this.cityPic.spriteFrame = spriteFrame;
        });

        this.nameLabel.string = info.name;

        if (info.selected) {
            this.current.active = true;
            this.locked.active = false;
            this.cityPic.node.active = false;
        } else if (info.unlock) {
            this.current.active = false;
            this.locked.active = false;
            this.cityPic.node.active = true;
        } else {
            this.cityPic.node.active = false;
            this.current.active = false;
            this.locked.active = true;
        }
    },

    start() {

    },

    fakeLock() {
        this.current.active = false;
        this.locked.active = true;
        this.cityPic.node.active = false;
    },

    fakeUnLock() {
        this.current.active = true;
        this.locked.active = false;
        this.cityPic.node.active = false;
    },

    fakeCurrent(){
        this.current.active = true;
        this.locked.active = false;
        this.cityPic.node.active = false;
    },

    showFinishAnimation(cb) {
        this.current.active = false;
        this.locked.active = false;
        this.cityPic.node.active = true;
        this.cityPic.node.setScale(0);

        let end = cc.callFunc(() => {
            this.current.active = false;
            cb();
        }, this);
        let scale = cc.sequence(cc.scaleTo(0.3, 1, 1).easing(cc.easeBackOut()), end);
        this.cityPic.node.runAction(scale);
    },

    // update (dt) {},
});
