103 lines
2.7 KiB
C#
103 lines
2.7 KiB
C#
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备信息
|
|
/// </summary>
|
|
public class DeviceInfo
|
|
{
|
|
/// <summary>
|
|
/// 车身核心信息
|
|
/// </summary>
|
|
[JsonPropertyName("body")]
|
|
public BodyDevice[] Body { get; set; } = Array.Empty<BodyDevice>();
|
|
|
|
/// <summary>
|
|
/// 武器信息
|
|
/// </summary>
|
|
[JsonPropertyName("weapon")]
|
|
public WeaponDevice[] Weapon { get; set; } = Array.Empty<WeaponDevice>();
|
|
|
|
/// <summary>
|
|
/// 装甲信息
|
|
/// </summary>
|
|
[JsonPropertyName("armor")]
|
|
public ArmorDevice[] Armor { get; set; } = Array.Empty<ArmorDevice>();
|
|
|
|
/// <summary>
|
|
/// 底盘信息
|
|
/// </summary>
|
|
[JsonPropertyName("chassis")]
|
|
public ChassisDevice[] Chassis { get; set; } = Array.Empty<ChassisDevice>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备管理类
|
|
/// </summary>
|
|
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<DeviceInfo>(json)!;
|
|
Console.WriteLine($"角色设备信息配置文件: {path} 加载成功 ");
|
|
}
|
|
else
|
|
{
|
|
Console.Write($"角色设备信息配置文件: {path} 不存在 ");
|
|
}
|
|
}
|
|
}
|
|
}
|