123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { _decorator, Component, Label, Node, Sprite } from 'cc';
- import { base_ui } from '../fw/base_ui';
- import { car_item_data, car_type } from '../data';
- import { imageCacheManager } from '../manager/imageCacheManager';
- import { userDataManager } from '../manager/userDataManager';
- const { ccclass, property } = _decorator;
- @ccclass('car_info')
- export class car_info extends base_ui {
- @property(Node) btn_close:Node = null
- @property(Node) lab_xiangcha_score:Node = null
- @property(Node) img_car:Node = null
- @property(Node) lab_car_name:Node = null
- @property(Node) lab_score:Node = null
- @property(Node) img_suo:Node = null
- @property(Node) node_chongci:Node = null
- @property(Node) lab_chongci:Node = null
- @property(Node) node_qiyou:Node = null
- @property(Node) lab_qiyou:Node = null
- @property(Node) node_dunpai:Node = null
- @property(Node) lab_dunpai:Node = null
- @property(Node) node_xingxing:Node = null
- @property(Node) lab_xingxing:Node = null
- @property(Node) node_citie:Node = null
- @property(Node) lab_citie:Node = null
- @property(Node) lab_no_shuxing:Node = null
- start() {
- this.onButtonListen(this.btn_close, ()=>{
- this.close()
- })
- }
- initView(data:car_item_data, is_jiesuo:boolean) {
- if(is_jiesuo) {
- this.img_suo.active = false
- this.lab_car_name.active = false
- this.lab_xiangcha_score.getComponent(Label).string = data.name
- } else {
- if(data.stype==car_type.score) {
- let xiangcha_score = data.unlock_points - userDataManager.user_car_list.max_integral
- if(xiangcha_score<0) {
- xiangcha_score = 0
- }
- this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 分`
- } else {
- let xiangcha_score = 100
- this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 碎片`
- }
- this.img_suo.active = true
- this.lab_car_name.active = true
- this.lab_car_name.getComponent(Label).string = data.name
- }
-
- this.img_car.getComponent(Sprite).spriteFrame = imageCacheManager.getRankCarImageById(data.id)
- if(data.stype==car_type.score) {
- this.lab_score.getComponent(Label).string = data.unlock_points + '分解锁'
- } else {
- this.lab_score.getComponent(Label).string = `已集齐 ${0} / ${data.unlock_points}`
- }
- let count = 0
- if(data.attribute.k_sprint_cd<=0) {
- this.node_chongci.active = false
- } else {
- count+=1
- this.lab_chongci.getComponent(Label).string = `+${data.attribute.k_sprint_cd}秒`
- }
- if(data.attribute.k_oil_number<=0) {
- this.node_qiyou.active = false
- } else {
- count+=1
- this.lab_qiyou.getComponent(Label).string = `+${data.attribute.k_oil_number}桶`
- }
- if(data.attribute.n_shield_cd==0) {
- this.node_dunpai.active = false
- } else {
- count+=1
- this.lab_dunpai.getComponent(Label).string = `+${data.attribute.n_shield_cd}秒`
- }
- if(data.attribute.n_star_cd==0) {
- this.node_xingxing.active = false
- } else {
- count+=1
- this.lab_xingxing.getComponent(Label).string = `+${data.attribute.n_star_cd}秒`
- }
- if(data.attribute.n_magnet_cd==0) {
- this.node_citie.active = false
- } else {
- count+=1
- this.lab_citie.getComponent(Label).string = `+${data.attribute.n_magnet_cd}秒`
- }
- if(count==0) {
- this.lab_no_shuxing.active = true
- } else {
- this.lab_no_shuxing.active = false
- }
- }
- }
|