优化武器商品描述文本、修复敌人子弹无法击中玩家的bug
This commit is contained in:
@@ -3,6 +3,7 @@ using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
@@ -12,12 +13,14 @@ namespace SepCore.UI
|
||||
public Rarity Rarity;
|
||||
public Sprite Icon;
|
||||
public ItemType ItemType;
|
||||
public string TypeName;
|
||||
public string Description;
|
||||
public int Price;
|
||||
|
||||
public GoodsItemContext()
|
||||
{
|
||||
Name = string.Empty;
|
||||
TypeName = string.Empty;
|
||||
Description = string.Empty;
|
||||
Rarity = Rarity.White;
|
||||
Price = 0;
|
||||
@@ -33,22 +36,49 @@ namespace SepCore.UI
|
||||
|
||||
if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
DamageType damageType;
|
||||
if (rawData.DataRow is WeaponConfig weaponConfig)
|
||||
{
|
||||
Name = weaponConfig.WeaponType.ToString();
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weaponConfig);
|
||||
damageType = weaponConfig.DamageType;
|
||||
}
|
||||
else if (rawData.DataRow is WeaponData weaponData)
|
||||
{
|
||||
Name = weaponData.Title;
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weaponData);
|
||||
damageType = weaponData.DamageType;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("Weapon data row is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
TypeName = damageType switch
|
||||
{
|
||||
DamageType.Melee => "近战武器",
|
||||
DamageType.Ranged => "远程武器",
|
||||
DamageType.Element => "元素武器",
|
||||
_ => "武器"
|
||||
};
|
||||
}
|
||||
else if (ItemType == ItemType.Prop)
|
||||
{
|
||||
if (rawData.DataRow is PropConfig prop)
|
||||
{
|
||||
Name = prop.Name;
|
||||
Description = ItemDescUtility.CreatePropDescription(prop.StatModifierConfigs);
|
||||
TypeName = "道具";
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("Prop data row is invalid.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var prop = (PropConfig)rawData.DataRow;
|
||||
Name = prop.Name;
|
||||
Description = ItemDescUtility.CreatePropDescription(prop.StatModifierConfigs);
|
||||
Log.Error("Unsupported goods item type '{0}'.", ItemType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,7 @@ namespace SepCore.UI
|
||||
|
||||
_iconArea.OnInit(data.Icon, data.Rarity);
|
||||
_titleText.text = data.Name;
|
||||
_typeText.text = data.ItemType switch
|
||||
{
|
||||
ItemType.None => "error",
|
||||
ItemType.Weapon => "武器",
|
||||
ItemType.Prop => "道具",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
_typeText.text = data.TypeName;
|
||||
_descriptionText.text = data.Description;
|
||||
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SepCore.Definition;
|
||||
@@ -9,18 +8,9 @@ namespace SepCore.CustomUtility
|
||||
{
|
||||
public static class ItemDescUtility
|
||||
{
|
||||
private static readonly Dictionary<ParamType, string> _paramTypeNames = new()
|
||||
{
|
||||
{ ParamType.HitRadius, "攻击半宽" },
|
||||
{ ParamType.SectorAngle, "攻击角度" },
|
||||
{ ParamType.HitHalfWidth, "横向半宽" },
|
||||
{ ParamType.PierceLength, "前戳距离" },
|
||||
{ ParamType.HitHeight, "判定高度" },
|
||||
};
|
||||
|
||||
private static readonly string[] _statTypeNames =
|
||||
{
|
||||
"无效", // None = 0
|
||||
"无效", // None = 0
|
||||
"最大生命", // MaxHp = 1
|
||||
"生命恢复", // HpRegen = 2
|
||||
"生命窃取", // LifeSteal = 3
|
||||
@@ -35,8 +25,8 @@ namespace SepCore.CustomUtility
|
||||
"护甲", // Armor = 12
|
||||
"闪避率", // Dodge = 13
|
||||
"移动速度", // MoveSpeed = 14
|
||||
"收获", // Harvesting = 15
|
||||
"幸运" // Luck = 16
|
||||
"收获", // Harvesting = 15
|
||||
"幸运" // Luck = 16
|
||||
};
|
||||
|
||||
public static string Describe(StatModifierConfig statModifierConfig)
|
||||
@@ -110,80 +100,53 @@ namespace SepCore.CustomUtility
|
||||
|
||||
public static string CreateWeaponDescription(WeaponConfig weaponConfig)
|
||||
{
|
||||
if (weaponConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown,
|
||||
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs, weaponConfig.Parameters);
|
||||
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs);
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(WeaponBase weapon)
|
||||
{
|
||||
if (weapon == null || weapon.WeaponData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weapon.WeaponData);
|
||||
}
|
||||
|
||||
|
||||
public static string CreateWeaponDescription(WeaponData weaponData)
|
||||
{
|
||||
if (weaponData == null)
|
||||
{
|
||||
return null;
|
||||
Log.Error("Weapon data is invalid.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponData.Attack, weaponData.Cooldown,
|
||||
weaponData.AttackRange, weaponData.Modifiers, weaponData.Parameters);
|
||||
weaponData.AttackRange, weaponData.Modifiers);
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(PropItem prop)
|
||||
{
|
||||
if (prop == null)
|
||||
{
|
||||
return null;
|
||||
Log.Error("Prop is invalid.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return CreatePropDescription(prop.Modifiers);
|
||||
}
|
||||
|
||||
private static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
IEnumerable<StatModifierConfig> modifiers, IReadOnlyDictionary<ParamType, float> parameters)
|
||||
public static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
IEnumerable<StatModifierConfig> modifiers = null)
|
||||
{
|
||||
float baseCrit = GameEntry.Luban.Global.WeaponBaseCrit;
|
||||
float critMult = GameEntry.Luban.Global.CritMultiplier;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"攻击: {attack}");
|
||||
sb.AppendLine($"冷却: {cooldown}");
|
||||
sb.AppendLine($"范围: {attackRange}");
|
||||
sb.AppendLine($"伤害: {attack}");
|
||||
sb.AppendLine($"暴击: x{critMult:0.##} ({baseCrit * 100:0.##}%)");
|
||||
sb.AppendLine($"冷却: {cooldown:0.##}s");
|
||||
sb.AppendLine($"范围: {attackRange:0.##}");
|
||||
|
||||
string modifiersDesc = CreatePropDescription(modifiers);
|
||||
if (!string.IsNullOrEmpty(modifiersDesc))
|
||||
{
|
||||
sb.Append(modifiersDesc);
|
||||
sb.AppendLine();
|
||||
sb.Append(modifiersDesc.TrimEnd());
|
||||
}
|
||||
|
||||
if (parameters == null || parameters.Count == 0)
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
foreach (var kvp in parameters)
|
||||
{
|
||||
if (!_paramTypeNames.TryGetValue(kvp.Key, out string paramName))
|
||||
{
|
||||
paramName = kvp.Key.ToString();
|
||||
}
|
||||
|
||||
string valStr = kvp.Key == ParamType.SectorAngle
|
||||
? kvp.Value.ToString()
|
||||
: kvp.Value.ToString("0.##");
|
||||
|
||||
sb.AppendLine($"{paramName}: {valStr}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
return sb.ToString().TrimEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -115,10 +115,7 @@ namespace SepCore.Simulation
|
||||
query.SourceOwnerEntityId != PlayerTargetEntityId)
|
||||
{
|
||||
float3 playerPosition = PlayerPosition;
|
||||
if (query.SourceType == SimulationCollision.SourceTypeArea)
|
||||
{
|
||||
playerPosition.y = query.Position.y;
|
||||
}
|
||||
playerPosition.y = query.Position.y;
|
||||
|
||||
float3 playerDelta = playerPosition - query.Position;
|
||||
float playerSqrDistance = math.lengthsq(playerDelta);
|
||||
|
||||
Reference in New Issue
Block a user