2025-01-06 01:44:04 +08:00

150 lines
5.4 KiB
C#

using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Constant;
using Oshima.FunGame.OshimaModules.Effects.ItemEffects;
using Oshima.FunGame.OshimaModules.Skills;
namespace Oshima.FunGame.OshimaModules.Items
{
public class
{
public interface EPBook
{
public double EP { get; set; }
}
public static void Init(Item item, double exp, int remainUseTimes = 1)
{
item.Skills.Active = new (item, exp);
item.RemainUseTimes = remainUseTimes;
item.IsInGameItem = false;
item.IsReduceTimesAfterUse = true;
item.IsRemoveAfterUse = true;
}
public static string UseItem(Item item, Character character)
{
if (item.Skills.Active != null)
{
item.Skills.Active.OnSkillCasted([character]);
string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!";
if (item is EPBook hpBook)
{
msg += $"获得了 {hpBook.EP} 点能量值!";
}
return msg;
}
return "此物品没有主动技能,无法被使用!";
}
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
{
string msg = "";
bool result = false;
Character[] targets = [];
string key = args.Keys.FirstOrDefault(s => s.Equals("targets", StringComparison.CurrentCultureIgnoreCase)) ?? "";
if (key != "" && args.TryGetValue(key, out object? value) && value is Character[] temp)
{
if (temp.Length > 0)
{
targets = [temp[0]];
msg = UseItem(item, temp[0]);
result = true;
}
else
{
msg = $"使用物品失败,没有作用目标!";
}
}
args["msg"] = msg;
key = args.Keys.FirstOrDefault(s => s.Equals("useCount", StringComparison.CurrentCultureIgnoreCase)) ?? "";
if (key != "" && args.TryGetValue(key, out value) && value is int count && targets.Length > 0)
{
string truemsg = $"对角色 [ {targets[0]} ] 使用 {count} 个 [ {item.Name} ] 成功!";
if (item is EPBook expBook)
{
truemsg += $"获得了 {expBook.EP * count} 点能量值!";
}
args["truemsg"] = truemsg;
}
return result;
}
}
public class 1 : Item, .EPBook
{
public override long Id => (long)ConsumableID.1;
public override string Name => "能量饮料";
public override string Description => Skills.Active?.Description ?? "";
public override QualityType QualityType => QualityType.Green;
public double EP { get; set; } = 50;
public 1(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable)
{
User = user;
.Init(this, EP, remainUseTimes);
}
protected override bool OnItemUsed(Dictionary<string, object> args)
{
return .OnItemUsed(this, args);
}
}
public class 2 : Item, .EPBook
{
public override long Id => (long)ConsumableID.2;
public override string Name => "能量饮料 Pro";
public override string Description => Skills.Active?.Description ?? "";
public override QualityType QualityType => QualityType.Blue;
public double EP { get; set; } = 100;
public 2(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable)
{
User = user;
.Init(this, EP, remainUseTimes);
}
protected override bool OnItemUsed(Dictionary<string, object> args)
{
return .OnItemUsed(this, args);
}
}
public class 3 : Item, .EPBook
{
public override long Id => (long)ConsumableID.3;
public override string Name => "能量饮料 Pro Max";
public override string Description => Skills.Active?.Description ?? "";
public override QualityType QualityType => QualityType.Purple;
public double EP { get; set; } = 200;
public 3(User? user = null, int remainUseTimes = 1) : base(ItemType.Consumable)
{
User = user;
.Init(this, EP, remainUseTimes);
}
protected override bool OnItemUsed(Dictionary<string, object> args)
{
return .OnItemUsed(this, args);
}
}
public class : Skill
{
public override long Id => (long)ItemActiveID.;
public override string Name => "能量饮料";
public override string Description => Effects.Count > 0 ? Effects.First().Description : "";
public (Item? item = null, double ep = 0) : base(SkillType.Item)
{
Level = 1;
Item = item;
Effects.Add(new GetEP(this, new()
{
{ "ep", ep }
}));
}
}
}