youvsvirus / youvsvirus-unity

Unity version of the you vs virus game.
GNU General Public License v3.0
1 stars 1 forks source link

Margrit/game ended early #51

Closed maccxs closed 4 years ago

maccxs commented 4 years ago

Sometimes after restart in the endscreen, the game just ended . This was probably due to activeInfections=0 and initComplete = true.

ghost commented 4 years ago

Your fix worked fine. Calling initComplete() in HumanBase's Start() was a little problematic, though, because it would tell the end game controller that initialization was complete when only one human got initiated. But since, due to your fix to the script execution order, all human Start() calls would happen before the next call to EndGameController.Update(), it worked fine.

I found an even easier fix: CreatePopulation now creates all humans not in its Start, but in its Awake method. This way, all humans get created at scene creation instead of the first frame. Now, through script exec order, the humans' Start() method is guaranteed to be run before EndGameController's Start() method. So, the first time EndGameController's Update() is called, all humans are definitely started and will already be counted in the end game controller. This change made initComplete() obsolete, so I removed it.

Also, I fixed two minor bugs I found along the way.