Unlockable buildings in menu

P

PWL

Guest
In my incremental game about city building I never really dealt with an issue I had with the menu.

The menu:
townstruct_post.PNG

The way it currently works is that you click the blue button on the left to open the buildings-menu (the red ones appear). The problem is that the buildings are unlocked through-out the game, so you have to reopen the menu to see if you have unlocked a new building, because that's when it checks which buildings you have unlocked.

Let's say you have not unlocked the ones I've pointed out (the shield and the fire buttons). How do I implement them being unlocked and appear automatically when you reach a certain amount of points? Should I always have the buttons there and just let each of them check each step if the requirements are met, then make them visible?

There might be a simple solution to this, I just feel a little stuck in my own way of thinking.
 

Yal

GMC Memer
GMC Elder
Another idea is that when the conditions get met (if there's an easy way to check this... you say it's by reaching points, so you'd check the point value), you force the menu to close and reopen if it's already open, making it spawn the new buttons. Should require less reworking than fundamentally changing how the menu works.

Don't forget to have some sort of "unlocked" variable that you trigger upon unlocking so you can stop doing complex calculations for things that are already unlocked... and for that matter, not accidentally closing and reopen the menu each step once you reach the unlock point.
 
P

PWL

Guest
force the menu to close and reopen if it's already open, making it spawn the new buttons. Should require less reworking than fundamentally changing how the menu works.
Good idea. Could save some calculations.

Still curious if there's a better way if I was to rework the menu. The thing I don't like about this idea is that it is more of a workaround just because I didn't design it properly in the first place.
 

Yal

GMC Memer
GMC Elder
There's always a better way to do stuff, so trying to find a perfect solution is just wasting time. Do something that suits your needs and seems 'proper'/'robust' enough that you don't think it'll introduce problems/bugs further down the line. If you end up realizing you made mistakes, you can learn from them, but don't worry too much about fixing problems before you actually run into them. If you spot a problem before it actually becomes a problem, at least it will be easier to fix it, but if you fix potential problems before they actually get in the way, you risk ending up never getting anything done.

It's kinda like fire - it needs fuel, sure, but it also needs oxygen and heat. There's no way something will catch fire unless all three of them are around, so you can fireproof - or extinguish a fire that starts - by just removing one of them.
 
B

Brendan Forish

Guest
I set visible to 0 for all locked UI buttons. In the left click even I have an IF statement at the very beginning to check if its locked too. Ive never run into issue doing this.
 
H

heyimdandan

Guest
Definitely go with a variable that keeps tabs on whether each item is locked. I've set my game up so that all the levels but the first are locked, so you can go back and replay any earlier level once you achieve a certain level of progress. If you use up all your continues then (me being the pig I am) all the levels are relocked!

One thing I've mentioned in past threads is planning out your game on paper before you even go near the keyboard. Adding new game mechanics down the line always causes a lot of grief and can take days to implement new code. I know, I've been there!
 
  • Like
Reactions: Yal

Yal

GMC Memer
GMC Elder
One thing I've mentioned in past threads is planning out your game on paper before you even go near the keyboard. Adding new game mechanics down the line always causes a lot of grief and can take days to implement new code. I know, I've been there!
I'm gonna second this as well. I also find it a lot faster to plan on paper compared to using digital tools - you don't need to waste time navigating menus to doodle something, and you can use any structure you're comfortable with. The hard part with paper is finding stuff again later, though, so make sure you have some structure for development documents.
 
Top