-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented pausing the game in PauseMenuTimeStopComponent via disabl…
…ing the entities on screen. Does not yet handle incoming waves.
- Loading branch information
1 parent
e0f2eb1
commit 29192a8
Showing
1 changed file
with
20 additions
and
2 deletions.
There are no files selected for viewing
22 changes: 20 additions & 2 deletions
22
source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuTimeStopComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
package com.csse3200.game.components.pausemenu; | ||
|
||
import com.csse3200.game.components.Component; | ||
import com.csse3200.game.entities.Entity; | ||
import com.badlogic.gdx.utils.Array; | ||
import com.csse3200.game.services.ServiceLocator; | ||
|
||
/** | ||
* Handles the pausing/resuming of time when the pause menu is brought up/put away. | ||
*/ | ||
public class PauseMenuTimeStopComponent extends Component { | ||
|
||
private Array<Entity> freezeList; | ||
public PauseMenuTimeStopComponent() { | ||
} | ||
|
||
/** | ||
* Handles the pausing of the game entities when the pause menu is made. | ||
*/ | ||
@Override | ||
public void create() { | ||
ServiceLocator.getTimeSource().setTimeScale(0f); | ||
freezeList = ServiceLocator.getEntityService().getEntities(); | ||
for (Entity pauseTarget : freezeList) { | ||
if (pauseTarget.getId() != getEntity().getId()) { | ||
// ZA WARUDO! TOKI WO TOMARE! | ||
pauseTarget.setEnabled(false); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Handles the un-pausing of the game entities when the pause menu is closed. | ||
*/ | ||
@Override | ||
public void dispose() { | ||
ServiceLocator.getTimeSource().setTimeScale(1f); | ||
for (Entity pauseTarget : freezeList) { | ||
pauseTarget.setEnabled(true); | ||
} | ||
} | ||
} |