Content_Button.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. Name: {
  5. default: '',
  6. tooltip: '建筑名称',
  7. },
  8. Price: {
  9. default: '',
  10. tooltip: '需要金币的价格',
  11. },
  12. DiamondPrice: {
  13. default: 1,
  14. type:cc.Integer,
  15. tooltip: '需要钻石的价格',
  16. },
  17. Synopsis: {
  18. default: '',
  19. tooltip: '简介',
  20. },
  21. clickEvents: {
  22. default: [],
  23. type: cc.Component.EventHandler,
  24. tooltip: CC_DEV && 'i18n:COMPONENT.button.click_events',
  25. }
  26. },
  27. onPressed() {
  28. let NameNode = this.node.getChildByName('Name');
  29. if (NameNode) {
  30. let Num = NameNode.getChildByName('Num');
  31. if (Num) {
  32. let NumLabel = Num.getComponent(cc.Label);
  33. // cc.log('NumLabel='+NumLabel.string);
  34. if (parseInt(NumLabel.string) < 1) {
  35. //this is Content_Button
  36. GlobalD.game._ManageUIScript.onPurchaseTips(this);
  37. return;
  38. }
  39. }
  40. }
  41. // GlobalD.game._ManageUIScript.onPurchaseTips(this.node.name);
  42. // return;
  43. GlobalD.game._ManageUIScript.onSetButtonState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
  44. },
  45. onPressedInfo(event, customEventData) {
  46. GlobalD.game._ManageUIScript.onSetButtonInfoState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
  47. }
  48. });