- Home /
Question by
NutellaDaddy · Mar 31, 2014 at 09:28 PM ·
c#inventoryitems
Is there a way to shorten these?
I am defining items and it seems that I have to define them one by one for my inventory like so. using UnityEngine; using System.Collections;
public class AllItems : MonoBehaviour
{
public static Weapon AllWeapons()
{
Weapon machete = new Weapon (10.0f, 0.0f, 3, false, 0, false);
machete.name = "Machete";
machete.description = "A fast bladed weapon";
machete.icon = Resources.Load (ItemGenerator.meleeWeaponPath + machete.name) as Texture2D;;
machete.rarity = RarityType.Common;
machete.curDurability = 150.0f;
machete.maxDurability = 150.0f;
machete.weightAmount = 1;
}
public static Consumable AllConsumables()
{
}
public static Armor AllArmor()
{
}
public static Placeables AllPlaceables()
{
}
}
And that only creates the functions for the items and one weapon. Is there any way to shorten this using anything? I don't want to have to hard code all of these values.
Comment
Best Answer
Answer by getyour411 · Mar 31, 2014 at 10:14 PM
There's always another way to do something (almost always, anyway) but when it comes to the things you are showing this is pretty much it. You could use Random.Range for a few things or have just a few archetypes that everything else is scaled from, but in the end defining items is a bit of a slog.