mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-21 19:49:34 +08:00
更新装备/取消装备物品的逻辑
This commit is contained in:
parent
9391fbc903
commit
62240398ee
@ -1,4 +1,5 @@
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Interface.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Utility
|
||||
@ -482,7 +483,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
// 获取随机敌人
|
||||
if (enemys.Count > 0)
|
||||
{
|
||||
Character enemy = enemys[new Random().Next(enemys.Count)];
|
||||
Character enemy = enemys[Random.Shared.Next(enemys.Count)];
|
||||
character.NormalAttack.Attack(this, character, enemy);
|
||||
baseTime = character.NormalAttack.HardnessTime;
|
||||
foreach (Effect effect in character.Effects.Where(e => e.Level > 0).ToList())
|
||||
@ -496,7 +497,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
// 预使用技能,即开始吟唱逻辑
|
||||
// 注意:FastAuto 模式下,此吟唱逻辑删减了选取目标的逻辑,将选取逻辑放在了实际释放的环节
|
||||
// 在正常交互式模式下,吟唱前需要先选取目标
|
||||
Skill skill = skills[new Random().Next(skills.Count)];
|
||||
Skill skill = skills[Random.Shared.Next(skills.Count)];
|
||||
if (skill.SkillType == SkillType.Magic)
|
||||
{
|
||||
character.CharacterState = CharacterState.Casting;
|
||||
@ -836,7 +837,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <param name="max">最大获取量</param>
|
||||
public static double GetEP(double a, double b, double max)
|
||||
{
|
||||
return Calculation.Round2Digits(Math.Min((a + new Random().Next(30)) * b, max));
|
||||
return Calculation.Round2Digits(Math.Min((a + Random.Shared.Next(30)) * b, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -866,7 +867,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
effect.AlterExpectedDamageBeforeCalculation(actor, enemy, ref expectedDamage, isNormalAttack, false, MagicType.None);
|
||||
}
|
||||
|
||||
double dice = new Random().NextDouble();
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (isNormalAttack)
|
||||
{
|
||||
// 闪避判定
|
||||
@ -900,7 +901,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
finalDamage = Calculation.Round2Digits(expectedDamage * (1 - physicalDamageReduction));
|
||||
|
||||
// 暴击判定
|
||||
dice = new Random().NextDouble();
|
||||
dice = Random.Shared.NextDouble();
|
||||
if (dice < actor.CritRate)
|
||||
{
|
||||
finalDamage = Calculation.Round2Digits(finalDamage * actor.CritDMG); // 暴击伤害倍率加成
|
||||
@ -943,7 +944,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
effect.AlterExpectedDamageBeforeCalculation(actor, enemy, ref expectedDamage, isNormalAttack, true, magicType);
|
||||
}
|
||||
|
||||
double dice = new Random().NextDouble();
|
||||
double dice = Random.Shared.NextDouble();
|
||||
if (isNormalAttack)
|
||||
{
|
||||
// 闪避判定
|
||||
@ -987,7 +988,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
finalDamage = Calculation.Round2Digits(expectedDamage * (1 - MDF));
|
||||
|
||||
// 暴击判定
|
||||
dice = new Random().NextDouble();
|
||||
dice = Random.Shared.NextDouble();
|
||||
if (dice < actor.CritRate)
|
||||
{
|
||||
finalDamage = Calculation.Round2Digits(finalDamage * actor.CritDMG); // 暴击伤害倍率加成
|
||||
@ -1013,7 +1014,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
if (!_continuousKilling.TryAdd(killer, 1)) _continuousKilling[killer] += 1;
|
||||
_stats[killer].Kills += 1;
|
||||
_stats[death].Deaths += 1;
|
||||
int money = new Random().Next(250, 350);
|
||||
int money = Random.Shared.Next(250, 350);
|
||||
|
||||
Character[] assists = _assistDamage.Keys.Where(c => c != death && _assistDamage[c].GetPercentage(death) > 0.10).ToArray();
|
||||
double totalDamagePercentage = Calculation.Round4Digits(_assistDamage.Keys.Where(assists.Contains).Select(c => _assistDamage[c].GetPercentage(death)).Sum());
|
||||
@ -1037,7 +1038,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
// 终结击杀的奖励仍然是全额的
|
||||
if (_continuousKilling.TryGetValue(death, out int coefficient) && coefficient > 1)
|
||||
{
|
||||
money += (coefficient + 1) * new Random().Next(50, 100);
|
||||
money += (coefficient + 1) * Random.Shared.Next(50, 100);
|
||||
string termination = CharacterSet.GetContinuousKilling(coefficient);
|
||||
string msg = $"[ {killer} ] 终结了 [ {death} ]{(termination != "" ? " 的" + termination : "")},获得 {money} 金钱!";
|
||||
if (assists.Length > 1)
|
||||
@ -1163,12 +1164,12 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
foreach (Character other in _queue.Where(c => c != character && c.CharacterState == CharacterState.Actionable && _queue.IndexOf(c) >= _queue.Count / 2).ToList())
|
||||
{
|
||||
// 有 65% 欲望插队
|
||||
if (new Random().NextDouble() < 0.65)
|
||||
if (Random.Shared.NextDouble() < 0.65)
|
||||
{
|
||||
List<Skill> skills = other.Skills.Where(s => s.Level > 0 && s.SkillType == SkillType.SuperSkill && s.Enable && !s.IsInEffect && s.CurrentCD == 0 && other.EP >= s.RealEPCost).ToList();
|
||||
if (skills.Count > 0)
|
||||
{
|
||||
Skill skill = skills[new Random().Next(skills.Count)];
|
||||
Skill skill = skills[Random.Shared.Next(skills.Count)];
|
||||
_castingSuperSkills.Add(other, skill);
|
||||
other.CharacterState = CharacterState.PreCastSuperSkill;
|
||||
_queue.Remove(other);
|
||||
@ -1237,7 +1238,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
pNormalAttack /= total;
|
||||
}
|
||||
|
||||
double rand = new Random().NextDouble();
|
||||
double rand = Random.Shared.NextDouble();
|
||||
|
||||
// 按概率进行检查
|
||||
if (rand < pUseItem)
|
||||
@ -1289,13 +1290,27 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public void Equip(Character character, Item item)
|
||||
{
|
||||
if (character.Equip(item))
|
||||
{
|
||||
EquipItemToSlot type = character.EquipSlot.GetEquipItemToSlot(item);
|
||||
WriteLine($"[ {character} ] 装备了 [ {item.Name} ]。" + (type != EquipItemToSlot.None ? $"({ItemSet.GetEquipSlotTypeName(type)} 栏位)" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
public void Equip(Character character, EquipItemToSlot type, Item item)
|
||||
{
|
||||
if (character.Equip(item, type))
|
||||
{
|
||||
WriteLine($"[ {character} ] 装备了 [ {item.Name} ]。({ItemSet.GetEquipSlotTypeName(type)} 栏位)");
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
public void UnEquip(Character character, EquipItemToSlot type)
|
||||
{
|
||||
Item? item = character.UnEquip(type);
|
||||
if (item != null)
|
||||
{
|
||||
WriteLine($"[ {character} ] 取消装备了 [ {item.Name} ]。({ItemSet.GetEquipSlotTypeName(type)} 栏位)");
|
||||
}
|
||||
|
@ -170,12 +170,12 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// <summary>
|
||||
/// 基础生命值 [ 与初始设定和等级相关 ] [ 与基础力量相关 ]
|
||||
/// </summary>
|
||||
public double BaseHP => Calculation.Round2Digits(InitialHP + (Level - 1) * (17 + 0.68 * InitialHP) + BaseSTR * 17);
|
||||
public double BaseHP => Calculation.Round2Digits(InitialHP + (Level - 1) * (17 + 0.68 * InitialHP) + BaseSTR * 9);
|
||||
|
||||
/// <summary>
|
||||
/// 额外生命值 [ 与额外力量相关 ]
|
||||
/// </summary>
|
||||
public double ExHP => Calculation.Round2Digits(ExSTR * 17);
|
||||
public double ExHP => Calculation.Round2Digits(ExSTR * 9);
|
||||
|
||||
/// <summary>
|
||||
/// 额外生命值2 [ 与技能和物品相关 ]
|
||||
@ -805,7 +805,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为角色穿戴装备(必须使用此方法而不是自己去给EquipSlot里的物品赋值)
|
||||
/// 为角色装备物品(必须使用此方法而不是自己去给EquipSlot里的物品赋值)
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="slot"></param>
|
||||
@ -823,6 +823,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.MagicCardPack);
|
||||
EquipSlot.MagicCardPack = item;
|
||||
item.OnItemEquip(this, EquipItemToSlot.MagicCardPack);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -831,7 +832,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.Weapon);
|
||||
EquipSlot.Weapon = item;
|
||||
item.OnItemEquip(this);
|
||||
item.OnItemEquip(this, EquipItemToSlot.Weapon);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -840,7 +841,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.Armor);
|
||||
EquipSlot.Armor = item;
|
||||
item.OnItemEquip(this);
|
||||
item.OnItemEquip(this, EquipItemToSlot.Armor);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -849,7 +850,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.Shoes);
|
||||
EquipSlot.Shoes = item;
|
||||
item.OnItemEquip(this);
|
||||
item.OnItemEquip(this, EquipItemToSlot.Shoes);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -858,7 +859,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.Accessory1);
|
||||
EquipSlot.Accessory1 = item;
|
||||
item.OnItemEquip(this);
|
||||
item.OnItemEquip(this, EquipItemToSlot.Accessory1);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -867,7 +868,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
UnEquip(EquipItemToSlot.Accessory2);
|
||||
EquipSlot.Accessory2 = item;
|
||||
item.OnItemEquip(this);
|
||||
item.OnItemEquip(this, EquipItemToSlot.Accessory2);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
@ -880,29 +881,90 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
return result;
|
||||
}
|
||||
|
||||
public void UnEquip(EquipItemToSlot type)
|
||||
/// <summary>
|
||||
/// 为角色装备物品(必须使用此方法而不是自己去给EquipSlot里的物品赋值)<para/>
|
||||
/// 此方法为根据物品类型,优先空位自动装备
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public bool Equip(Item item)
|
||||
{
|
||||
switch (item.ItemType)
|
||||
{
|
||||
case ItemType.MagicCardPack:
|
||||
return Equip(item, EquipItemToSlot.MagicCardPack);
|
||||
case ItemType.Weapon:
|
||||
return Equip(item, EquipItemToSlot.Weapon);
|
||||
case ItemType.Armor:
|
||||
return Equip(item, EquipItemToSlot.Armor);
|
||||
case ItemType.Shoes:
|
||||
return Equip(item, EquipItemToSlot.Shoes);
|
||||
case ItemType.Accessory:
|
||||
if (EquipSlot.Accessory1 != null && EquipSlot.Accessory2 is null)
|
||||
{
|
||||
return Equip(item, EquipItemToSlot.Accessory2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Equip(item, EquipItemToSlot.Accessory1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消装备,返回被取消的物品对象
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Item? UnEquip(EquipItemToSlot type)
|
||||
{
|
||||
Item? result = null;
|
||||
switch (type)
|
||||
{
|
||||
case EquipItemToSlot.MagicCardPack:
|
||||
EquipSlot.MagicCardPack?.OnItemUnequip();
|
||||
if (EquipSlot.MagicCardPack != null)
|
||||
{
|
||||
result = EquipSlot.MagicCardPack;
|
||||
EquipSlot.MagicCardPack.OnItemUnEquip(EquipItemToSlot.MagicCardPack);
|
||||
}
|
||||
break;
|
||||
case EquipItemToSlot.Weapon:
|
||||
EquipSlot.Weapon?.OnItemUnequip();
|
||||
if (EquipSlot.Weapon != null)
|
||||
{
|
||||
result = EquipSlot.Weapon;
|
||||
EquipSlot.Weapon.OnItemUnEquip(EquipItemToSlot.Weapon);
|
||||
}
|
||||
break;
|
||||
case EquipItemToSlot.Armor:
|
||||
EquipSlot.Armor?.OnItemUnequip();
|
||||
if (EquipSlot.Armor != null)
|
||||
{
|
||||
result = EquipSlot.Armor;
|
||||
EquipSlot.Armor.OnItemUnEquip(EquipItemToSlot.Armor);
|
||||
}
|
||||
break;
|
||||
case EquipItemToSlot.Shoes:
|
||||
EquipSlot.Shoes?.OnItemUnequip();
|
||||
if (EquipSlot.Shoes != null)
|
||||
{
|
||||
result = EquipSlot.Shoes;
|
||||
EquipSlot.Shoes.OnItemUnEquip(EquipItemToSlot.Shoes);
|
||||
}
|
||||
break;
|
||||
case EquipItemToSlot.Accessory1:
|
||||
EquipSlot.Accessory1?.OnItemUnequip();
|
||||
if (EquipSlot.Accessory1 != null)
|
||||
{
|
||||
result = EquipSlot.Accessory1;
|
||||
EquipSlot.Accessory1.OnItemUnEquip(EquipItemToSlot.Accessory1);
|
||||
}
|
||||
break;
|
||||
case EquipItemToSlot.Accessory2:
|
||||
EquipSlot.Accessory2?.OnItemUnequip();
|
||||
if (EquipSlot.Accessory2 != null)
|
||||
{
|
||||
result = EquipSlot.Accessory2;
|
||||
EquipSlot.Accessory2.OnItemUnEquip(EquipItemToSlot.Accessory2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1046,7 +1108,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
}
|
||||
}
|
||||
|
||||
if (Items.Count > 0)
|
||||
if (EquipSlot.Any())
|
||||
{
|
||||
builder.AppendLine("== 装备栏 ==");
|
||||
if (EquipSlot.MagicCardPack != null)
|
||||
@ -1081,7 +1143,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
}
|
||||
}
|
||||
|
||||
if (Effects.Count > 0)
|
||||
if (Effects.Where(e => e.EffectType != EffectType.Item).Any())
|
||||
{
|
||||
builder.AppendLine("== 状态栏 ==");
|
||||
foreach (Effect effect in Effects.Where(e => e.EffectType != EffectType.Item))
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Milimoe.FunGame.Core.Entity
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色的装备槽位
|
||||
@ -29,5 +31,47 @@
|
||||
/// 饰品2
|
||||
/// </summary>
|
||||
public Item? Accessory2 { get; internal set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 是否有任意装备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Any()
|
||||
{
|
||||
return MagicCardPack != null || Weapon != null || Armor != null || Shoes != null || Accessory1 != null || Accessory2 != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物品所装备的栏位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public EquipItemToSlot GetEquipItemToSlot(Item item)
|
||||
{
|
||||
if (MagicCardPack == item)
|
||||
{
|
||||
return EquipItemToSlot.MagicCardPack;
|
||||
}
|
||||
else if (Weapon == item)
|
||||
{
|
||||
return EquipItemToSlot.Weapon;
|
||||
}
|
||||
else if (Armor == item)
|
||||
{
|
||||
return EquipItemToSlot.Armor;
|
||||
}
|
||||
else if (Shoes == item)
|
||||
{
|
||||
return EquipItemToSlot.Shoes;
|
||||
}
|
||||
else if (Accessory1 == item)
|
||||
{
|
||||
return EquipItemToSlot.Accessory1;
|
||||
}
|
||||
else if (Accessory2 == item)
|
||||
{
|
||||
return EquipItemToSlot.Accessory2;
|
||||
}
|
||||
return EquipItemToSlot.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Interface.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Entity
|
||||
@ -20,6 +21,11 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// </summary>
|
||||
public virtual string GeneralDescription { get; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 物品的背景故事
|
||||
/// </summary>
|
||||
public virtual string BackgroundStory { get; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 物品类型
|
||||
/// </summary>
|
||||
@ -134,7 +140,7 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// <summary>
|
||||
/// 当装备物品时
|
||||
/// </summary>
|
||||
public void OnItemEquip(Character character)
|
||||
public void OnItemEquip(Character character, EquipItemToSlot type)
|
||||
{
|
||||
Character = character;
|
||||
Character.Items.Add(this);
|
||||
@ -153,12 +159,13 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Character != null) OnItemEquipped(Character, this, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当取消装备物品时
|
||||
/// </summary>
|
||||
public void OnItemUnequip()
|
||||
public void OnItemUnEquip(EquipItemToSlot type)
|
||||
{
|
||||
if (Character != null)
|
||||
{
|
||||
@ -178,7 +185,29 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
e.OnEffectLost(Character);
|
||||
}
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case EquipItemToSlot.MagicCardPack:
|
||||
Character.EquipSlot.MagicCardPack = null;
|
||||
break;
|
||||
case EquipItemToSlot.Weapon:
|
||||
Character.EquipSlot.Weapon = null;
|
||||
break;
|
||||
case EquipItemToSlot.Armor:
|
||||
Character.EquipSlot.Armor = null;
|
||||
break;
|
||||
case EquipItemToSlot.Shoes:
|
||||
Character.EquipSlot.Shoes = null;
|
||||
break;
|
||||
case EquipItemToSlot.Accessory1:
|
||||
Character.EquipSlot.Accessory1 = null;
|
||||
break;
|
||||
case EquipItemToSlot.Accessory2:
|
||||
Character.EquipSlot.Accessory2 = null;
|
||||
break;
|
||||
}
|
||||
Character.Items.Remove(this);
|
||||
OnItemUnEquipped(Character, this, type);
|
||||
}
|
||||
Character = null;
|
||||
}
|
||||
@ -188,11 +217,8 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// </summary>
|
||||
public void UseItem(ActionQueue queue, Character character, List<Character> enemys, List<Character> teammates)
|
||||
{
|
||||
if (Skills.Active != null)
|
||||
{
|
||||
Skills.Active.OnSkillCasted(queue, character, enemys, teammates);
|
||||
}
|
||||
OnItemUsed();
|
||||
OnItemUsed(character, this);
|
||||
Skills.Active?.OnSkillCasted(queue, character, enemys, teammates);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -200,18 +226,52 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// </summary>
|
||||
public void UseItem(/*Inventory inventory*/)
|
||||
{
|
||||
|
||||
OnItemUsed();
|
||||
if (User != null) OnItemUsed(User, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物品被使用时
|
||||
/// 当物品被角色使用时
|
||||
/// </summary>
|
||||
public virtual void OnItemUsed()
|
||||
/// <param name="character"></param>
|
||||
/// <param name="item"></param>
|
||||
public virtual void OnItemUsed(Character character, Item item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物品被玩家使用时
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="item"></param>
|
||||
public virtual void OnItemUsed(User user, Item item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物品被装备时
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="type"></param>
|
||||
public virtual void OnItemEquipped(Character character, Item item, EquipItemToSlot type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物品被取消装备时
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="type"></param>
|
||||
public virtual void OnItemUnEquipped(Character character, Item item, EquipItemToSlot type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected Item(ItemType type, bool isInGame = true, EquipSlotType slot = EquipSlotType.None)
|
||||
{
|
||||
ItemType = type;
|
||||
@ -235,6 +295,16 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示物品的详细信息
|
||||
/// </summary>
|
||||
/// <param name="isShowGeneralDescription">是否显示通用描述,而不是描述</param>
|
||||
/// <returns></returns>
|
||||
public string ToString(bool isShowGeneralDescription)
|
||||
{
|
||||
StringBuilder builder = new();
|
||||
|
||||
@ -267,12 +337,26 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
builder.AppendLine($"此物品将在 {NextTradableTime.ToString(General.GeneralDateTimeFormatChinese)} 后可交易");
|
||||
}
|
||||
|
||||
if (isShowGeneralDescription && GeneralDescription != "")
|
||||
{
|
||||
builder.AppendLine("物品描述:" + GeneralDescription);
|
||||
}
|
||||
else if (Description != "")
|
||||
{
|
||||
builder.AppendLine("物品描述:" + Description);
|
||||
}
|
||||
|
||||
if (Skills.Active != null) builder.AppendLine($"{Skills.Active.ToString()}");
|
||||
foreach (Skill skill in Skills.Passives)
|
||||
{
|
||||
builder.AppendLine($"{skill.ToString()}");
|
||||
}
|
||||
|
||||
if (BackgroundStory != "")
|
||||
{
|
||||
builder.AppendLine("\r\n" + BackgroundStory);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
@ -286,6 +370,24 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
return other is Item c && c.Id + "." + c.Name == Id + "." + Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置一些属性给从 <see cref="ItemModule"/> 新建来的 <paramref name="item"/><para/>
|
||||
/// 通常,在使用 JSON 反序列化 Item,且从 <see cref="ItemModule.GetItem(long, string, ItemType)"/> 中获取了实例后,需要使用此方法复制给新实例
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void SetPropertyToItemModuleNew(Item item)
|
||||
{
|
||||
item.WeaponType = WeaponType;
|
||||
item.EquipSlotType = EquipSlotType;
|
||||
item.Equipable = Equipable;
|
||||
item.IsPurchasable = IsPurchasable;
|
||||
item.Price = Price;
|
||||
item.IsSellable = IsSellable;
|
||||
item.NextSellableTime = NextSellableTime;
|
||||
item.IsTradable = IsTradable;
|
||||
item.NextTradableTime = NextTradableTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所属的角色
|
||||
/// </summary>
|
||||
|
@ -337,7 +337,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon.Example
|
||||
}
|
||||
}
|
||||
|
||||
public override Skill? GetSkill(long id, string name)
|
||||
public override Skill? GetSkill(long id, string name, SkillType type)
|
||||
{
|
||||
// 此方法将根据id和name,返回一个你继承实现了的类对象。
|
||||
return Factory.GetSkill();
|
||||
@ -367,7 +367,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon.Example
|
||||
}
|
||||
}
|
||||
|
||||
public override Item? GetItem(long id, string name)
|
||||
public override Item? GetItem(long id, string name, ItemType type)
|
||||
{
|
||||
// 此方法将根据id和name,返回一个你继承实现了的类对象。
|
||||
return Factory.GetItem();
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Interface.Addons;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
{
|
||||
@ -40,8 +41,9 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Item? GetItem(long id, string name);
|
||||
public abstract Item? GetItem(long id, string name, ItemType type);
|
||||
|
||||
/// <summary>
|
||||
/// 加载模组
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Interface.Addons;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
{
|
||||
@ -40,8 +41,9 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Skill? GetSkill(long id, string name);
|
||||
public abstract Skill? GetSkill(long id, string name, SkillType type);
|
||||
|
||||
/// <summary>
|
||||
/// 加载模组
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Common.Architecture;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
@ -25,6 +26,43 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
||||
case nameof(Item.ItemType):
|
||||
result.ItemType = (ItemType)reader.GetInt32();
|
||||
break;
|
||||
case nameof(Item.WeaponType):
|
||||
result.WeaponType = (WeaponType)reader.GetInt32();
|
||||
break;
|
||||
case nameof(Item.EquipSlotType):
|
||||
result.EquipSlotType = (EquipSlotType)reader.GetInt32();
|
||||
break;
|
||||
case nameof(Item.Equipable):
|
||||
result.Equipable = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Item.IsPurchasable):
|
||||
result.IsPurchasable = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Item.Price):
|
||||
result.Price = reader.GetDouble();
|
||||
break;
|
||||
case nameof(Item.IsSellable):
|
||||
result.IsSellable = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Item.NextSellableTime):
|
||||
string dateString = reader.GetString() ?? "";
|
||||
if (DateTime.TryParseExact(dateString, General.GeneralDateTimeFormat, null, System.Globalization.DateTimeStyles.None, out DateTime date))
|
||||
{
|
||||
result.NextSellableTime = date;
|
||||
}
|
||||
else result.NextSellableTime = DateTime.MinValue;
|
||||
break;
|
||||
case nameof(Item.IsTradable):
|
||||
result.IsTradable = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Item.NextTradableTime):
|
||||
dateString = reader.GetString() ?? "";
|
||||
if (DateTime.TryParseExact(dateString, General.GeneralDateTimeFormat, null, System.Globalization.DateTimeStyles.None, out date))
|
||||
{
|
||||
result.NextTradableTime = date;
|
||||
}
|
||||
else result.NextTradableTime = DateTime.MinValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +73,15 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
||||
writer.WriteNumber(nameof(Item.Id), (int)value.Id);
|
||||
writer.WriteString(nameof(Item.Name), value.Name);
|
||||
writer.WriteNumber(nameof(Item.ItemType), (int)value.ItemType);
|
||||
writer.WriteNumber(nameof(Item.WeaponType), (int)value.WeaponType);
|
||||
writer.WriteNumber(nameof(Item.EquipSlotType), (int)value.EquipSlotType);
|
||||
writer.WriteBoolean(nameof(Item.Equipable), value.Equipable);
|
||||
writer.WriteBoolean(nameof(Item.IsPurchasable), value.IsPurchasable);
|
||||
writer.WriteNumber(nameof(Item.Price), value.Price);
|
||||
writer.WriteBoolean(nameof(Item.IsSellable), value.IsSellable);
|
||||
writer.WriteString(nameof(Item.NextSellableTime), value.NextSellableTime.ToString(General.GeneralDateTimeFormat));
|
||||
writer.WriteBoolean(nameof(Item.IsTradable), value.IsTradable);
|
||||
writer.WriteString(nameof(Item.NextTradableTime), value.NextTradableTime.ToString(General.GeneralDateTimeFormat));
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
EquipItemToSlot.Armor => "防具",
|
||||
EquipItemToSlot.Shoes => "鞋子",
|
||||
EquipItemToSlot.Accessory1 => "饰品1",
|
||||
EquipItemToSlot.Accessory2 => "饰品",
|
||||
EquipItemToSlot.Accessory2 => "饰品2",
|
||||
_ => ""
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user