
cc.Class({
    extends: cc.Component,

    properties: {
        //建筑底下碰撞区域
        Red: {
            // ATTRIBUTES:
            default: null,        // The default value will be used only when the component attaching
            // to a node for the first time
            type: cc.SpriteFrame, // optional, default is typeof default
            serializable: true,   // optional, default is true
        },
        Green: {
            // ATTRIBUTES:
            default: null,        // The default value will be used only when the component attaching
            // to a node for the first time
            type: cc.SpriteFrame, // optional, default is typeof default
            serializable: true,   // optional, default is true
        },
        Tip: cc.Sprite,

        //如果是数组
        isChildenArray: false,


        //建筑对周围的影响力
        effectYellow: {
            // ATTRIBUTES:
            default: null,
            type: cc.SpriteFrame,
            serializable: true,
        },
        effectGreen: {
            // ATTRIBUTES:
            default: null,        // The default value will be used only when the component attaching
            // to a node for the first time
            type: cc.SpriteFrame, // optional, default is typeof default
            serializable: true,   // optional, default is true
        },
    },

    //设置红色提示
    onSetRedSpriteFrame(_opacity) {
        if (_opacity)
            this.Tip.node.opacity = _opacity;
        if (this.isChildenArray) {
            let TipArray = this.node.children;
            // cc.log(TipArray)
            let length = TipArray.length;
            for (let i = 0; i < length; i++) {
                TipArray[i].getComponent(cc.Sprite).spriteFrame = this.Red;
            }
        } else {
            this.Tip.spriteFrame = this.Red;
        }
    },


    //重新设置图片
    onReset() {
        this.Tip.node.scale = 1;
        // this.Tip.node.color.setA(1);
        this.Tip.node.opacity = 230;
        if (this.isChildenArray) {

            let TipArray = this.node.children;
            let length = TipArray.length;
            for (let i = 0; i < length; i++) {
                TipArray[i].getComponent(cc.Sprite).spriteFrame = this.Green;

            }
        } else {
            this.Tip.spriteFrame = this.Green;
        }
    },


    //设置影响力黄色
    onSetEffectYellowSpriteFrame() {
        this.Tip.spriteFrame = this.effectYellow;
        this.Tip.node.scale = 0.8;
        // this.Tip.node.color.setA(0.5);
        this.Tip.node.opacity = 200;
    },

    //设置影响力 绿色
    onSetEffectGreenSpriteFrame() {
        this.Tip.spriteFrame = this.effectGreen;
        this.Tip.node.scale = 0.8;
        // this.Tip.node.color.setA(0.5);
        this.Tip.node.opacity = 200;
    },
});
