| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /**
- * 货币类型,游戏币为默认
- */
- var CurrencyType = cc.Enum({
- GAME: 0,
- CNT: 1,
- SNB: 2
- });
- cc.Class({
- extends: cc.Component,
- properties: {
- Name: {
- default: '',
- tooltip: '建筑名称',
- },
- Price: {
- default: '',
- tooltip: '需要金币的价格',
- },
- DiamondPrice: {
- default: 1,
- type: cc.Integer,
- tooltip: '需要钻石的价格',
- },
- CNT: {
- default: '',
- tooltip: '需要CNT货币的价格',
- },
- SNB: {
- default: '',
- tooltip: '需要SNB货币的价格',
- },
- Synopsis: {
- default: '',
- tooltip: '简介',
- },
- //消耗的货币类型,默认是游戏币
- consumeType: {
- default: CurrencyType.GAME,
- type: cc.Enum(CurrencyType),
- 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);
- if (parseInt(NumLabel.string) < 1) {
-
- switch (this.consumeType) {
- /**
- * todo 目前只有特殊购买开放购买
- */
- case CurrencyType.CNT:
- case CurrencyType.SNB:
- console.warn("Content_Button 不需要购买!");
- // GlobalD.game._ManageUIScript.onPurchaseTips(this);
- break;
- default:
- console.warn("Content_Button 不需要购买!");
- break;
- }
- // GlobalD.game._ManageUIScript.onPurchaseTips(this);
- return;
- }
- }
- }
- let item = { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis };
- switch (this.consumeType) {
- case CurrencyType.CNT:
- item.Price = this.CNT;
- break;
- case CurrencyType.SNB:
- item.Price = this.SNB;
- break;
- default:
- item.Price = this.Price;
- break;
- }
- GlobalD.game._ManageUIScript.onSetButtonState({ Target: this },item);
- },
- onPressedInfo(event, customEventData) {
- let item = { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis };
- switch (this.consumeType) {
- case CurrencyType.CNT:
- item.Price = this.CNT;
- break;
- case CurrencyType.SNB:
- item.Price = this.SNB;
- break;
- default:
- item.Price = this.Price;
- break;
- }
- GlobalD.game._ManageUIScript.onSetButtonInfoState({ Target: this }, item );
- }
- });
|