I have an idea of a short, quick game I want to make, but it involves a bit of 'SimCity' style management. Here's a simplified idea of what I want:
What I have is a 2d grid map; one or more squares are set as 'generators' and produce power, others are 'buildings' and have to be connected to another powered structure such as another building, or a generator to receive power.
Now, I can get a simple 'powering up' to work, but it's not perfect since if you shut the generator down, the buildings don't power down properly. I'm doing this by checking the buildings next to the current one and if one of them is powered, then the current building also gets powered. Of course, this doesn't work when you turn off the generator because two or more buildings will 'recharge' themselves. I've tried several variations on the basic theory, and none of them seem to work properly.
I hope this makes sense, if not I'll post a simple example. There has to be a simple way of doing this, I can't see using a complex pathfinding routine for every single building as that would really slow everything down and over complicate things.
Any thoughts? Ta. :)
What I have is a 2d grid map; one or more squares are set as 'generators' and produce power, others are 'buildings' and have to be connected to another powered structure such as another building, or a generator to receive power.
Now, I can get a simple 'powering up' to work, but it's not perfect since if you shut the generator down, the buildings don't power down properly. I'm doing this by checking the buildings next to the current one and if one of them is powered, then the current building also gets powered. Of course, this doesn't work when you turn off the generator because two or more buildings will 'recharge' themselves. I've tried several variations on the basic theory, and none of them seem to work properly.
I hope this makes sense, if not I'll post a simple example. There has to be a simple way of doing this, I can't see using a complex pathfinding routine for every single building as that would really slow everything down and over complicate things.
Any thoughts? Ta. :)