Skip to content

Commit

Permalink
Created the GameEndService, added it to the Service Locator and initi…
Browse files Browse the repository at this point in the history
…alised it in the Main game
  • Loading branch information
nawal-0 committed Sep 10, 2023
1 parent e9436c2 commit 45f0d05
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
import com.csse3200.game.physics.PhysicsService;
import com.csse3200.game.rendering.RenderService;
import com.csse3200.game.rendering.Renderer;
import com.csse3200.game.services.CurrencyService;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.services.*;
import com.csse3200.game.ui.terminal.Terminal;
import com.csse3200.game.ui.terminal.TerminalDisplay;
import com.csse3200.game.components.maingame.MainGameExitDisplay;
Expand Down Expand Up @@ -100,6 +97,7 @@ public MainGameScreen(GdxGame game) {

ServiceLocator.registerEntityService(new EntityService());
ServiceLocator.registerRenderService(new RenderService());
ServiceLocator.registerGameEndService(new GameEndService());

renderer = RenderFactory.createRenderer();
renderer.getCamera().getEntity().setPosition(CAMERA_POSITION);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.csse3200.game.services;

public class GameEndService {

private int engineerCount;

public GameEndService() {
this.engineerCount = 5;
}

public int getEngineerCount() {
return engineerCount;
}

public void updateEngineerCount() {
engineerCount -= 1;
if (engineerCount == 0) {
// loss screen

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ServiceLocator {
private static GameTime timeSource;
private static InputService inputService;
private static ResourceService resourceService;
private static GameEndService gameEndService;

public static CurrencyService getCurrencyService() {
return currencyService;
Expand Down Expand Up @@ -53,6 +54,10 @@ public static ResourceService getResourceService() {
return resourceService;
}

public static GameEndService getGameEndService() {
return gameEndService;
}

public static void registerCurrencyService(CurrencyService service) {
logger.debug("Registering currency service {}", service);
currencyService = service;
Expand Down Expand Up @@ -88,13 +93,19 @@ public static void registerResourceService(ResourceService source) {
resourceService = source;
}

public static void registerGameEndService(GameEndService source) {
logger.debug("Registering game end service service {}", source);
gameEndService = source;
}

public static void clear() {
entityService = null;
renderService = null;
physicsService = null;
timeSource = null;
inputService = null;
resourceService = null;
gameEndService = null;
}

private ServiceLocator() {
Expand Down

0 comments on commit 45f0d05

Please sign in to comment.