I have all of these items that I am defining and I wonder if I should have a seperate script for each item because what happens is you find the item on the ground and then you press e on it to pick it up and then when you press E it adds the item to your inventory. Should I put all of the items in one script or make a seperate script for each item?
Here’s how it looks right now using the same script for each item:
using UnityEngine;
using System.Collections;
public class AllItems : MonoBehaviour
{
private const string meleeWeaponPath = "Icons/Weapons/Melee";
public static Weapon AllWeapons()
{
//MELEE WEAPONS
Weapon machete = new Weapon (12.5f, 0.0f, 4, false, 0, false);
machete.name = "Machete";
machete.description = "A fast bladed weapon";
machete.icon = Resources.Load (meleeWeaponPath + machete.name) as Texture2D;;
machete.rarity = RarityType.Common;
machete.curDurability = 150.0f;
machete.maxDurability = 150.0f;
machete.weightAmount = 1;
Weapon shovel = new Weapon (20.0f, 0.0f, 2, false, 0, false);
shovel.name = "Shovel";
shovel.description = "A blunt tool for shoveling the earth.";
shovel.icon = Resources.Load (meleeWeaponPath + shovel.name) as Texture2D;;
shovel.rarity = RarityType.Common;
shovel.curDurability = 150.0f;
shovel.maxDurability = 150.0f;
shovel.weightAmount = 1;
Weapon woodAxe = new Weapon (25.0f, 0.0f, 1, false, 0, false);
shovel.name = "Wood Axe";
shovel.description = "A sharp tool for chopping down trees.";
shovel.icon = Resources.Load (meleeWeaponPath + woodAxe.name) as Texture2D;;
shovel.rarity = RarityType.Uncommon;
shovel.curDurability = 200.0f;
shovel.maxDurability = 200.0f;
shovel.weightAmount = 1;
// BASIC RANGED/Rough Craft
//GUNS
//LASER WEAPONS
return null;
}
public static Consumable AllConsumables()
{
//FOOD
//LIQUID
//MEDICINE OR HEALTH RELATED
return null;
}
public static Armor AllArmor()
{
//BASIC AND MODERN
//ROUGH CRAFT
//POWER OR ADVANCED
return null;
}
public static Placeable AllPlaceables()
{
//BUILDINGS
//STATIONS
return null;
}
public enum ItemType
{
Armor,
Weapon,
Consumable,
Placeable
}
}
Just want to know what you guys would thing would be the best or easiest! Tell me if you have any other ideas.