Vehicle Upgrade System

Hi all,

Imagine you are playing a game. You buy a fighter and get enough experience to upgrade it. You talk to a "mechanic" and a window comes up with buttons displaying the pictures of the components to be upgraded.

And this is where I got stuck.

How would I go about creating a script that will be attached to the "mechanic" that will allow many vehicles to be upgraded with many upgrades. (the upgrades are physical components like new engines, turrets etc requiring the instantiation and parenting of prefabs).

I can create menus and instantiate things but have no Idea how I should do the rest. Arrays have been suggested to me but are handled differently in unity to what I am used to.

Any and all help is appreciated.

Thanks.

Arrays have been suggested to me but are handled differently in unity to what I am used to.

This is probably where I'd start. In C# at least, arrays are handled no differently in Unity than anywhere else. I'm not that familiar with array use in UnityScript, but I do know that the idiosyncratic way in which multi-dimensional arrays were handled has been addressed in the latest version of Unity. Aside from that, I'm willing to bet array use in UnityScript is pretty conventional as well.

So, perhaps you could edit your post (or post a comment) and describe in what way array use seems to differ from what you're used to. Arrays (and containers in general) are invaluable tools, so if there's something keeping you from using them, that's the problem you'll want to address first (IMO).

If you are able to program in C#, you can go beyond arrays and use some of the generic collections to simplify things for yourself. I would think you'd probably want to create some kind of hierarchy of classes to store your upgrade data - e.g. you could start with a class like VehicleUpgrade that stores data like upgrade name, the type of vehicles it applies to, the upgrade category, etc. - but I am sure it will get more complicated quickly. For example, you may have different classes you can add into this one that represent different upgrade components and store their data.

If you are using C#, then you can use collections like strongly-typed lists or dictionaries (e.g. List or Dictionary which is much easier to use and more type-safe than just a plain old array.

But really, for a system like this, it seems like how you structure all of the data about a given upgrade is a lot more complicated than how you store the different upgrades themselves...