Week 9 Friday Game resetting if Generation failed.

Week 9 Friday Game resetting if Generation failed.

Yesterday after writing down the algorithm (for the conditions in which the PLG knows the level has failed) I implemented and it worked with the first attempt.
Next up was a way to reset and start again the level generation.
the most painless process is reloading the scene so you reset the variables and make sure all components have been deleted.
 I encountered a problem though after the initial attempt when the scene is reloaded the source light does not seem to work. I thought for some reason the light needed to be in outside the scene. but that did not seem to work. I also realized that the light source would probably change and it is not needed to be placed at the beginning of the scene but way after after the loot and enemy placement.
For visibility though I have scripted so you assign a lightsource prefab that is placed right after we get a good level.

Below is a test run were I have put the exit scan line too far away, so the level can never find preexit rooms so it will never create a good level. As I mention in my previous post, the level checks the density, once it reaches the desired value of density set by the user it begins to check if there is a preexit and attach the exit. If it does not find a exit it sets a counter to 10 which declines every time we try to add another tile. Because of the way we setup our exit scan line (in this example), an exit is never found so the program will add another 10 pieces try again in a endless loop. This is why we break the loop and declare the level as bad. To break the loop one of two things need to happen.

  1.  There are no more OpenExits available.
  2.  The density has now reached our max density. which is a value set in the editor.



Below is the current script, the level starts without a light source, when the level is successful we then add the lightsource.



Next step is capping the outside exits and calculating the path from start to exit.

Comments

Popular posts from this blog

Player stats and brightness.

Testing the PLG

More work done on the interface, saving data.