car_info_shuxing.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { car_item_data } from '../../data';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('car_info_shuxing')
  5. export class car_info_shuxing extends Component {
  6. @property(Node) node_chongci:Node = null
  7. @property(Node) lab_chongci:Node = null
  8. @property(Node) node_qiyou:Node = null
  9. @property(Node) lab_qiyou:Node = null
  10. @property(Node) node_dunpai:Node = null
  11. @property(Node) lab_dunpai:Node = null
  12. @property(Node) node_xingxing:Node = null
  13. @property(Node) lab_xingxing:Node = null
  14. @property(Node) node_citie:Node = null
  15. @property(Node) lab_citie:Node = null
  16. @property(Node) lab_no_shuxing:Node = null
  17. initView(data:car_item_data) {
  18. let count = 0
  19. if(data.attribute.k_sprint_cd<=0) {
  20. this.node_chongci.active = false
  21. } else {
  22. count+=1
  23. this.lab_chongci.getComponent(Label).string = `+${data.attribute.k_sprint_cd}秒`
  24. }
  25. if(data.attribute.k_oil_number<=0) {
  26. this.node_qiyou.active = false
  27. } else {
  28. count+=1
  29. this.lab_qiyou.getComponent(Label).string = `+${data.attribute.k_oil_number}桶`
  30. }
  31. if(data.attribute.n_shield_cd==0) {
  32. this.node_dunpai.active = false
  33. } else {
  34. count+=1
  35. this.lab_dunpai.getComponent(Label).string = `+${data.attribute.n_shield_cd}秒`
  36. }
  37. if(data.attribute.n_star_cd==0) {
  38. this.node_xingxing.active = false
  39. } else {
  40. count+=1
  41. this.lab_xingxing.getComponent(Label).string = `+${data.attribute.n_star_cd}秒`
  42. }
  43. if(data.attribute.n_magnet_cd==0) {
  44. this.node_citie.active = false
  45. } else {
  46. count+=1
  47. this.lab_citie.getComponent(Label).string = `+${data.attribute.n_magnet_cd}秒`
  48. }
  49. if(count==0) {
  50. this.lab_no_shuxing.active = true
  51. } else {
  52. this.lab_no_shuxing.active = false
  53. }
  54. }
  55. }