C# InventorySystem项目列表及其子类Permanents Bug

C# InventorySystem项目列表及其子类Permanents Bug,c#,list,unity3d,subclass,C#,List,Unity3d,Subclass,嘿,我的库存系统需要一些帮助。这是非常简单的-我猜-但我有一些问题,我无法找到一个在线解决方案 //!!据我所知,这是最小的 我在大学的任务是做一个包含子类的系统。在我添加子类之前,它工作得很好。。显然,项目是在开始时创建并添加到库存中的,但不知何故,子部分和整个项目似乎在某个点被覆盖。我的猜测是,当永久物的子类被添加时,物品列表将在以后引起问题 不管怎样,我刚开始,我找不到问题 任何帮助都将不胜感激——或者为我指出正确的方向,让我能够阅读给定的问题 干杯并提前表示感谢 项目数据库 public

嘿,我的库存系统需要一些帮助。这是非常简单的-我猜-但我有一些问题,我无法找到一个在线解决方案

//!!据我所知,这是最小的

我在大学的任务是做一个包含子类的系统。在我添加子类之前,它工作得很好。。显然,项目是在开始时创建并添加到库存中的,但不知何故,子部分和整个项目似乎在某个点被覆盖。我的猜测是,当永久物的子类被添加时,物品列表将在以后引起问题

不管怎样,我刚开始,我找不到问题

任何帮助都将不胜感激——或者为我指出正确的方向,让我能够阅读给定的问题

干杯并提前表示感谢

项目数据库

public class ItemDatabase : MonoBehaviour
{
    public List<Item> items = new List<Item>();

    void Start ()
    {
        items.Add(new Permanent(0, "Iron Armor", "The armor has seen battle.", 0, Item.ItemType.Permanent, 110, 20000, 6640, 600, 100, true, "Torso", 5, -5, 10, 50));
        items.Add(new Consumable(139, "Healing Potion", "Brew that will restore health.", 1, Item.ItemType.Consumable, 30, 800, 720, 100, 100, 1, 3, 50, 0, 0, 0));
        items.Add(new Permanent(376, "Bronze Sword", "The sword is made with poor quality bronze.", 0, Item.ItemType.Permanent, 5, 1480, 820, 480, 100, true, "Hand", 5, -5, 10, 50));
        items.Add(new Permanent(24, "Gladiator Helmet", "This helmet can kick ass!", 0, Item.ItemType.Permanent, 110, 20000, 6640, 500, 200, true, "Head", 5, -5, 10, 50));

    }
}
消耗品

public class Consumable : Item
{
    public int ccharges;
    public int cmaxcharges;
    public int cstre;
    public int cagil;
    public int cinte;
    public int cwisd;
    public Consumable(int id, string name, string desc, int typeint, ItemType type, int value, float weight, int volume, int sturdiness, int health, int charges, int maxcharges, int stre, int agil, int intl, int wisd) : base(id, name, desc, typeint, type, value, weight, volume, sturdiness, health)
    {
        int ccharges = charges;
        int cmaxcharges = maxcharges;
        int cstre = stre;
        int cagil = agil;
        int cinte = intl;
        int cwisd = wisd;
    }
}

public class Miscellaneous : Item
{
    public bool mquest;

    public Miscellaneous(int id, string name, string desc, int typeint, ItemType type, int value, float weight, int volume, int sturdiness, int health, bool quest) : base(id, name, desc, typeint, type, value, weight, volume, sturdiness, health)
    {
        bool mquest = quest;
    }
}

你绝对应该把它修剪一下在调试器中逐行运行它,检查变量以查看哪里出错。仅仅通过阅读代码进行调试比在野外观察问题要困难几个数量级。
public class Permanent : Item
{
    public bool pequipment;
    public string pequipmentslot;
    public int pstre;
    public int pagil;
    public int pinte;
    public int pwisd;
    public Permanent(int id, string name, string desc, int typeint, ItemType type, int value, float weight, int volume, int sturdiness, int health, bool equipment, string equipmentslot, int stre, int agil, int intl, int wisd) : base(id, name, desc, typeint, type,  value, weight, volume, sturdiness, health)
    {
        bool pequipment = equipment;
        string pequipmentslot = equipmentslot;
        int pstre = stre;
        int pagil = agil;
        int pinte = intl;
        int pwisd = wisd;
    }

}
public class Consumable : Item
{
    public int ccharges;
    public int cmaxcharges;
    public int cstre;
    public int cagil;
    public int cinte;
    public int cwisd;
    public Consumable(int id, string name, string desc, int typeint, ItemType type, int value, float weight, int volume, int sturdiness, int health, int charges, int maxcharges, int stre, int agil, int intl, int wisd) : base(id, name, desc, typeint, type, value, weight, volume, sturdiness, health)
    {
        int ccharges = charges;
        int cmaxcharges = maxcharges;
        int cstre = stre;
        int cagil = agil;
        int cinte = intl;
        int cwisd = wisd;
    }
}
public class Miscellaneous : Item
{
    public bool mquest;

    public Miscellaneous(int id, string name, string desc, int typeint, ItemType type, int value, float weight, int volume, int sturdiness, int health, bool quest) : base(id, name, desc, typeint, type, value, weight, volume, sturdiness, health)
    {
        bool mquest = quest;
    }
}