cc.Class({
    extends: cc.Component,

    properties: {
        Name: {
            default: '',
            tooltip: '建筑名称',
        },
        Price: {
            default: '',
            tooltip: '需要金币的价格',
        },
        DiamondPrice: {
            default: 1,
            type:cc.Integer,
            tooltip: '需要钻石的价格',
        },
        Synopsis: {
            default: '',
            tooltip: '简介',
        },

        clickEvents: {
            default: [],
            type: cc.Component.EventHandler,
            tooltip: CC_DEV && 'i18n:COMPONENT.button.click_events',
        }
    },
    onPressed() {

        let NameNode = this.node.getChildByName('Name');
        if (NameNode) {
            let Num = NameNode.getChildByName('Num');

            if (Num) {
                let NumLabel = Num.getComponent(cc.Label);
                // cc.log('NumLabel='+NumLabel.string);
                if (parseInt(NumLabel.string) < 1) {

                    //this is Content_Button
                    GlobalD.game._ManageUIScript.onPurchaseTips(this);
                    return;
                }
            }
        }
        // GlobalD.game._ManageUIScript.onPurchaseTips(this.node.name);
        // return;
        GlobalD.game._ManageUIScript.onSetButtonState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
    },
    onPressedInfo(event, customEventData) {
        GlobalD.game._ManageUIScript.onSetButtonInfoState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
    }
});
