Phase2.1 添加武器tag配置和数据表定义

This commit is contained in:
2026-09-27 18:21:26 +08:00
parent 4ac79f0101
commit e0488cc790
47 changed files with 1249 additions and 169 deletions
@@ -84,11 +84,13 @@ namespace SepCore.UI
{
if (uiComponent.IsLoadingUIForm(assetName))
{
Log.Warning("UIComponentExtension.OpenUIForm() skipped '{0}' because it is already loading.", assetName);
return null;
}
if (uiComponent.HasUIForm(assetName))
{
Log.Warning("UIComponentExtension.OpenUIForm() skipped '{0}' because it is already open.", assetName);
return null;
}
}
@@ -36,7 +36,8 @@ namespace SepCore.CustomComponent
"tbuiformconfig",
"tbuisoundconfig",
"tbweaponconfig",
"tbstatconfig"
"tbstatconfig",
"tbweapontagconfig"
};
private sealed class TableAccessor
@@ -131,7 +132,7 @@ namespace SepCore.CustomComponent
},
{
typeof(WeaponConfig),
Accessor(tables => id => tables.TbWeaponConfig.GetOrDefault((WeaponType)id),
Accessor(tables => id => tables.TbWeaponConfig.GetOrDefault(id),
tables => tables.TbWeaponConfig.DataList)
},
{
@@ -139,6 +140,11 @@ namespace SepCore.CustomComponent
Accessor(tables => id => tables.TbStatConfig.GetOrDefault((StatType)id),
tables => tables.TbStatConfig.DataList)
},
{
typeof(WeaponTagConfig),
Accessor(tables => id => tables.TbWeaponTagConfig.GetOrDefault(id),
tables => tables.TbWeaponTagConfig.DataList)
},
};
private static TableAccessor Accessor<TValue>(Func<Tables, Func<int, object>> rowGetterFactory,
@@ -5,8 +5,7 @@ namespace SepCore.UI
public class ShopGoodsSelection
{
public GoodsType GoodsType;
public int PropId;
public WeaponType WeaponType;
public int RefId;
public int Price;
}
}
@@ -167,7 +167,7 @@ namespace SepCore.UI
if (goodsConfig.GoodsType == GoodsType.Prop)
{
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goodsConfig.PropId);
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goodsConfig.RefId);
int basePrice = propConfig.Price;
price = CalculateRandomizedPrice(basePrice, priceRandomPercent);
@@ -177,7 +177,7 @@ namespace SepCore.UI
}
else if (goodsConfig.GoodsType == GoodsType.Weapon)
{
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goodsConfig.WeaponType);
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goodsConfig.RefId);
int basePrice = weaponConfig.Price;
price = CalculateRandomizedPrice(basePrice, priceRandomPercent);
@@ -197,8 +197,7 @@ namespace SepCore.UI
_selections.Add(new ShopGoodsSelection
{
GoodsType = goodsConfig.GoodsType,
PropId = goodsConfig.PropId,
WeaponType = goodsConfig.WeaponType,
RefId = goodsConfig.RefId,
Price = price
});
@@ -253,14 +252,14 @@ namespace SepCore.UI
if (goods.GoodsType == GoodsType.Prop)
{
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.PropId);
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.RefId);
rarity = propConfig.Rarity;
return true;
}
if (goods.GoodsType == GoodsType.Weapon)
{
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goods.WeaponType);
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goods.RefId);
rarity = weaponConfig.Rarity;
return true;
}
@@ -285,7 +284,7 @@ namespace SepCore.UI
{
if (goods.GoodsType == GoodsType.Prop)
{
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.PropId);
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.RefId);
_player.AddProp(new PropItem(propConfig));
return new DisplayItemRawData
{
@@ -303,7 +302,7 @@ namespace SepCore.UI
return null;
}
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goods.WeaponType);
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goods.RefId);
int id = GameEntry.Entity.NextId();
var weaponData = EntityDataFactory.Create(id, weaponConfig, _player.Id, CampType.Player);
@@ -311,7 +310,7 @@ namespace SepCore.UI
if (weapon == null)
{
Log.Warning(
$"ShopFormUseCase::ApplyGoodsPurchase: Show weapon failed, weapon type id = {goods.WeaponType}");
$"ShopFormUseCase::ApplyGoodsPurchase: Show weapon failed, weapon type id = {goods.RefId}");
return null;
}
@@ -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: