using System;
using System.Collections.Generic;
namespace BITKit
{
#region 物品枚举
public enum ItemQuality
{
///
/// 常见的
///
Common,
///
/// 罕见的
///
Uncommon,
///
/// 稀有的
///
Rare,
///
/// 史诗的
///
Epic,
///
/// 传奇的
///
Legendary,
///
/// 神话的
///
Mythical,
///
/// 开发者
///
Develop,
}
#endregion
#region 物品接口
///
/// 物品属性
///
public interface IScriptableItemProperty
{
}
///
/// 控制器(分)类
///
public interface IScriptableControllerClass
{
}
///
/// 基础物品
///
public interface IScriptableItem
{
///
/// 唯一Id
///
int Id { get; }
///
/// 物品名,一般用于查找物品的主键
///
string Name { get; }
///
/// 物品描述
///
string Description { get; }
///
/// 最大堆叠数量
///
public int MaxStack { get; }
///
/// 物品品质
///
ItemQuality Quality { get; }
///
/// 属性
///
IReadOnlyDictionary Properties { get; }
///
/// 控制器类
///
IScriptableControllerClass ControllerClass { get; }
///
/// 价值
///
///
int Value => 10;
///
/// 创建运行时物品
///
///
IRuntimeItem CreateRuntimeItem();
}
public interface IRuntimeItem : ICloneable
{
///
/// 运行时Id
///
public int Id { get; set; }
///
/// 配置Id
///
public int ScriptableId { get; }
///
/// 数量
///
public int Amount { get; set; }
///
/// 运行时属性
///
IDictionary RuntimeProperties { get; }
///
/// 当运行时属性改变时
///
// ReSharper disable once EventNeverInvoked.Global
event Action OnRuntimePropertiesChanged;
}
#endregion
#region 物品实现
///
/// 被托管的物品
///
[Serializable]
public struct RuntimeItem : IRuntimeItem
{
public static RuntimeItem Create()
{
var item = new RuntimeItem()
{
Id = new Random().Next(),
RuntimeProperties =
new Dictionary()
};
return item;
}
public int Id { get; set; }
public int ScriptableId { get; set; }
public int Amount { get; set; }
public IDictionary RuntimeProperties { get; set; }
public event Action OnRuntimePropertiesChanged;
object ICloneable.Clone()
{
return new RuntimeItem
{
Id = new Random().Next(),
ScriptableId = ScriptableId,
Amount = Amount,
RuntimeProperties = new Dictionary(RuntimeProperties),
OnRuntimePropertiesChanged = null,
};
}
}
#endregion
}