mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 03:59:35 +08:00

* 添加 OpenFactory,可以动态扩展技能和物品 * 修改 Effect 的反序列化解析;增加对闪避/暴击判定的先前事件编程接口 * 补充魔法伤害的判定 * 装备系统优化;角色的复制问题修复 * 添加物品品质;更新装备饰品替换机制;添加第一滴血、团队模式 * 添加技能选取 * 添加团队死斗模式
92 lines
3.6 KiB
C#
92 lines
3.6 KiB
C#
using System.Text.Json;
|
|
using Milimoe.FunGame.Core.Api.Utility;
|
|
using Milimoe.FunGame.Core.Entity;
|
|
using Milimoe.FunGame.Core.Library.Common.Architecture;
|
|
using Milimoe.FunGame.Core.Library.Constant;
|
|
|
|
namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
|
{
|
|
public class EquipSlotConverter : BaseEntityConverter<EquipSlot>
|
|
{
|
|
public override EquipSlot NewInstance()
|
|
{
|
|
return new();
|
|
}
|
|
|
|
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref EquipSlot result)
|
|
{
|
|
Item temp;
|
|
switch (propertyName)
|
|
{
|
|
case nameof(EquipSlot.MagicCardPack):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.MagicCardPack)
|
|
{
|
|
result.MagicCardPack = temp;
|
|
}
|
|
break;
|
|
case nameof(EquipSlot.Weapon):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.Weapon)
|
|
{
|
|
result.Weapon = temp;
|
|
}
|
|
break;
|
|
case nameof(EquipSlot.Armor):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.Armor)
|
|
{
|
|
result.Armor = temp;
|
|
}
|
|
break;
|
|
case nameof(EquipSlot.Shoes):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.Shoes)
|
|
{
|
|
result.Shoes = temp;
|
|
}
|
|
break;
|
|
case nameof(EquipSlot.Accessory1):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.Accessory1)
|
|
{
|
|
result.Accessory1 = temp;
|
|
}
|
|
break;
|
|
case nameof(EquipSlot.Accessory2):
|
|
temp = NetworkUtility.JsonDeserialize<Item>(ref reader, options) ?? new();
|
|
if (temp.EquipSlotType == EquipSlotType.Accessory2)
|
|
{
|
|
result.Accessory2 = temp;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, EquipSlot value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteStartObject();
|
|
|
|
writer.WritePropertyName(nameof(value.MagicCardPack));
|
|
JsonSerializer.Serialize(writer, value.MagicCardPack, options);
|
|
|
|
writer.WritePropertyName(nameof(value.Weapon));
|
|
JsonSerializer.Serialize(writer, value.Weapon, options);
|
|
|
|
writer.WritePropertyName(nameof(value.Armor));
|
|
JsonSerializer.Serialize(writer, value.Armor, options);
|
|
|
|
writer.WritePropertyName(nameof(value.Shoes));
|
|
JsonSerializer.Serialize(writer, value.Shoes, options);
|
|
|
|
writer.WritePropertyName(nameof(value.Accessory1));
|
|
JsonSerializer.Serialize(writer, value.Accessory1, options);
|
|
|
|
writer.WritePropertyName(nameof(value.Accessory2));
|
|
JsonSerializer.Serialize(writer, value.Accessory2, options);
|
|
|
|
writer.WriteEndObject();
|
|
}
|
|
}
|
|
}
|