Okay, so I’ve researched scriptable objects and I’ve realized that it’s something that might be very useful for the kind of game I’m making. I’ve managed to create my own scriptable object for weapons that is able to hold weapon upgrades, range, damage, and other special stuff.
I was told scriptable objects are much better for larger scales than enums so that I can hold data for each weapon. I do know how to implement them into
[CreateAssetMenu(fileName = "New Weapon", menuName = "Weapon")]
public class Weapon : ScriptableObject
{
public new string name;
public string _discription;
public Sprite _artwork;
public int _range;
public int _damage;
public int _upgrades;
public int _element;
public void Print()
{
Debug.Log(name + ": " + _discription + " The weapon does: " + _damage + "damage.");
}
}
I’ve researched how to show these on the UI, but is there any hint you could give me on getting scriptable objects working with an inventory system, and point me in a direction on how I can give the player control of the order of weapon in the inventory that the game will use to give said weapons in the same order the player set for themselves.
For Example, I want the player to be able to take any of the four weapons: Katana, Spear, Axe, Chakram, and be able to set them in any order. Even using multiple of itself. (Chakram, Spear, Spear, Axe, for example) and then the game will then give the player the items list they created on a set timer.
public class Weapon
{
public WeaponType type { get; set; }
}
public enum WeaponType
{
Katana,
Axe,
Spear,
Chakram
}
public class WeaponCycle: MonoBehaviour
{
[SerializeField] private Weapon[] _weapon;
public Weapon[] weapons = new Weapon[4];
List<Weapon> InventoryWeapons = new List<Weapon>();
// Start is called before the first frame update
void Start()
{
for (int i = 0; i < weapons.Length; i++)
{
weapons*.type = (WeaponType)Random.Range(0, 3);*
}
StartCoroutine(GiveWeapons(1));
}
IEnumerator GiveWeapons(float delay)
{
for (int i = 0; i < weapons.Length; i++)
{
yield return new WaitForSeconds(delay);
InventoryWeapons.Add(weapons*);*
}
}
}
Sorry if it feels like I’m asking for too much, but I’m a beginner when it comes to C# and I’m trying to learn as efficiently as I can.