Announcement

Collapse
No announcement yet.

Best way to store upgrades

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Best way to store upgrades

    Hello,
    I am currently doing an upgrade system for buildings that works this way:

    Each building has an array which contains the upgrades options (as structs)
    My structs are made like this: name, cost, time, and boolean (to check if this upgrade is already done)

    But it feels a bit amateur to me and I'm afraid of doing it wrong.
    Can someone give me a piece of advice on that?

    Thanks a lot

    #2
    Depends a bit on the upgrade system. First of all, I would take the name,cost,time out of there and somehow create a data table of upgrades for easier tweaking.
    If upgrades are some kind of attachments, then I think a boolean would be useful.
    But if it's a classical upgrade that replaces the structure like Tent->Hut->House, then I would use a state instead. It could be an enum, or it could be a name variable.
    If it's a Name variable, then the name would be set to "Tent" or "hut or "house" etc. Then, when wanting to see what upgrades the building has, check the data table for that name. The data table could then also hold other information like what units to train or research can be done etc.

    Comment

    Working...
    X