import ItemUtil from "../ts/core/ItemUtil"; cc.Class({ extends: cc.Component, properties: { itemIcon: cc.Sprite, itemDetail: cc.Prefab, schemeItemDetail: cc.Prefab, gradeFlag: cc.Node, itemBg: cc.Node, maskIcon: cc.Sprite }, onLoad() { //this.levelNode = this.itemBg.getChildByName('level'); this.selectedNode = this.node.getChildByName('selected'); if (this.selectedNode) { this.selectedNode.active = false; } }, reset() { this.itemBg.active = false; this.itemInfo = null; }, /* * type: 0,普通,1,屬性方案使用 * onUse: 屬性方案中是否已裝載 */ loadInfo(info, type = 0, onUse = false) { this.itemInfo = info; this.itemBg.active = true; this.itemIcon.spriteFrame = ItemUtil.getItemIconBy(this.itemInfo); if (this.itemBg.getChildByName('level')) { this.itemBg.getChildByName('level').getComponent(cc.Label).string = this.itemInfo.Grade; } if (this.gradeFlag) { if (this.itemInfo.Grade > 1) { this.gradeFlag.active = true; } else { this.gradeFlag.active = false; } } this.type = type; this.onUse = onUse; if (ItemUtil.isBaldric(info.EIndex) && (info.flag == 1||info.BaseAttr=="[]")){ this.maskIcon.spriteFrame = ItemUtil.getItemIconBy({ icon: 1000 }); this.gradeFlag.active = false; this.itemBg.getChildByName('level').getComponent(cc.Label).string ="" } // if (ItemUtil.isShowDetail()||ItemUtil.isEquip(info)) return; }, selected() { if (this.selectedNode) { this.selectedNode.active = true; } if (this.itemInfo != null) { let canvas = cc.find('Canvas'); let prefab = this.itemDetail; if (ItemUtil.isBaldric(this.itemInfo.EIndex)) { ItemUtil.showMenu = true; ItemUtil.showAccessDetail(this.itemInfo, this.onUse); return; } if (this.type == 1) { prefab = this.schemeItemDetail; } console.log(prefab) if (canvas.getChildByName('EquipItemDetail') == null) { let detail = cc.instantiate(prefab); detail.parent = canvas; let name = 'EquipItemDetail'; if (this.type == 1) { name = 'SchemeEquipItemDetail'; } detail.name = name; detail.getComponent(name).loadInfo(this.itemInfo, this.onUse); let schemePanel = cc.find('MainUI/SchemePanel', canvas); if (schemePanel != null) { detail.getComponent(name).showOperation(); } else { let bagLayer = cc.find('MainUI/BagPanel', canvas); if (bagLayer != null) { detail.getComponent(name).showOperation(); } } } } }, unSelected() { this.selectedNode.active = false; }, });