diff --git a/Entity/Character/Character.cs b/Entity/Character/Character.cs
index 8be1c76..12d3a85 100644
--- a/Entity/Character/Character.cs
+++ b/Entity/Character/Character.cs
@@ -38,7 +38,7 @@ namespace Milimoe.FunGame.Core.Entity
public CharacterProfile Profile { get; set; }
///
- /// 角色的详细资料
+ /// 角色的装备
///
public EquipSlot EquipSlot { get; set; }
@@ -1122,7 +1122,7 @@ namespace Milimoe.FunGame.Core.Entity
builder.Append(skill.ToString());
}
}
-
+
if (EquipSlot.Any())
{
builder.AppendLine("== 装备栏 ==");
@@ -1158,6 +1158,15 @@ namespace Milimoe.FunGame.Core.Entity
}
}
+ if (Items.Count > 0)
+ {
+ builder.AppendLine("== 角色背包 ==");
+ foreach (Item item in Items)
+ {
+ builder.Append(item.ToString());
+ }
+ }
+
if (Effects.Where(e => e.EffectType != EffectType.Item).Any())
{
builder.AppendLine("== 状态栏 ==");
@@ -1275,6 +1284,7 @@ namespace Milimoe.FunGame.Core.Entity
{
Character c = new()
{
+ Id = Id,
Name = Name,
FirstName = FirstName,
NickName = NickName,
@@ -1326,11 +1336,15 @@ namespace Milimoe.FunGame.Core.Entity
};
foreach (Skill skill in Skills)
{
- c.Skills.Add(skill);
+ Skill newskill = skill.Copy();
+ newskill.Character = c;
+ c.Skills.Add(newskill);
}
foreach (Item item in Items)
{
- c.Items.Add(item);
+ Item newitem = item.Copy();
+ newitem.Character = c;
+ c.Items.Add(newitem);
}
c.Recovery();
return c;
diff --git a/Entity/Item/Item.cs b/Entity/Item/Item.cs
index becb820..d4846dd 100644
--- a/Entity/Item/Item.cs
+++ b/Entity/Item/Item.cs
@@ -14,17 +14,17 @@ namespace Milimoe.FunGame.Core.Entity
///
/// 物品的描述
///
- public virtual string Description { get; } = "";
+ public virtual string Description { get; set; } = "";
///
/// 物品的通用描述
///
- public virtual string GeneralDescription { get; } = "";
+ public virtual string GeneralDescription { get; set; } = "";
///
/// 物品的背景故事
///
- public virtual string BackgroundStory { get; } = "";
+ public virtual string BackgroundStory { get; set; } = "";
///
/// 物品类型
@@ -32,7 +32,17 @@ namespace Milimoe.FunGame.Core.Entity
public virtual ItemType ItemType { get; set; } = ItemType.Others;
///
- /// 物品槽位
+ /// 是否允许装备
+ ///
+ public bool Equipable { get; set; } = true;
+
+ ///
+ /// 是否允许取消装备
+ ///
+ public bool Unequipable { get; set; } = true;
+
+ ///
+ /// 装备槽位
///
public virtual EquipSlotType EquipSlotType { get; set; } = EquipSlotType.None;
@@ -56,16 +66,6 @@ namespace Milimoe.FunGame.Core.Entity
///
public bool Enable { get; set; } = true;
- ///
- /// 是否允许装备
- ///
- public bool Equipable { get; set; } = true;
-
- ///
- /// 是否允许取消装备
- ///
- public bool Unequipable { get; set; } = true;
-
///
/// 是否是局内使用的物品(局内是指对角色生效的物品)
///
@@ -143,7 +143,6 @@ namespace Milimoe.FunGame.Core.Entity
public void OnItemEquip(Character character, EquipItemToSlot type)
{
Character = character;
- Character.Items.Add(this);
foreach (Skill skill in Skills.Passives)
{
if (!skill.IsActive && skill.Level > 0)
@@ -206,7 +205,6 @@ namespace Milimoe.FunGame.Core.Entity
Character.EquipSlot.Accessory2 = null;
break;
}
- Character.Items.Remove(this);
OnItemUnEquipped(Character, this, type);
}
Character = null;
@@ -388,6 +386,44 @@ namespace Milimoe.FunGame.Core.Entity
item.NextTradableTime = NextTradableTime;
}
+ ///
+ /// 复制一个物品
+ ///
+ ///
+ public Item Copy()
+ {
+ Item item = new()
+ {
+ Id = Id,
+ Name = Name,
+ Description = Description,
+ GeneralDescription = GeneralDescription,
+ ItemType = ItemType,
+ Equipable = Equipable,
+ Unequipable = Unequipable,
+ EquipSlotType = EquipSlotType,
+ WeaponType = WeaponType,
+ Key = Key,
+ Enable = Enable,
+ IsInGameItem = IsInGameItem,
+ IsPurchasable = IsPurchasable,
+ Price = Price,
+ IsSellable = IsSellable,
+ NextSellableTime = NextSellableTime,
+ IsTradable = IsTradable,
+ NextTradableTime = NextTradableTime,
+ RemainUseTimes = RemainUseTimes,
+ };
+ item.Skills.Active = Skills.Active?.Copy();
+ foreach (Skill skill in Skills.Passives)
+ {
+ Skill newskill = skill.Copy();
+ newskill.Item = item;
+ item.Skills.Passives.Add(newskill);
+ }
+ return item;
+ }
+
///
/// 所属的角色
///
diff --git a/Entity/Skill/Effect.cs b/Entity/Skill/Effect.cs
index 0297050..b6ea370 100644
--- a/Entity/Skill/Effect.cs
+++ b/Entity/Skill/Effect.cs
@@ -19,40 +19,40 @@ namespace Milimoe.FunGame.Core.Entity
/// 特殊效果类型
/// 注意:如果技能特效没有原生施加控制效果,请始终保持此属性为 。
///
- public virtual EffectType EffectType { get; } = EffectType.None;
+ public virtual EffectType EffectType { get; set; } = EffectType.None;
///
/// 作用于自身
///
- public virtual bool TargetSelf { get; } = false;
+ public virtual bool TargetSelf { get; set; } = false;
///
/// 作用目标数量
///
- public virtual int TargetCount { get; } = 0;
+ public virtual int TargetCount { get; set; } = 0;
///
/// 作用范围
///
- public virtual double TargetRange { get; } = 0;
+ public virtual double TargetRange { get; set; } = 0;
///
/// 持续性的
/// 配合 使用,而不是 。
///
- public virtual bool Durative { get; } = false;
+ public virtual bool Durative { get; set; } = false;
///
/// 持续时间
/// 配合 使用。
///
- public virtual double Duration { get; } = 0;
+ public virtual double Duration { get; set; } = 0;
///
/// 持续时间(回合)
/// 使用此属性需要将 设置为 false。
///
- public virtual int DurationTurn { get; } = 0;
+ public virtual int DurationTurn { get; set; } = 0;
///
/// 剩余持续时间
@@ -67,12 +67,12 @@ namespace Milimoe.FunGame.Core.Entity
///
/// 魔法类型
///
- public virtual MagicType MagicType { get; } = MagicType.None;
+ public virtual MagicType MagicType { get; set; } = MagicType.None;
///
/// 效果描述
///
- public virtual string Description { get; } = "";
+ public virtual string Description { get; set; } = "";
///
/// 等级,跟随技能的等级
@@ -434,6 +434,29 @@ namespace Milimoe.FunGame.Core.Entity
return builder.ToString();
}
+ ///
+ /// 复制一个特效
+ ///
+ ///
+ public Effect Copy(Skill skill)
+ {
+ Effect copy = new(skill)
+ {
+ EffectType = EffectType,
+ TargetSelf = TargetSelf,
+ TargetCount = TargetCount,
+ TargetRange = TargetRange,
+ Durative = Durative,
+ Duration = Duration,
+ DurationTurn = DurationTurn,
+ MagicType = MagicType,
+ Description = Description,
+ ActionQueue = ActionQueue
+ };
+
+ return copy;
+ }
+
///
/// 比较两个特效
///
diff --git a/Entity/Skill/Skill.cs b/Entity/Skill/Skill.cs
index 5576c6a..ab25ba4 100644
--- a/Entity/Skill/Skill.cs
+++ b/Entity/Skill/Skill.cs
@@ -118,7 +118,7 @@ namespace Milimoe.FunGame.Core.Entity
/// 冷却时间
///
[InitRequired]
- public virtual double CD { get; } = 0;
+ public virtual double CD { get; set; } = 0;
///
/// 剩余冷却时间 [ 建议配合 属性使用 ]
@@ -145,6 +145,11 @@ namespace Milimoe.FunGame.Core.Entity
/// 游戏中的行动顺序表实例,在技能效果被触发时,此实例会获得赋值,使用时需要判断其是否存在
///
public ActionQueue? ActionQueue { get; set; } = null;
+
+ ///
+ /// 技能是否属于某个物品
+ ///
+ public Item? Item { get; set; } = null;
///
/// 继承此类实现时,调用基类的构造函数
@@ -308,6 +313,35 @@ namespace Milimoe.FunGame.Core.Entity
return other is Skill c && c.Id + "." + c.Name == Id + "." + Name;
}
+ ///
+ /// 复制一个技能
+ ///
+ ///
+ public Skill Copy()
+ {
+ Skill s = new()
+ {
+ Id = Id,
+ Name = Name,
+ Description = Description,
+ GeneralDescription = GeneralDescription,
+ SkillType = SkillType,
+ MPCost = MPCost,
+ CastTime = CastTime,
+ EPCost = EPCost,
+ CD = CD,
+ CurrentCD = CurrentCD,
+ HardnessTime = HardnessTime,
+ ActionQueue = ActionQueue
+ };
+ foreach (Effect e in Effects)
+ {
+ Effect neweffect = e.Copy(s);
+ s.Effects.Add(neweffect);
+ }
+ return s;
+ }
+
///
/// 等级
///
diff --git a/Library/Common/JsonConverter/CharacterConverter.cs b/Library/Common/JsonConverter/CharacterConverter.cs
index 55f8eba..d8c0841 100644
--- a/Library/Common/JsonConverter/CharacterConverter.cs
+++ b/Library/Common/JsonConverter/CharacterConverter.cs
@@ -170,6 +170,20 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
case nameof(Character.ExEvadeRate):
result.ExEvadeRate = reader.GetDouble();
break;
+ case nameof(Character.Skills):
+ HashSet skills = NetworkUtility.JsonDeserialize>(ref reader, options) ?? [];
+ foreach (Skill skill in skills)
+ {
+ result.Skills.Add(skill);
+ }
+ break;
+ case nameof(Character.Items):
+ HashSet- items = NetworkUtility.JsonDeserialize>(ref reader, options) ?? [];
+ foreach (Item item in items)
+ {
+ result.Items.Add(item);
+ }
+ break;
}
}
@@ -230,6 +244,10 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
writer.WriteNumber(nameof(Character.ExCritRate), value.ExCritRate);
writer.WriteNumber(nameof(Character.ExCritDMG), value.ExCritDMG);
writer.WriteNumber(nameof(Character.ExEvadeRate), value.ExEvadeRate);
+ writer.WritePropertyName(nameof(Character.Skills));
+ JsonSerializer.Serialize(writer, value.Skills, options);
+ writer.WritePropertyName(nameof(Character.Items));
+ JsonSerializer.Serialize(writer, value.Items, options);
writer.WriteEndObject();
}