上节开发了背包系统物品的基类,这节继续开发它的子类---消耗品、装备、武器材料类
各个子类继承了基类并且有各自的属性及构造方法,子类的拷贝参构造是拷贝的父类的属性在加上子类的属性;下面上代码:
Consumable类的:
public class Consumable : Item
{
#region 属性
/// <summary>
/// HP
/// </summary>
public int HP { get; set; }
/// <summary>
/// MP
/// </summary>
public int MP { get; set; }
#endregion 属性
/// <summary>
/// 构造方法
/// </summary>
/// 父类构造
/// <param name="id">ID</param>
/// <param name="name">名称</param>
/// <param name="itemType">物品类型</param>
/// <param name="quality">品质</param>
/// <param name="des">描述</param>
/// <param name="capacity">容量</param>
/// <param name="buyPrice">购买价格</param>
/// <param name="sellPrice">出售价格</param>
/// <param name="sprite">图标</param>
/// 本身构造
/// <param name="hp">HP</param>
/// <param name="mp">MP</param>
public Consumable(int id, string name, ItemType itemType, QualityType quality, string des, int capacity, int buyPrice, int sellPrice, string sprite,
int hp, int mp)
: base(id, name, itemType, quality, des, capacity, buyPrice, sellPrice, sprite)
{
this.HP = hp;
this.MP = mp;
}
/// &l