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

cc.Class({
    extends: cc.Component,

    properties: {
        upLeft: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        upRight: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        downLeft: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        downRight: {
            default: null,
            type: cc.Node,
            serializable: true,
        },

        farmerUpLeft: {
            default: null,
            tip: "农民图片",
            type: cc.SpriteFrame,
            serializable: true,
            visible: false
        },
        farmerUpRight: {
            default: null,
            tip: "农民图片",
            type: cc.SpriteFrame,
            serializable: true,
            visible: false
        },
        farmerDownLeft: {
            default: null,
            tip: "农民图片",
            type: cc.SpriteFrame,
            serializable: true,
            visible: false
        },
        farmerDownRight: {
            default: null,
            tip: "农民图片",
            type: cc.SpriteFrame,
            serializable: true,
            visible: false
        },


        villageUpLeft: {
            default: null,
            tip: "村长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        villageUpRight: {
            default: null,
            tip: "村长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        villageDownLeft: {
            default: null,
            tip: "村长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        villageDownRight: {
            default: null,
            tip: "村长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },

        mayorUpLeft: {
            default: null,
            tip: "镇长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        mayorUpRight: {
            default: null,
            tip: "镇长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        mayorDownLeft: {
            default: null,
            tip: "镇长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        mayorDownRight: {
            default: null,
            tip: "镇长图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
    },

    onLoad() {
        this.farmerUpLeft = this.upLeft.getComponent(cc.Sprite).spriteFrame;
        this.farmerUpRight = this.upRight.getComponent(cc.Sprite).spriteFrame;
        this.farmerDownLeft = this.downLeft.getComponent(cc.Sprite).spriteFrame;
        this.farmerDownRight = this.downRight.getComponent(cc.Sprite).spriteFrame;
    },

    /**
     * 设置面板信息
     */
    setInfo(_level) {
        // console.log("DynamicLoadingBg,",_level);
        if (0 === _level) {
            this.upLeft.getComponent(cc.Sprite).spriteFrame = this.farmerUpLeft;
            this.upRight.getComponent(cc.Sprite).spriteFrame = this.farmerUpRight;
            this.downLeft.getComponent(cc.Sprite).spriteFrame = this.farmerDownLeft;
            this.downRight.getComponent(cc.Sprite).spriteFrame = this.farmerDownRight;
        } else if (1 === _level) {
            this.upLeft.getComponent(cc.Sprite).spriteFrame = this.villageUpLeft;
            this.upRight.getComponent(cc.Sprite).spriteFrame = this.villageUpRight;
            this.downLeft.getComponent(cc.Sprite).spriteFrame = this.villageDownLeft;
            this.downRight.getComponent(cc.Sprite).spriteFrame = this.villageDownRight;
        } else if (2 === _level) {
            this.upLeft.getComponent(cc.Sprite).spriteFrame = this.mayorUpLeft;
            this.upRight.getComponent(cc.Sprite).spriteFrame = this.mayorUpRight;
            this.downLeft.getComponent(cc.Sprite).spriteFrame = this.mayorDownLeft;
            this.downRight.getComponent(cc.Sprite).spriteFrame = this.mayorDownRight;
        }
    },
});
