123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import i18n from "../../../i18n/i18n";
- import ViewObject from "../../../main/ViewObject";
- import EquipViewAttr from "../../common/EquipViewAttr";
- import PetIcon from "../../common/PetIcon";
- import FFCalAttr, { FFAttr } from "../../data/FFCalAttr";
- /**
- * 宠物属性详情
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class PetInfo extends ViewObject {
- @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)
- mSkillAbout: cc.Label = null;
- @property(cc.Sprite)
- mSkillIcon: cc.Sprite = null;
- /**
- *
- * @param prev 父界面
- */
- public show(prev?: ViewObject) {
- if (prev) {
- this.prev = prev;
- this.prev.__close();
- }
- this.main.viewManage.popView1(this.node);
- if (this.main && this.main.gameHttp) {
- this.main.gameHttp.pushEvent(this);
- }
- }
- public init(pi: PetIcon) {
- this.node.zIndex = 1
- let ffAttr: FFAttr = FFCalAttr.getAttr(this.main, pi.data)
- this.mZdl.string = '' + ffAttr.zdl;
- this.mAtk.string = '' + ffAttr.atk;
- this.mDef.string = '' + ffAttr.def;
- this.mHp.string = '' + ffAttr.hp;
- this.mSp.string = '' + ffAttr.sp;
- if (ffAttr.attrs.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 < ffAttr.attrs.length; i++) {
- const element = ffAttr.attrs[i];
- let node = cc.instantiate(this.mFAttrItem);
- let eAttr = node.getComponent(EquipViewAttr);
- eAttr.init(this.main, element);
- node.parent = this.mFAttrNode;
- }
- }
- if (ffAttr.weaponSkill > 0) {
- this.mSkillNode.active = true;
- let skillData = this.main.sManage.getSkillById(ffAttr.weaponSkill);
- 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;
- }
- }
- }
|