68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { all_ItemConfig } from '../../game/gameConfig';
|
|
import { uimanger } from '../UIManger';
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export class guns_single extends cc.Component {
|
|
@property(cc.Label) label: cc.Label = null;
|
|
@property(cc.Node) imgNode: cc.Node = null;
|
|
@property(cc.Prefab) infoPage: cc.Prefab = null;
|
|
|
|
@property(cc.ProgressBar) limitBar:cc.ProgressBar = null;
|
|
|
|
@property(cc.Label) cegget:cc.Label = null;
|
|
private curData = {};
|
|
|
|
private guninfo = {};
|
|
|
|
init(data) {
|
|
|
|
if (data == 0) {
|
|
this.node.active = false;
|
|
return;
|
|
}
|
|
var limit = data.ceg_uplimit
|
|
var get = data.today_get_gold
|
|
|
|
this.limitBar.progress =(limit-get)/limit
|
|
this.cegget.string = `${limit-data.today_get_gold}/${data.ceg_uplimit}`
|
|
|
|
this.node.active = true;
|
|
this.curData = data;
|
|
const imgConfigs = all_ItemConfig[data.gun_id];
|
|
this.label.string = imgConfigs.name;
|
|
this.setItemImg(this.imgNode, imgConfigs.icon);
|
|
|
|
// console.log(imgConfigs)
|
|
|
|
this.guninfo = {
|
|
name: imgConfigs.icon,
|
|
weapon_id: parseInt(data.gun_id),
|
|
weapon_lv: parseInt(data.fun_lv),
|
|
weapon_uniid: data.gun_uniid,
|
|
ammo: 30,
|
|
volume: 30
|
|
}
|
|
|
|
// console.log(`gungungun---${JSON.stringify(this.guninfo)}`)
|
|
this.node.name = JSON.stringify(this.guninfo);
|
|
|
|
}
|
|
|
|
showInfo() {
|
|
uimanger.showUI(this.infoPage, this.curData);
|
|
}
|
|
|
|
setItemImg(imgNode: cc.Node, itemId: number) {
|
|
cc.loader.loadRes(`icons/${itemId}`, cc.SpriteFrame, (err, res) => {
|
|
imgNode.getComponent(cc.Sprite).spriteFrame = res;
|
|
});
|
|
// this.node.name = JSON.stringify(this.guninfo);
|
|
}
|
|
|
|
removeClickEvent() {
|
|
this.getComponent(cc.Button).clickEvents.length = 0;
|
|
}
|
|
}
|