CheckButton.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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)
  16. {
  17. this.data = data;
  18. this.lbl_times.string = data.cashFrequency.toString();
  19. this.lbl_value.string = (data.money/100).toString();
  20. }
  21. public setIsChoose(isChoose: boolean)
  22. {
  23. if(this.isCanNotChoose)
  24. {
  25. return;
  26. }
  27. this.node_choose.active = isChoose;
  28. this.node_noChoose.active = !isChoose;
  29. }
  30. public setIsCanNotChoose()
  31. {
  32. this.isCanNotChoose = true;
  33. this.node_choose.active = true;
  34. this.node_noChoose.active = false;
  35. let com = this.node_choose.getComponent(SetGray);
  36. com.setGray(true);
  37. }
  38. public getIsCanNotChoose()
  39. {
  40. return this.isCanNotChoose;
  41. }
  42. public setRemaineTimes(times: number)
  43. {
  44. this.lbl_times.string = times.toString();
  45. if(times <= 0)
  46. {
  47. this.setIsCanNotChoose();
  48. }
  49. }
  50. }