所以可以说我有这个:
public class Item
{
public int ItemID;
public List<Enchantment> Enchantments; //Enchantment is a class
}
public class Stick: Item
{
public int Damage = 18;
public Stick()
{
ItemID = 4;
}
public void Update()
{
foreach (Enchantment ItemEnchantment in Enchantments)
{
Enchantment.Update();
}
}
}
public class Enchantment
{
public int EnchantmentID;
public void Update()
{
//NEED HELP HERE
Parent.Damage += 2; //How do I know my parent is a (Stick)?
//I thought of giving each item a uniqueID, and two items cannot have the same id, so the enchantment checks the items list for a specific id, and then uses that as the parent class.
//But is there a more efficient way?
}
}
我怎么知道我的父母是(棒)?我想给每个项目一个唯一的ID,两个项目不能有相同的ID,所以结界检查项目列表中的特定ID,然后将其用作父类。但是有没有更有效的方法?
^ 考虑显示努力 Oo ? 我只需要一种更有效的方法来完成这个..