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; 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; } }); } 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; }); } }