using Cal; using Cal.DataTable; using System; using System.Collections.Generic; using System.Linq; namespace ET { public static class EquipItemSystem { static readonly List startWeight = new() { 1100, 2580, 1600, 460, 160, 24, 8, 1 }; static readonly List startRareWeight = new() { 1600, 3150, 256, 8, 1 }; static readonly List weight = new() { 1100, 2100, 1150, 90, 8, 1 }; static readonly List qualityEqicWeight = new() { 360, 800, 8, 1 }; static readonly List qualityLengeryWeight = new() { 9, 1 }; public static void Create(this EquipItem self, EquipBase equipBase, Unit unit, float randomMax) { Create(self, equipBase, unit.GetComponent().GetAsInt(NumericType.Level), randomMax); } public static void Create(this EquipItem self, EquipBase equipBase, int _level, float randomMax) { self.mainAttribute = new Dictionary(); self.addtionalAttributes = new(); self.gemList = new int[equipBase.MaxHole]; self.specialKey = (AttributeType) equipBase.SpecialKey; ItemHelper.GenerateRandomMainAttribute(self, equipBase, randomMax); int level = equipBase.UseLevel; if (equipBase.UseLevel == 1) { level = _level; } ItemHelper.GenerateAdditionalAttribute(self, level); } public static void CreateManul(this EquipItem self, Unit unit, EquipType equipType, AttributeType atkType, C2M_MakeMunalEquip.StoneType isRare, int level) { //self.mainAttribute = new Dictionary(); self.addtionalAttributes = new(); self.randomAttributes = new(); self.gemList = new int[4]; self.specialKey = AttributeType.无; ItemHelper.GenerateAdditionalAttribute(self, level); int star = 3; int quality = 1; List qualityList = weight; List starList = startWeight; if (isRare == C2M_MakeMunalEquip.StoneType.Rare || isRare == C2M_MakeMunalEquip.StoneType.UpgradeRare || isRare == C2M_MakeMunalEquip.StoneType.Epic) { star = 6; starList = startRareWeight; } if (isRare == C2M_MakeMunalEquip.StoneType.Epic) { quality = 3; qualityList = qualityEqicWeight; } int starIndex = MathHelper.GetProbabilityIndexByWeight(starList); int qualityIndex = MathHelper.GetProbabilityIndexByWeight(qualityList); star += starIndex; quality += qualityIndex; self.quality = (Quality) quality; self.star = star; if (isRare == C2M_MakeMunalEquip.StoneType.Epic) { PlayerData data = unit.GetComponent(); try { if (self.quality < Quality.Legendary) { bool isEnd = data.UpdateEpicManulCount(); if (isEnd) { //保底橙色 qualityIndex = MathHelper.GetProbabilityIndexByWeight(qualityLengeryWeight); self.quality = Quality.Legendary + (byte) qualityIndex; } } else { data.GenerateEpicManulCount(); } } catch (Exception e) { Log.Error(e); } } //产生词条 List manulEquipList = ManulEquipAttributeCategory.Instance.qualityDic?[quality]; if (manulEquipList == null || manulEquipList.Count == 0) return; using ListComponent list = ListComponent.Create(); list.List.AddRange(manulEquipList); EquipUpgrade equipUpgrade = EquipUpgradeCategory.Instance.Get((long) equipType); bool hasAtk = false; foreach (int item in equipUpgrade.CanUpgradeArr) { if (item == (int) atkType) { hasAtk = true; break; } } int type = equipUpgrade.CanUpgradeArr[0]; if (hasAtk) { foreach (ManulEquipAttribute item in list.List) { if (item.Key == (int) atkType) { self.specialId = (int) item.Id; break; } } list.List.RemoveAll(t => t.Key == (int) atkType); } else { foreach (ManulEquipAttribute item in list.List) { if (type == item.Key) { self.specialId = (int) item.Id; break; } } list.List.RemoveAll(t => t.Key == type); } RandomHelper.SelectUnits(list.List, null, star); foreach (ManulEquipAttribute item in list.List) { self.randomAttributes.Add((int) item.Id); } } public static float GetSpecialAttribute(this EquipItem self, AttributeType type) { float add = 1; if (self.equipLevel != 0) { Strengthentable strengthentable = StrengthentableCategory.Instance.Get(self.equipLevel, false); if (strengthentable != null) add = 1 + strengthentable.AttribteAdd; } if (self.specialKey == type) { EquipBase equipBase = EquipBaseCategory.Instance.Get(self.itemId); return equipBase.SpecialValue * add; } if (self.specialId != 0) { ManulEquipAttribute manulEquipAttribute = ManulEquipAttributeCategory.Instance.Get(self.specialId); if (manulEquipAttribute != null && manulEquipAttribute.Key == (int) type) return manulEquipAttribute.Value * add; } return 0; } public static float GetMainAttribute(this EquipItem self, AttributeType type) { if (self.mainAttribute == null) return 0; self.mainAttribute.TryGetValue((int) type, out float value); EquipBase equipBase = EquipBaseCategory.Instance.Get(self.itemId); float baseValue = EquipBaseCategory.Instance.GetValue(type, equipBase); return baseValue * (1 + value); } public static void SetMainAttribute(this EquipItem self, AttributeType type, float value) { if (self.mainAttribute != null) self.mainAttribute[(int) type] = value; } public static float GetAdditionalAttribute(this EquipItem self, AttributeType type) { int typeInt = (int) type; if (self.addtionalAttributes == null) return 0; float vaule = 0; foreach (int id in self.addtionalAttributes) { EquipAffixConfig manulEquip = EquipAffixConfigCategory.Instance.Get(id); if (manulEquip != null) { foreach (EquipAffixConfig.Affix item in manulEquip.AffixArr) { if (item.Key == typeInt) { vaule += item.Value; } } } } return vaule; } public static float GetRandomAttribute(this EquipItem self, AttributeType type) { int typeInt = (int) type; if (self.randomAttributes == null) return 0; foreach (int id in self.randomAttributes) { ManulEquipAttribute manulEquip = ManulEquipAttributeCategory.Instance.Get(id); if (manulEquip != null) { if (manulEquip.Key == typeInt) { return manulEquip.Value; } } } return 0; } public static float GetGemAttribute(this EquipItem self, AttributeType type) { try { if (self.gemList != null) { foreach (int gemId in self.gemList) { if (gemId == 0) continue; MaterialBase materialBase = DataTableHelper.Get(gemId); if (materialBase.GemKey == (int) type) { return materialBase.GemValue; } } } } catch (Exception e) { Log.Error(e); } return 0; } public static float GetStarSoulAttribute(this EquipItem self, Bag bag, AttributeType type) { float value = 0; try { if (self.starSoulItemServerId != 0) { StarSoulBag starSoulBag = bag.Parent.GetComponent(); StarSoulItem item = starSoulBag.Get(self.starSoulItemServerId); if (item == null) { return value; } StarSoulAttributeConfig soulAttributeConfig = StarSoulAttributeConfigCategory.Instance.Get(item.mainId); if (soulAttributeConfig.Key == (int) type) value += soulAttributeConfig.Value; for (var i = 0; i < item.viceIds.Length; i++) { soulAttributeConfig = StarSoulAttributeConfigCategory.Instance.Get(item.viceIds[i]); if (soulAttributeConfig.Key == (int) type) value += ItemHelper.GetRealViceValue(soulAttributeConfig.Value*(1+item.viceAdd[i]),item.quality); } } } catch (Exception e) { Log.Error(e); } return value; } } }