feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Codely.Newtonsoft.Json.Linq;
|
|
|
|
namespace UnityTcp.Editor.Helpers
|
|
{
|
|
/// <summary>
|
|
/// Helper class for JSON command processing utilities
|
|
/// </summary>
|
|
public static class JsonCommandHelper
|
|
{
|
|
/// <summary>
|
|
/// Helper method to check if a string is valid JSON
|
|
/// </summary>
|
|
public static bool IsValidJson(string text)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
text = text.Trim();
|
|
if (
|
|
(text.StartsWith("{") && text.EndsWith("}"))
|
|
|| // Object
|
|
(text.StartsWith("[") && text.EndsWith("]"))
|
|
) // Array
|
|
{
|
|
try
|
|
{
|
|
JToken.Parse(text);
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Helper method to get a summary of parameters for error reporting
|
|
/// </summary>
|
|
public static string GetParamsSummary(JObject @params)
|
|
{
|
|
try
|
|
{
|
|
return @params == null || !@params.HasValues
|
|
? "No parameters"
|
|
: string.Join(
|
|
", ",
|
|
@params
|
|
.Properties()
|
|
.Select(p =>
|
|
{
|
|
string s = p.Value?.ToString();
|
|
if (s == null) return $"{p.Name}: ";
|
|
int take = Math.Min(20, s.Length);
|
|
return $"{p.Name}: {s.Substring(0, take)}";
|
|
})
|
|
);
|
|
}
|
|
catch
|
|
{
|
|
return "Could not summarize parameters";
|
|
}
|
|
}
|
|
}
|
|
}
|