car_info.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { _decorator, Component, Label, Node, Sprite } from 'cc';
  2. import { base_ui } from '../fw/base_ui';
  3. import { car_item_data, car_type } from '../data';
  4. import { imageCacheManager } from '../manager/imageCacheManager';
  5. import { userDataManager } from '../manager/userDataManager';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('car_info')
  8. export class car_info extends base_ui {
  9. @property(Node) btn_close:Node = null
  10. @property(Node) lab_xiangcha_score:Node = null
  11. @property(Node) img_car:Node = null
  12. @property(Node) lab_car_name:Node = null
  13. @property(Node) lab_score:Node = null
  14. @property(Node) img_suo:Node = null
  15. @property(Node) node_chongci:Node = null
  16. @property(Node) lab_chongci:Node = null
  17. @property(Node) node_qiyou:Node = null
  18. @property(Node) lab_qiyou:Node = null
  19. @property(Node) node_dunpai:Node = null
  20. @property(Node) lab_dunpai:Node = null
  21. @property(Node) node_xingxing:Node = null
  22. @property(Node) lab_xingxing:Node = null
  23. @property(Node) node_citie:Node = null
  24. @property(Node) lab_citie:Node = null
  25. @property(Node) lab_no_shuxing:Node = null
  26. start() {
  27. this.onButtonListen(this.btn_close, ()=>{
  28. this.close()
  29. })
  30. }
  31. initView(data:car_item_data, is_jiesuo:boolean) {
  32. if(is_jiesuo) {
  33. this.img_suo.active = false
  34. this.lab_car_name.active = false
  35. this.lab_xiangcha_score.getComponent(Label).string = data.name
  36. } else {
  37. if(data.stype==car_type.score) {
  38. let xiangcha_score = data.unlock_points - userDataManager.user_car_list.max_integral
  39. if(xiangcha_score<0) {
  40. xiangcha_score = 0
  41. }
  42. this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 分`
  43. } else {
  44. let xiangcha_score = 100
  45. this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 碎片`
  46. }
  47. this.img_suo.active = true
  48. this.lab_car_name.active = true
  49. this.lab_car_name.getComponent(Label).string = data.name
  50. }
  51. this.img_car.getComponent(Sprite).spriteFrame = imageCacheManager.getRankCarImageById(data.id)
  52. if(data.stype==car_type.score) {
  53. this.lab_score.getComponent(Label).string = data.unlock_points + '分解锁'
  54. } else {
  55. this.lab_score.getComponent(Label).string = `已集齐 ${0} / ${data.unlock_points}`
  56. }
  57. let count = 0
  58. if(data.attribute.k_sprint_cd<=0) {
  59. this.node_chongci.active = false
  60. } else {
  61. count+=1
  62. this.lab_chongci.getComponent(Label).string = `+${data.attribute.k_sprint_cd}秒`
  63. }
  64. if(data.attribute.k_oil_number<=0) {
  65. this.node_qiyou.active = false
  66. } else {
  67. count+=1
  68. this.lab_qiyou.getComponent(Label).string = `+${data.attribute.k_oil_number}桶`
  69. }
  70. if(data.attribute.n_shield_cd==0) {
  71. this.node_dunpai.active = false
  72. } else {
  73. count+=1
  74. this.lab_dunpai.getComponent(Label).string = `+${data.attribute.n_shield_cd}秒`
  75. }
  76. if(data.attribute.n_star_cd==0) {
  77. this.node_xingxing.active = false
  78. } else {
  79. count+=1
  80. this.lab_xingxing.getComponent(Label).string = `+${data.attribute.n_star_cd}秒`
  81. }
  82. if(data.attribute.n_magnet_cd==0) {
  83. this.node_citie.active = false
  84. } else {
  85. count+=1
  86. this.lab_citie.getComponent(Label).string = `+${data.attribute.n_magnet_cd}秒`
  87. }
  88. if(count==0) {
  89. this.lab_no_shuxing.active = true
  90. } else {
  91. this.lab_no_shuxing.active = false
  92. }
  93. }
  94. }