110 lines
3.7 KiB
TypeScript
110 lines
3.7 KiB
TypeScript
import { all_ItemConfig } from "../../game/gameConfig";
|
|
import { UIUpdateWeapon } from "../Academy/UIUpdateWeapon";
|
|
import { UIBase } from "../UIBase";
|
|
import { uimanger } from "../UIManger";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class guns_info extends UIBase {
|
|
@property(cc.Node) title: cc.Node = null;
|
|
@property(cc.Node) imgNode: cc.Node = null;
|
|
|
|
@property(cc.ScrollView) scrollView: cc.ScrollView = null;
|
|
@property(cc.Node) arrow_up: cc.Node = null;
|
|
@property(cc.Node) arrow_down: cc.Node = null;
|
|
|
|
// gun info
|
|
@property(cc.Label) lab_hp: cc.Label = null;
|
|
@property(cc.Label) lab_returnBlood: cc.Label = null;
|
|
@property(cc.Label) lab_attack: cc.Label = null;
|
|
@property(cc.Label) lab_defence: cc.Label = null;
|
|
@property(cc.Label) lab_speed: cc.Label = null;
|
|
@property(cc.Label) lab_range: cc.Label = null;
|
|
@property(cc.Label) lab_rateoffire: cc.Label = null;
|
|
@property(cc.Label) lab_clip: cc.Label = null;
|
|
@property(cc.Label) lab_vision: cc.Label = null;
|
|
@property(cc.Label) lab_reload: cc.Label = null;
|
|
@property(cc.Label) lab_naijiu: cc.Label = null;
|
|
|
|
@property(cc.Label) lab_lucky: cc.Label = null;
|
|
@property(cc.Label) lab_successrate: cc.Label = null;
|
|
|
|
@property(cc.ProgressBar) limitBar:cc.ProgressBar = null;
|
|
|
|
@property(cc.Label) cegget:cc.Label = null;
|
|
|
|
protected update(dt: number): void {
|
|
if (this.scrollView.getScrollOffset().y <= 0) {
|
|
this.arrow_down.active = true;
|
|
this.arrow_up.active = false;
|
|
} else {
|
|
this.arrow_up.active = true;
|
|
this.arrow_down.active = false;
|
|
}
|
|
}
|
|
|
|
init(data) {
|
|
const infoMap = new Map([
|
|
["1", this.lab_hp],
|
|
["2", this.lab_returnBlood],
|
|
["3", this.lab_attack],
|
|
["4", this.lab_defence],
|
|
["5", this.lab_speed],
|
|
["6", this.lab_range],
|
|
["9", this.lab_rateoffire],
|
|
["10", this.lab_clip],
|
|
["13", this.lab_vision],
|
|
["14", this.lab_reload],
|
|
["34", this.lab_lucky],
|
|
["35", this.lab_successrate],
|
|
["37", this.lab_naijiu],
|
|
]);
|
|
|
|
const imgConfigs = all_ItemConfig[data.gun_id];
|
|
this.title.getComponent(cc.Label).string = imgConfigs.name;
|
|
this.setItemImg(this.imgNode, imgConfigs.icon);
|
|
// info
|
|
data.attr.forEach((element) => {
|
|
if (element.type == 2) {
|
|
infoMap.get(`${element.attr_id}`).string = `${element.val}%`;
|
|
} else {
|
|
infoMap.get(`${element.attr_id}`).string = `${element.val}`;
|
|
}
|
|
});
|
|
|
|
infoMap.forEach((element) => {
|
|
if (element.string === "000") {
|
|
element.string = "Locked";
|
|
element.node.color = cc.Color.GRAY;
|
|
}
|
|
});
|
|
|
|
//
|
|
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}`
|
|
}
|
|
|
|
onClickAdvance() {
|
|
const data = {};
|
|
data["current"] = "advance";
|
|
uimanger.showUI(UIUpdateWeapon.prefabPath, data);
|
|
}
|
|
|
|
onClickUpgrade() {
|
|
uimanger.showUI(UIUpdateWeapon.prefabPath, {});
|
|
}
|
|
|
|
onClose() {
|
|
this.node.destroy();
|
|
}
|
|
setItemImg(imgNode: cc.Node, itemId: number) {
|
|
cc.loader.loadRes(`icons/${itemId}`, cc.SpriteFrame, (err, res) => {
|
|
imgNode.getComponent(cc.Sprite).spriteFrame = res;
|
|
});
|
|
}
|
|
}
|