优化武器商品描述文本、修复敌人子弹无法击中玩家的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,15 +8,6 @@ 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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(WeaponBase weapon)
|
||||
{
|
||||
if (weapon == null || weapon.WeaponData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weapon.WeaponData);
|
||||
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-3
@@ -115,10 +115,7 @@ namespace SepCore.Simulation
|
||||
query.SourceOwnerEntityId != PlayerTargetEntityId)
|
||||
{
|
||||
float3 playerPosition = PlayerPosition;
|
||||
if (query.SourceType == SimulationCollision.SourceTypeArea)
|
||||
{
|
||||
playerPosition.y = query.Position.y;
|
||||
}
|
||||
|
||||
float3 playerDelta = playerPosition - query.Position;
|
||||
float playerSqrDistance = math.lengthsq(playerDelta);
|
||||
|
||||
@@ -3,33 +3,45 @@
|
||||
--- !u!159 &1
|
||||
EditorSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_ExternalVersionControlSupport: Visible Meta Files
|
||||
serializedVersion: 12
|
||||
m_SerializationMode: 2
|
||||
m_LineEndingsForNewScripts: 2
|
||||
m_DefaultBehaviorMode: 0
|
||||
m_PrefabRegularEnvironment: {fileID: 0}
|
||||
m_PrefabUIEnvironment: {fileID: 0}
|
||||
m_SpritePackerMode: 0
|
||||
m_SpritePackerCacheSize: 10
|
||||
m_SpritePackerPaddingPower: 1
|
||||
m_Bc7TextureCompressor: 0
|
||||
m_EtcTextureCompressorBehavior: 1
|
||||
m_EtcTextureFastCompressor: 1
|
||||
m_EtcTextureNormalCompressor: 2
|
||||
m_EtcTextureBestCompressor: 4
|
||||
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp
|
||||
m_ProjectGenerationRootNamespace:
|
||||
m_CollabEditorSettings:
|
||||
inProgressEnabled: 1
|
||||
m_EnableTextureStreamingInEditMode: 1
|
||||
m_EnableTextureStreamingInPlayMode: 1
|
||||
m_EnableEditorAsyncCPUTextureLoading: 0
|
||||
m_AsyncShaderCompilation: 1
|
||||
m_EnterPlayModeOptionsEnabled: 0
|
||||
m_PrefabModeAllowAutoSave: 1
|
||||
m_EnterPlayModeOptionsEnabled: 1
|
||||
m_EnterPlayModeOptions: 3
|
||||
m_ShowLightmapResolutionOverlay: 1
|
||||
m_GameObjectNamingDigits: 1
|
||||
m_GameObjectNamingScheme: 0
|
||||
m_AssetNamingUsesSpace: 1
|
||||
m_InspectorUseIMGUIDefaultInspector: 0
|
||||
m_UseLegacyProbeSampleCount: 0
|
||||
m_SerializeInlineMappingsOnOneLine: 0
|
||||
m_DisableCookiesInLightmapper: 1
|
||||
m_AssetPipelineMode: 1
|
||||
m_RefreshImportMode: 0
|
||||
m_CacheServerMode: 0
|
||||
m_CacheServerEndpoint:
|
||||
m_CacheServerNamespacePrefix: default
|
||||
m_CacheServerEnableDownload: 1
|
||||
m_CacheServerEnableUpload: 1
|
||||
m_CacheServerEnableAuth: 0
|
||||
m_CacheServerEnableTls: 0
|
||||
m_CacheServerValidationMode: 2
|
||||
m_CacheServerDownloadBatchSize: 128
|
||||
m_EnableEnlightenBakedGI: 0
|
||||
|
||||
Reference in New Issue
Block a user