// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        //秘书
        secretary: {
            default: null,
            type: cc.SpriteFrame,
            serializable: true,
        },
        worker: {
            default: null,
            type: cc.SpriteFrame,
            serializable: true,
        },
        businessman: {
            default: null,
            type: cc.SpriteFrame,
            serializable: true,
        },
        player: {
            default: null,
            type: cc.SpriteFrame,
            serializable: true,
        },

        character: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start() {

    },

    // update (dt) {},
    //切换图片
    onSetCharacterSprite(characterType) {
        switch (characterType) {
            case 'secretary':
                this.character.scale = 0.55;
                this.character.getComponent(cc.Sprite).spriteFrame = this.secretary;
                break;
            case 'worker':
                this.character.scale = 0.76;
                this.character.getComponent(cc.Sprite).spriteFrame = this.worker;
                break;
            case 'businessman':
                this.character.scale = 0.76;
                this.character.getComponent(cc.Sprite).spriteFrame = this.businessman;
                break;
            case 'player':
                this.character.scale = 0.76;
                this.character.getComponent(cc.Sprite).spriteFrame = this.player;
                break;
        }
    }
});
