CheckButton.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import SetGray from "../../component/SetGray";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class Turnable extends cc.Component {
  5. @property({displayName: '选中节点', type: cc.Node})
  6. private node_choose: cc.Node = null;
  7. @property({displayName: '未选中节点', type: cc.Node})
  8. private node_noChoose: cc.Node = null;
  9. @property({displayName: '显示次数', type: cc.Label})
  10. private lbl_times: cc.Label = null;
  11. @property({displayName: '显示金额', type: cc.Label})
  12. private lbl_value: cc.Label = null;
  13. private isCanNotChoose: boolean = false;
  14. private data = null;
  15. public setShowUI(data):boolean
  16. {
  17. this.data = data;
  18. let haveTimes = data.cashFrequency - gData.gameData.playerProp.getRedMoneyCashOutTimesByIndex(data.index);
  19. this.lbl_times.string = `剩${haveTimes}次`;
  20. this.lbl_value.string = (data.money/100) + '元';
  21. return haveTimes > 0;
  22. }
  23. public setIsChoose(isChoose: boolean)
  24. {
  25. if(this.isCanNotChoose)
  26. {
  27. return;
  28. }
  29. this.node_choose.active = isChoose;
  30. this.node_noChoose.active = !isChoose;
  31. }
  32. public setIsCanNotChoose()
  33. {
  34. this.isCanNotChoose = true;
  35. this.node_choose.active = true;
  36. this.node_noChoose.active = false;
  37. let com = this.node_choose.getComponent(SetGray);
  38. com.setGray(true);
  39. }
  40. public getIsCanNotChoose()
  41. {
  42. return this.isCanNotChoose;
  43. }
  44. public setRemaineTimes(): boolean
  45. {
  46. let haveTimes = gData.gameData.playerProp.getRedMoneyCashOutTimesByIndex(this.data.index);
  47. let remainTimes = this.data.cashFrequency- haveTimes;
  48. this.lbl_times.string = `剩${remainTimes}次`;
  49. if(remainTimes <= 0)
  50. {
  51. this.setIsCanNotChoose();
  52. return true;
  53. }
  54. return false;
  55. }
  56. }