Hi,
I recently received some great help with a question about subclasses and my approach to various item types.
I am now struggling with creating my items - please see below example:
public Item(string name, int cost, string type, string desc){
_Name = name;
_Cost = cost;
_Type = type;
_Desc = desc;
}
The above is in the Item class (Item.cs) and defines an Item, so to create one I use: new Item(“Item”,100,“Consumable”,“This is an Item”)
public class ArmourUpgrade : Item {
public ArmourUpgrade(){
_UpgradeValue = 0;
}
}
I then have this in the ArmourUpgrade class (ArmourUpgrade.cs)…how do I create an ArmourUpgrade in the same way as above?
I’m sure its a simple answer, but I just can’t see it.
Thanks
EDIT:
Update to the question above…
public ArmourUpgrade(string name, int cost, string type, string desc,int UpgVal){
Name = name;
Cost = cost;
Type = type;
Desc = desc;
UpgradeValue = UpgVal;
}
The above code works, so from my Shop script I call ArmourUpgrade(“Upgrade v1”,5,“Upgrade”,“This is Upgrade v1”,“10”), but as al Items have a name, cost, type and desc, does this need to be included in the ArmourUpgrade constructor?
Thanks again.