using System.Text.Json.Serialization; namespace XNet.Business.Tank.Manager { public class BodyDevice { [JsonPropertyName("body")] public string Name { get; set; } = string.Empty; } public class WeaponDevice { [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; [JsonPropertyName("attackPower")] public float AttackPower { get; set; } = 0.0f; [JsonPropertyName("findFaceDistance")] public float FindFaceDistance { get; set; } = 0.0f; } public class ArmorDevice { [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; [JsonPropertyName("armor")] public float Armor { get; set; } = 0.0f; [JsonPropertyName("blood")] public float Blood { get; set; } = 0.0f; } public class ChassisDevice { [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; [JsonPropertyName("speed")] public float Speed { get; set; } = 0.0f; } /// /// 设备信息 /// public class DeviceInfo { /// /// 车身核心信息 /// [JsonPropertyName("body")] public BodyDevice[] Body { get; set; } = Array.Empty(); /// /// 武器信息 /// [JsonPropertyName("weapon")] public WeaponDevice[] Weapon { get; set; } = Array.Empty(); /// /// 装甲信息 /// [JsonPropertyName("armor")] public ArmorDevice[] Armor { get; set; } = Array.Empty(); /// /// 底盘信息 /// [JsonPropertyName("chassis")] public ChassisDevice[] Chassis { get; set; } = Array.Empty(); } /// /// 设备管理类 /// public class DeviceManager { public static readonly DeviceManager Instance = new DeviceManager(); public DeviceInfo DeviceInfo { get; set; } = default!; private DeviceManager() { } public void Init() { string path = Path.Combine(AppContext.BaseDirectory, "role", "device.json"); if (File.Exists(path)) { string json = File.ReadAllText(path); DeviceInfo = System.Text.Json.JsonSerializer.Deserialize(json)!; Console.WriteLine($"角色设备信息配置文件: {path} 加载成功 "); } else { Console.Write($"角色设备信息配置文件: {path} 不存在 "); } } } }