I have three classes: a base Item class as well as two classes inheriting from it: Weapon and Ammo.
public class Item {
public string name;
public Texture2D icon;
}
public class Weapon : Item {
public int ammo_max;
public int damage;
}
public class Ammo : Item {
public int amount;
}
So far, so good. Now my problem: I want to have grenades that can be both: Weapon and Ammo. They could be loaded as Ammo for a grenade launcher (Weapon) or they could be a Weapon themselves (thrown). Is there an elegant way of accomplishing this, or have I walled myself in with my item inheritance? :)
↧