|
@@ -71,10 +71,14 @@ export class EquipUpdate extends BaseView {
|
|
|
|
|
|
private _equipsData = [];
|
|
|
|
|
|
+ private _selectEquip = {};
|
|
|
+
|
|
|
protected onLoad() {
|
|
|
super.onLoad();
|
|
|
this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
|
|
|
this.titieTx.string = StringUtil.getLanguageData('装备升级');
|
|
|
+ this.updateBtnTx.string = StringUtil.getLanguageData('升级');
|
|
|
+ this.autoBtnTx.string = StringUtil.getLanguageData('一键选择');
|
|
|
this.closeTips.node.getComponent(UIOpacity).opacity = 0;
|
|
|
}
|
|
|
|
|
@@ -98,6 +102,8 @@ export class EquipUpdate extends BaseView {
|
|
|
this.load('common', `prefab/CommonItem`, Prefab, (pre: Prefab) => {
|
|
|
let item = instantiate(pre);
|
|
|
this.equipNode.addChild(item);
|
|
|
+ item.getComponent(CommonItem).setClickEnable(false);
|
|
|
+ item.getComponent(CommonItem).setNumShow(false);
|
|
|
item.getComponent(CommonItem).refreshItem(this._curEquip);
|
|
|
})
|
|
|
|
|
@@ -109,7 +115,6 @@ export class EquipUpdate extends BaseView {
|
|
|
this.itemSv.numItems = this._equipsData.length;
|
|
|
|
|
|
this.initUI();
|
|
|
- // this.updateByExp();
|
|
|
}
|
|
|
|
|
|
//UI关闭时会调用,该函数在onDestroy前调用
|
|
@@ -133,11 +138,46 @@ export class EquipUpdate extends BaseView {
|
|
|
let target: any = event.target;
|
|
|
if (target.name == 'mask') {
|
|
|
Framework.layer.close(this);
|
|
|
+ } else if (target.name == 'update_btn') {
|
|
|
+ if (Object.keys(this._selectEquip).length <= 0) {
|
|
|
+ Framework.tips.setTips(StringUtil.getLanguageData('请选择吞噬的装备'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let args = {
|
|
|
+ race: this._curRace,
|
|
|
+ slot: this._curSlot,
|
|
|
+ eat_eids: {}
|
|
|
+ }
|
|
|
+ for (const key in this._selectEquip) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(this._selectEquip, key)) {
|
|
|
+ const element = this._selectEquip[key];
|
|
|
+ args.eat_eids[key] = element.count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EquipManager.sendUpdateMsg(args, () => {
|
|
|
+ Framework.tips.setTips(StringUtil.getLanguageData('升级成功!'));
|
|
|
+ Framework.layer.close(this);
|
|
|
+ })
|
|
|
+ } else if (target.name == 'auto_btn') {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onEventList(item, idx) {
|
|
|
- item.getComponent(CommonItem).refreshItem();
|
|
|
+ item.getComponent(CommonItem).refreshItem(this._equipsData[idx]);
|
|
|
+ item.getComponent(CommonItem).setClick((data, isSelect) => {
|
|
|
+ item.getComponent(CommonItem).setSelectEnable(isSelect);
|
|
|
+ if (isSelect) {
|
|
|
+ this._selectEquip[data.id] = data;
|
|
|
+ this._otherExp = this._otherExp + ((data.conf.EatExp + data.exp) * data.count);
|
|
|
+ } else {
|
|
|
+ if (this._selectEquip.hasOwnProperty(data.id)) {
|
|
|
+ delete this._selectEquip[data.id];
|
|
|
+ this._otherExp = this._otherExp - ((data.conf.EatExp + data.exp) * data.count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateByExp();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
initUI() {
|
|
@@ -150,10 +190,10 @@ export class EquipUpdate extends BaseView {
|
|
|
let value = null;
|
|
|
if (attrConf.type == AttrAddTypeEnum.reality) {
|
|
|
nowAdd = attr[1] * (1 + curLvConf.AttackMod);
|
|
|
- value = " +" + attr[1] * (1 + curLvConf.AttackMod);
|
|
|
+ value = " +" + parseFloat((attr[1] * (1 + curLvConf.AttackMod)).toFixed(2));
|
|
|
} else {
|
|
|
nowAdd = 100 * Number(attr[1]) * (1 + curLvConf.AttackMod);
|
|
|
- value = " +" + (100 * Number(attr[1]) * (1 + curLvConf.AttackMod)) + "%";
|
|
|
+ value = " +" + parseFloat((100 * Number(attr[1]) * (1 + curLvConf.AttackMod)).toFixed(2)) + "%";
|
|
|
}
|
|
|
attrStr = attrStr + value;
|
|
|
this.equipNowAttr.string = attrStr;
|
|
@@ -166,10 +206,10 @@ export class EquipUpdate extends BaseView {
|
|
|
let valueNext = null;
|
|
|
if (attrConf.type == AttrAddTypeEnum.reality) {
|
|
|
nextAdd = attr[1] * (1 + nextLvConf.AttackMod);
|
|
|
- valueNext = " +" + attr[1] * (1 + nextLvConf.AttackMod);
|
|
|
+ valueNext = " +" + parseFloat((attr[1] * (1 + nextLvConf.AttackMod)).toFixed(2));
|
|
|
} else {
|
|
|
nextAdd = 100 * Number(attr[1]) * (1 + nextLvConf.AttackMod);
|
|
|
- valueNext = " +" + (100 * Number(attr[1]) * (1 + nextLvConf.AttackMod)) + "%";
|
|
|
+ valueNext = " +" + parseFloat((100 * Number(attr[1]) * (1 + nextLvConf.AttackMod)).toFixed(2)) + "%";
|
|
|
}
|
|
|
attrNextStr = attrNextStr + valueNext;
|
|
|
this.equipNextAttr.string = attrNextStr;
|
|
@@ -180,4 +220,44 @@ export class EquipUpdate extends BaseView {
|
|
|
this.expBar.progress = this._curExp / curLvConf.NeedExp;
|
|
|
this.expBarTx.string = this._curExp + '/' + curLvConf.NeedExp;
|
|
|
}
|
|
|
+
|
|
|
+ updateByExp() {
|
|
|
+ if (Object.keys(this._selectEquip).length <= 0) {
|
|
|
+ this.initUI()
|
|
|
+ } else {
|
|
|
+ let curLvConf = EquipManager.getEquipLevelByExp(this._curExp);
|
|
|
+ let attr = this._curEquip.conf['Stat1'].split(':');
|
|
|
+ let attrConf = AttrEnum[attr[0]]
|
|
|
+ let nowAdd = null;
|
|
|
+ if (attrConf.type == AttrAddTypeEnum.reality) {
|
|
|
+ nowAdd = attr[1] * (1 + curLvConf.AttackMod);
|
|
|
+ } else {
|
|
|
+ nowAdd = 100 * Number(attr[1]) * (1 + curLvConf.AttackMod);
|
|
|
+ }
|
|
|
+ let nextLvConf = EquipManager.getEquipLevelByExp(this._curExp + this._otherExp);
|
|
|
+ if (nextLvConf.Id <= curLvConf.Id) {
|
|
|
+ nextLvConf = EquipManager.getEquipNextLevel(this._curExp + this._otherExp);
|
|
|
+ }
|
|
|
+ this.equipNextLevel.string = 'Lv.' + nextLvConf.Id;
|
|
|
+ let attrNextConf = AttrEnum[attr[0]]
|
|
|
+ let attrNextStr = StringUtil.getLanguageData(attrNextConf.name);
|
|
|
+ let nextAdd = null;
|
|
|
+ let valueNext = null;
|
|
|
+ if (attrConf.type == AttrAddTypeEnum.reality) {
|
|
|
+ nextAdd = attr[1] * (1 + nextLvConf.AttackMod);
|
|
|
+ valueNext = " +" + parseFloat((attr[1] * (1 + nextLvConf.AttackMod)).toFixed(2));
|
|
|
+ } else {
|
|
|
+ nextAdd = 100 * Number(attr[1]) * (1 + nextLvConf.AttackMod);
|
|
|
+ valueNext = " +" + parseFloat((100 * Number(attr[1]) * (1 + nextLvConf.AttackMod)).toFixed(2)) + "%";
|
|
|
+ }
|
|
|
+ attrNextStr = attrNextStr + valueNext;
|
|
|
+ this.equipNextAttr.string = attrNextStr;
|
|
|
+
|
|
|
+ this.equipNextAttrAdd.string = attrConf.type == AttrAddTypeEnum.reality ? (" (+" + parseFloat((nextAdd - nowAdd).toFixed(2)) + ")") :
|
|
|
+ (" (+" + parseFloat((nextAdd - nowAdd).toFixed(2)) + "%)");
|
|
|
+
|
|
|
+ this.expBar.progress = (this._curExp + this._otherExp) / curLvConf.NeedExp;
|
|
|
+ this.expBarTx.string = (this._curExp + this._otherExp) + '/' + curLvConf.NeedExp;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|