|
@@ -1,7 +1,12 @@
|
|
|
-import { _decorator, Label, Node, tween, UIOpacity } from 'cc';
|
|
|
+import { _decorator, instantiate, Label, Node, Prefab, ProgressBar, tween, UIOpacity } from 'cc';
|
|
|
import { BaseView } from '../../../framework/layer/BaseView';
|
|
|
import { StringUtil } from '../../../framework/util/StringUtil';
|
|
|
import { CommonItem } from '../common/CommonItem';
|
|
|
+import List from '../../../framework/list/List';
|
|
|
+import { Equip } from '../../data/EquipData';
|
|
|
+import { EquipManager } from '../../manager/EquipManager';
|
|
|
+import { AttrAddTypeEnum, AttrEnum } from '../../common/InterfaceAddEnum';
|
|
|
+import { Framework } from '../../../framework/Framework';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('EquipUpdate')
|
|
@@ -12,44 +17,59 @@ export class EquipUpdate extends BaseView {
|
|
|
@property({ type: Label, tooltip: "标题" })
|
|
|
titieTx: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "装备名" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "装备名" })
|
|
|
+ equipNameTx: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "装备节点" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Node, tooltip: "装备节点" })
|
|
|
+ equipNode: Node = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "当前等级" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "当前等级" })
|
|
|
+ equipNowLevel: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "目标等级" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "目标等级" })
|
|
|
+ equipNextLevel: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "当前属性" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "当前属性" })
|
|
|
+ equipNowAttr: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "目标属性" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "目标属性" })
|
|
|
+ equipNextAttr: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "等级箭头" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "目标属性加成" })
|
|
|
+ equipNextAttrAdd: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "属性箭头" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Node, tooltip: "等级箭头" })
|
|
|
+ levelArrow: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "经验值标题" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Node, tooltip: "属性箭头" })
|
|
|
+ attrArrow: Node = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "经验值进度" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "经验值标题" })
|
|
|
+ expTitle: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "经验值文字" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: ProgressBar, tooltip: "经验值进度" })
|
|
|
+ expBar: ProgressBar = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "标题" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: Label, tooltip: "经验值文字" })
|
|
|
+ expBarTx: Label = null;
|
|
|
|
|
|
- // @property({ type: Label, tooltip: "标题" })
|
|
|
- // titieTx: Label = null;
|
|
|
+ @property({ type: List, tooltip: "材料列表" })
|
|
|
+ itemSv: List = null;
|
|
|
+
|
|
|
+ @property({ type: Label, tooltip: "升级按钮文字" })
|
|
|
+ updateBtnTx: Label = null;
|
|
|
+
|
|
|
+ @property({ type: Label, tooltip: "一键按钮文字" })
|
|
|
+ autoBtnTx: Label = null;
|
|
|
+
|
|
|
+ private _curRace: number = 0;
|
|
|
+ private _curSlot: number = 0;
|
|
|
+ private _curEquip: Equip = null;
|
|
|
+
|
|
|
+ private _curExp: number = 0;
|
|
|
+ private _otherExp: number = 0;
|
|
|
+
|
|
|
+ private _equipsData = [];
|
|
|
|
|
|
protected onLoad() {
|
|
|
super.onLoad();
|
|
@@ -59,7 +79,7 @@ export class EquipUpdate extends BaseView {
|
|
|
}
|
|
|
|
|
|
protected onDestroy() {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//UI开打时会调用,如果有初始化代码应该放到此函数
|
|
@@ -71,19 +91,37 @@ export class EquipUpdate extends BaseView {
|
|
|
.repeatForever()
|
|
|
.start()
|
|
|
|
|
|
+ this._curRace = data.race;
|
|
|
+ this._curSlot = data.slot;
|
|
|
+ this._curEquip = data.equip;
|
|
|
+
|
|
|
+ this.load('common', `prefab/CommonItem`, Prefab, (pre: Prefab) => {
|
|
|
+ let item = instantiate(pre);
|
|
|
+ this.equipNode.addChild(item);
|
|
|
+ item.getComponent(CommonItem).refreshItem(this._curEquip);
|
|
|
+ })
|
|
|
|
|
|
+ this.equipNameTx.string = StringUtil.getLanguageData(this._curEquip.conf['Name']);
|
|
|
+ this._curExp = this._curEquip.exp;
|
|
|
+
|
|
|
+ this._equipsData = EquipManager.getEquipRaceSlotAllGroup(data.race);
|
|
|
+
|
|
|
+ this.itemSv.numItems = this._equipsData.length;
|
|
|
+
|
|
|
+ this.initUI();
|
|
|
+ // this.updateByExp();
|
|
|
}
|
|
|
|
|
|
//UI关闭时会调用,该函数在onDestroy前调用
|
|
|
onClose() {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//框架管理UI层级时会调用,可根据UI情况修改
|
|
|
onShow() {
|
|
|
super.onShow();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//框架管理UI层级时会调用,可根据UI情况修改
|
|
|
onHide() {
|
|
|
super.onHide();
|
|
@@ -93,9 +131,53 @@ export class EquipUpdate extends BaseView {
|
|
|
private onTouchButton(event: Event) {
|
|
|
//Framework.audio.playEffect(AudioID.Click);
|
|
|
let target: any = event.target;
|
|
|
+ if (target.name == 'mask') {
|
|
|
+ Framework.layer.close(this);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
onEventList(item, idx) {
|
|
|
item.getComponent(CommonItem).refreshItem();
|
|
|
}
|
|
|
+
|
|
|
+ initUI() {
|
|
|
+ let curLvConf = EquipManager.getEquipLevelByExp(this._curExp);
|
|
|
+ this.equipNowLevel.string = 'Lv.' + curLvConf.Id;
|
|
|
+ let attr = this._curEquip.conf['Stat1'].split(':');
|
|
|
+ let attrConf = AttrEnum[attr[0]]
|
|
|
+ let attrStr = StringUtil.getLanguageData(attrConf.name);
|
|
|
+ let nowAdd = null;
|
|
|
+ let value = null;
|
|
|
+ if (attrConf.type == AttrAddTypeEnum.reality) {
|
|
|
+ nowAdd = attr[1] * (1 + curLvConf.AttackMod);
|
|
|
+ value = " +" + attr[1] * (1 + curLvConf.AttackMod);
|
|
|
+ } else {
|
|
|
+ nowAdd = 100 * Number(attr[1]) * (1 + curLvConf.AttackMod);
|
|
|
+ value = " +" + (100 * Number(attr[1]) * (1 + curLvConf.AttackMod)) + "%";
|
|
|
+ }
|
|
|
+ attrStr = attrStr + value;
|
|
|
+ this.equipNowAttr.string = attrStr;
|
|
|
+
|
|
|
+ let nextLvConf = EquipManager.getEquipNextLevel(this._curExp);
|
|
|
+ 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 = " +" + attr[1] * (1 + nextLvConf.AttackMod);
|
|
|
+ } else {
|
|
|
+ nextAdd = 100 * Number(attr[1]) * (1 + nextLvConf.AttackMod);
|
|
|
+ valueNext = " +" + (100 * Number(attr[1]) * (1 + nextLvConf.AttackMod)) + "%";
|
|
|
+ }
|
|
|
+ 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 / curLvConf.NeedExp;
|
|
|
+ this.expBarTx.string = this._curExp + '/' + curLvConf.NeedExp;
|
|
|
+ }
|
|
|
}
|