import i18n from "../../i18n/i18n"; import ViewObject from "../../main/ViewObject"; import GoodItem from "./GoodItem"; import EquipViewAttr from "./EquipViewAttr"; import FFCalAttr from "../data/FFCalAttr"; /** * 装备说明 */ const {ccclass, property} = cc._decorator; @ccclass export default class EquipAbout extends ViewObject { @property(cc.Label) mName: cc.Label = null; @property(cc.Label) mAbout: cc.Label = null; @property(GoodItem) mGoodItem: GoodItem = null; @property(cc.Label) mZdl: cc.Label = null; @property(cc.Label) mAtk: cc.Label = null; @property(cc.Label) mDef: cc.Label = null; @property(cc.Label) mHp: cc.Label = null; @property(cc.Label) mSp: cc.Label = null; @property(cc.Node) mFAttrNode: cc.Node = null;//副属性节点 @property(cc.Prefab) mFAttrItem: cc.Prefab = null; @property(cc.Node) mSkillNode: cc.Node = null;//技能节点 @property(cc.Label) mSkillName: cc.Label = null; @property(cc.Label) mSkillAbout: cc.Label = null; @property(cc.Sprite) mSkillIcon: cc.Sprite = null; @property([cc.Node]) mMainNode: Array = [];//主属性节点 public goodItem:GoodItem; public onLoad(){ } /** * initEquip */ public initEquip(goodItem:GoodItem) { this.goodItem = goodItem; let equip = this.goodItem.equip; let equipData = this.goodItem.equipData; this.mName.string = i18n.t(equipData.name); this.mAbout.string = i18n.t(equipData.about); this.goodItem.equip = equip; this.goodItem.equipData = equipData; this.goodItem.flushEquip(this.main); this.mZdl.string = ''+FFCalAttr.getZdl(equipData) if(equipData.atk > 0){ this.mAtk.string = i18n.t('攻击')+':'+equipData.atk; this.mMainNode[0].active = true; }else{ this.mMainNode[0].active = false; } if(equipData.def > 0){ this.mDef.string = i18n.t('防御')+':'+equipData.def; this.mMainNode[1].active = true; }else{ this.mMainNode[1].active = false; } if(equipData.hp > 0){ this.mHp.string = i18n.t('气血')+':'+equipData.hp; this.mMainNode[2].active = true; }else{ this.mMainNode[2].active = false; } if(equipData.sp > 0){ this.mSp.string = i18n.t('速度')+':'+equipData.sp; this.mMainNode[3].active = true; }else{ this.mMainNode[3].active = false; } if(equip.attr.length <= 0){ this.mFAttrNode.active = false; }else{ let nodes = this.mFAttrNode.children; nodes.forEach(node => { if(node.name != 'fsx_name'){ node.destroy(); } }); this.mFAttrNode.active = true; for (let i = 0; i < equip.attr.length; i++) { const element = equip.attr[i]; let node = cc.instantiate(this.mFAttrItem); let eAttr = node.getComponent(EquipViewAttr); eAttr.init(this.main,element); node.parent = this.mFAttrNode; } } if(equipData.skill > 0){ this.mSkillNode.active = true; let skillData = this.main.sManage.getSkillById(equipData.skill); this.mSkillName.string = i18n.t(skillData.name); this.mSkillAbout.string = i18n.t(skillData.about, { 'VAL1':skillData.value1, 'VAL2':skillData.value2, 'VAL3':skillData.value3, } ); cc.resources.load('icon/skill/'+skillData.icon, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{ if(err){ cc.error(err); }else{ this.mSkillIcon.spriteFrame = spriteFrame; } } ); }else{ this.mSkillNode.active = false; } } }