youvsvirus / youvsvirus-unity

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

Using from now on q as exit key #126

Closed maccxs closed 4 years ago

maccxs commented 4 years ago
holke commented 4 years ago

At least in the supermarket level i can continue playing the game and even finish it after i pressed q. The exit canvas pops up, but everything else keeps on running in the background. I did not test it for the other level but guess it is the same there.

Maybe resolve this by pausing the game when q is pressed?

maccxs commented 4 years ago

I tried with pausing the game, but then if I press "Retry" the game is still paused. Any ideas how to fix that?

holke commented 4 years ago

In sandbox mode when i press 'c' or 'q' twice then it ends. I restart and it ends after 5 seconds again. Possibly because the input is cached somewhere and this is then read in the next round as a key press. Thus, we should find out how to delete this internal cache and do so before a level starts.

holke commented 4 years ago

I just made two updates.

  1. It was possible that the ELC triggered the EndGamePlayerExposed and EndGamePlayerAtHome simultaneously. I deactivated this behaviour. Now once one of the ending routines is called, no other can be called. This also fixed the issue in the sandbox mode described in my comment above.

  2. The ELC now has a public variable testMode, which we can set in the scene view. If true, then pressing c will finish the level. If false it does not. This way, we wont have to delete any code to deactivate test mode. We just need to uncheck the box for each endlevelcontroller in the level scene view of the unity editor.

holke commented 4 years ago

i was too quick there. The problem still exists.

holke commented 4 years ago

Ok, i know where this comes from. The level gets ended by pressing ´c´ or ´q´ and when we then restart quickly enought, somehow, the DelayedEndLevel routine is running and terminates the new level after a few seconds.

This is particularly weird since the whole elc should be a new instance when the sandbox is restarted... Also i tried to stop the coroutines when exiting but did not succeed.

holke commented 4 years ago

I am using this as a rubber duck now...

i am getting closer to the cause of this. Somehow, when we restart the sandbox, the elc sometimes registers 0 active infections. And this then triggers the CheckEndCondition and finishes the level.

holke commented 4 years ago

Ok, i think i have it. It is unrelated to pressing the buttons.

Sometimes the Start() Routine of HumanBase is called before the Start() routine of HumanInstants. This is due to the fact, that the order in which the Start() routines are called is undefined.

When an NPC starts as infected, this is set by SetInitialCondition in HumanInstants::CreateHumans which is called during Start.

This initial infected NPC is only passed on to the EndLevelController in the NPCs Start() routine at

SetCondition(_initialCondition);

but, if the NPCs Start() routine was already executed before its InitialCondition was set by the HumanBase start, then this Info does not get passed on to the EndLevelController. And thus, the ELC thinks that there are 0 infected NPCs and hence wants to finish the game.

This also causes the ELC to think that there are less infected humans then actually are.

holke commented 4 years ago

I think this is unrelated to the q key and opened a new issue.

holke commented 4 years ago

I think we can merge this as soon as leveldemo is reviewed

holke commented 4 years ago

If i get infected in demo level and then retry the game is paused

holke commented 4 years ago

If i get infected in demo level and then retry the game is paused

Solved by improving the PauseGame class.

maccxs commented 4 years ago

If i get infected in demo level and then retry the game is paused

Solved by improving the PauseGame class.

Did you already commit this? I have the same problem in the disco level

maccxs commented 4 years ago

If i get infected in demo level and then retry the game is paused

Solved by improving the PauseGame class.

This really puzzled me since it got worse after your commit. However, gamePaused was not set to true in your code. Fixed in 70c33e5

maccxs commented 4 years ago

Damn, thats embarrassing for me :(

Dont't worry about it.

ter we are through with this we should however discuss our branching and reviewing workflow and the public NPC number stuff.

Yes, sorry that this was so chaotic. We should definitely fix some guidlines which also take into account that merging stuff in unity is a pain.