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