CheckButton.ts 1.4 KB

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