Phase2.1 添加武器tag配置和数据表定义
This commit is contained in:
@@ -17,9 +17,15 @@ namespace SepCore.CustomUtility
|
||||
return new EnemyData(entityId, GetEnemyConfig(enemyType), level);
|
||||
}
|
||||
|
||||
public static WeaponData Create(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
|
||||
public static WeaponData Create(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp, Rarity rarity = Rarity.White)
|
||||
{
|
||||
var config = GameEntry.Luban.Get<WeaponConfig>((int)weaponType);
|
||||
var config = WeaponUtility.GetWeaponConfig(weaponType, rarity);
|
||||
return new WeaponData(entityId, config, ownerId, ownerCamp);
|
||||
}
|
||||
|
||||
public static WeaponData Create(int entityId, int weaponId, int ownerId, CampType ownerCamp)
|
||||
{
|
||||
var config = WeaponUtility.GetWeaponConfig(weaponId);
|
||||
return new WeaponData(entityId, config, ownerId, ownerCamp);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SepCore.CustomUtility
|
||||
|
||||
public static Rarity SelectRarity(LevelDropConfig dropConfig)
|
||||
{
|
||||
float total = dropConfig.WhiteWeight + dropConfig.GreenWeight + dropConfig.BlueWeight + dropConfig.PurpleWeight + dropConfig.RedWeight;
|
||||
float total = dropConfig.WhiteWeight + dropConfig.BlueWeight + dropConfig.PurpleWeight + dropConfig.RedWeight;
|
||||
if (total <= 0f)
|
||||
{
|
||||
Log.Error("LevelDropConfig '{0}' has invalid total weight '{1}'.", dropConfig.Id, total);
|
||||
@@ -25,8 +25,6 @@ namespace SepCore.CustomUtility
|
||||
float roll = Random.Range(0f, total);
|
||||
if (roll < dropConfig.WhiteWeight) return Rarity.White;
|
||||
roll -= dropConfig.WhiteWeight;
|
||||
if (roll < dropConfig.GreenWeight) return Rarity.Green;
|
||||
roll -= dropConfig.GreenWeight;
|
||||
if (roll < dropConfig.BlueWeight) return Rarity.Blue;
|
||||
roll -= dropConfig.BlueWeight;
|
||||
if (roll < dropConfig.PurpleWeight) return Rarity.Purple;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.CustomUtility
|
||||
{
|
||||
public static class WeaponUtility
|
||||
{
|
||||
public const int IdMultiplier = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// 根据武器种类与品质换算武器配置编号。
|
||||
/// </summary>
|
||||
public static int GetWeaponId(WeaponType weaponType, Rarity rarity = Rarity.White)
|
||||
{
|
||||
return (int)weaponType * IdMultiplier + (int)rarity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据武器编号反推武器种类。
|
||||
/// </summary>
|
||||
public static WeaponType GetWeaponType(int weaponId)
|
||||
{
|
||||
return (WeaponType)(weaponId / IdMultiplier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据武器编号反推武器品质。
|
||||
/// </summary>
|
||||
public static Rarity GetRarity(int weaponId)
|
||||
{
|
||||
return (Rarity)(weaponId % IdMultiplier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定种类与品质的武器配置。
|
||||
/// </summary>
|
||||
public static WeaponConfig GetWeaponConfig(WeaponType weaponType, Rarity rarity = Rarity.White)
|
||||
{
|
||||
return GameEntry.Luban.Get<WeaponConfig>(GetWeaponId(weaponType, rarity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定武器编号的武器配置。
|
||||
/// </summary>
|
||||
public static WeaponConfig GetWeaponConfig(int weaponId)
|
||||
{
|
||||
return GameEntry.Luban.Get<WeaponConfig>(weaponId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取同种武器的下一阶品质配置(用于武器合成升阶)。
|
||||
/// 若已达到最高品质(Red)则返回 false。
|
||||
/// </summary>
|
||||
public static bool TryGetNextTierConfig(WeaponConfig current, out WeaponConfig nextTierConfig)
|
||||
{
|
||||
if (current.Rarity >= Rarity.Red)
|
||||
{
|
||||
nextTierConfig = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
int nextId = (int)current.WeaponType * IdMultiplier + ((int)current.Rarity + 1);
|
||||
nextTierConfig = GameEntry.Luban.Get<WeaponConfig>(nextId);
|
||||
return nextTierConfig != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算同种武器的下一阶品质武器编号。
|
||||
/// 若已达到最高品质(Red)则返回 false。
|
||||
/// </summary>
|
||||
public static bool TryGetNextTierWeaponId(int currentWeaponId, out int nextWeaponId)
|
||||
{
|
||||
Rarity rarity = GetRarity(currentWeaponId);
|
||||
if (rarity >= Rarity.Red)
|
||||
{
|
||||
nextWeaponId = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
nextWeaponId = currentWeaponId + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fff1b5f2bd835a748b998750d7d03154
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user