So I'm making a game where you can send ships to locations to sell or buy resources like wood, iron, gold, etc.
Now I was wondering how the resources should be created in de game. I came up with 2 options
Create a class for each resource:
public class ResourceBase { private int value; // other base properties } public class Gold : ResourceBase { public Gold { this.value = 40 // or whatever } }Create instances of a Resource class
public class Resource { string name; int value; public Resource(string name, int value) { this.name = name; this.value = value; } } // later on... Resource gold = new Resource("Gold",40);
With the second option it's possible to fill the game resources from a resources.json file, I kinda like that structure.
New ideas / design patterns / structures are always welcome!
EDIT: It's a little bit like Assassins Creed Black Flag's companion app. See the resource bar on the image below
EDIT 2: I've done some more research on the "load items/resources from JSON file" and found this blog: Power of JSON in Game Development - Items. It shows the best of option 1 and option 2. You're still able to add functionality to each resource :)

enuminstead. – Nolonar 13 hours ago