123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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<cc.Node> = [];
- public goodItem:GoodItem;
- public onLoad(){
- }
-
- 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;
- }
- }
- }
|