Browse Source

装备相关

wujia 6 tháng trước cách đây
mục cha
commit
f06b92e455

+ 47 - 11
assets/script/game/manager/EquipManager.ts

@@ -16,7 +16,7 @@ export class EquipManager {
         let arr = id.split('_');
         let eConf = conf[arr[0]];
         if (eConf) {
-            let lvAdd = this.getEquipLevelByExp(arr[0], Number(arr[1]));
+            let lvAdd = this.getEquipLevelByExp(Number(arr[1]));
             let attrAdd = eConf.Stat1.split(':')
             let equipData: Equip = {
                 id: id,
@@ -38,7 +38,7 @@ export class EquipManager {
      * @param id 装备id
      * @param exp 经验
      */
-    static getEquipLevelByExp(id: string, exp: number) {
+    static getEquipLevelByExp(exp: number) {
         let strengConf = EquipstrengthenConf.data;
         let data = [];
         for (const key in strengConf) {
@@ -50,17 +50,38 @@ export class EquipManager {
         data.sort((a, b) => {
             return Number(a.id) < Number(b.id) ? -1 : 1;
         });
-        let level = 0;
-        let atkMod = 0;
-        for (const element of data) {
-            if (exp >= element.NeedExp) {
-                level = element.Id;
-                atkMod = element.AttackMod
-            } else {
+        let nowConf = null
+        for (let index = 0; index < data.length; index++) {
+            const element = data[index];
+            if (exp < element.NeedExp) {
+                nowConf = element;
                 break;
             }
         }
-        return { level: level, atkMod: atkMod };
+        return nowConf;
+    }
+
+    static getEquipNextLevel(exp: number) {
+        let strengConf = EquipstrengthenConf.data;
+        let data = [];
+        for (const key in strengConf) {
+            if (Object.prototype.hasOwnProperty.call(strengConf, key)) {
+                const element = strengConf[key];
+                data.push(element);
+            }
+        }
+        data.sort((a, b) => {
+            return Number(a.id) < Number(b.id) ? -1 : 1;
+        });
+        let nowConf = null
+        for (let index = 0; index < data.length; index++) {
+            const element = data[index];
+            if (exp < element.NeedExp) {
+                nowConf = element;
+                break;
+            }
+        }
+        return strengConf[String(nowConf.Id + 1)];
     }
 
     //获取阵营穿戴装备
@@ -84,7 +105,7 @@ export class EquipManager {
         return equips;
     }
 
-    //获取阵营装备
+    //获取阵营装备(分类)
     static getEquipRaceSlotGroup(race) {
         let equips = { 1: [], 2: [], 3: [], 4: [] };
         let data = EquipData.getData();
@@ -99,6 +120,21 @@ export class EquipManager {
         return equips;
     }
 
+    //获取阵营装备(全)
+    static getEquipRaceSlotAllGroup(race) {
+        let equips = []
+        let data = EquipData.getData();
+        for (const key in data) {
+            if (Object.prototype.hasOwnProperty.call(data, key)) {
+                const element = data[key];
+                if (!element.wear && element.conf['Race'] == race) {
+                    equips.push(element);
+                }
+            }
+        }
+        return equips;
+    }
+
     //消息-穿戴装备
     static sendWearMsg(args: { eid: string, slot: number , race: number}, callback) {
         LoginMgr.sendPost('equip', 'wear', (data) => {

+ 10 - 0
assets/script/game/ui/common/CommonItem.ts

@@ -1,5 +1,6 @@
 import { _decorator, Label, Node, Sprite, SpriteFrame } from 'cc';
 import { ResKeeper } from '../../../framework/res/ResKeeper';
+import { ItemEnum } from '../../common/InterfaceAddEnum';
 const { ccclass, property } = _decorator;
 
 @ccclass('CommonItem')
@@ -20,6 +21,7 @@ export class CommonItem extends ResKeeper {
 	bgFrame: SpriteFrame[] = [];
 
 	private data = null;
+	private clickFunc = null;
 
 	protected onLoad() {
 
@@ -44,6 +46,14 @@ export class CommonItem extends ResKeeper {
 
 	refreshItem(data) {
 		this.data = data;
+		if (data.clickFunc) {
+			this.clickFunc = data.clickFunc;
+		}
+		if (this.data.type == ItemEnum.material) {
+		
+		} else if (this.data.type == ItemEnum.equip) {
+		
+		}
 	}
 
 	onClick() {

+ 4 - 4
assets/script/game/ui/hero/EquipOpreate.ts

@@ -4,7 +4,7 @@ import { StringUtil } from '../../../framework/util/StringUtil';
 import { Equip } from '../../data/EquipData';
 import { EquipConf } from '../../config/EquipConf';
 import { CommonItem } from '../common/CommonItem';
-import { AttrAddTypeEnum, AttrEnum, EquipSlotEnum } from '../../common/InterfaceAddEnum';
+import { AttrAddTypeEnum, AttrEnum } from '../../common/InterfaceAddEnum';
 import { Framework } from '../../../framework/Framework';
 import { ViewID } from '../../../framework/config/LayerConf';
 const { ccclass, property } = _decorator;
@@ -110,13 +110,13 @@ export class EquipOpreate extends BaseView {
 		let target: any = event.target;
 		if (target.name == 'mask') {
 			Framework.layer.close(this);
-		}else if (target.name == 'wear_btn') {
+		} else if (target.name == 'wear_btn') {
 			let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
 			Framework.layer.open(ViewID.EquipChoose, null, args);
-		}else if (target.name == 'update_btn') {
+		} else if (target.name == 'update_btn') {
 			let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
 			Framework.layer.open(ViewID.EquipUpdate, null, args);
-		}else if (target.name == 'strong_btn') {
+		} else if (target.name == 'strong_btn') {
 			// let args = { race: this._curRace, slot: this._curSlot, equip: this._curEquip }
 			// Framework.layer.open(ViewID.EquipStrong, null, args);
 		}

+ 112 - 30
assets/script/game/ui/hero/EquipUpdate.ts

@@ -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;
+	}
 }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 143 - 259
assets/sub_bundle/hero/prefab/EquipUpdate.prefab


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác