diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java index 60567a05f..9ed17c27d 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java @@ -3,9 +3,9 @@ import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; @@ -95,8 +95,9 @@ public void updateScrapsStats() { * build something that costs more than the balance */ public void scrapBalanceFlash() { - // TODO: IMPLEMENT THIS - scrapsTb.setText("Insufficient!"); + scrapsTb.addAction(Actions.repeat(2, + new SequenceAction(Actions.fadeOut(0.5f, Interpolation.bounce), + Actions.fadeIn(0.5f, Interpolation.bounce)))); } /** diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java index 392a1d56e..3cf8766dc 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java @@ -1,9 +1,12 @@ package com.csse3200.game.components.gamearea; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; @@ -53,8 +56,14 @@ private void addActors() { * Updates the engineer count on the UI component */ public void updateCount() { - String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount()); + int currentCount = ServiceLocator.getGameEndService().getEngineerCount(); + String text = String.format("%d", currentCount); engineerTb.getLabel().setText(text); +// if (currentCount < ServiceLocator.getGameEndService().getThreshold()) { +//// engineerTb.addAction(Actions.color(Color.RED, 0.5f, Interpolation.swingIn)); +// engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f), +// Actions.fadeIn(0.5f)))); +// } } @Override diff --git a/source/core/src/main/com/csse3200/game/services/GameEndService.java b/source/core/src/main/com/csse3200/game/services/GameEndService.java index e233f48c7..a97762059 100644 --- a/source/core/src/main/com/csse3200/game/services/GameEndService.java +++ b/source/core/src/main/com/csse3200/game/services/GameEndService.java @@ -5,16 +5,15 @@ public class GameEndService { private int engineerCount; - private boolean gameOver = false; - - private EngineerCountDisplay display; + private static final int STARTING_COUNT = 5; + private final EngineerCountDisplay display; /** * Constructor for the Game End Service */ public GameEndService() { - this.engineerCount = 20; + this.engineerCount = STARTING_COUNT; this.display = new EngineerCountDisplay(); } @@ -51,6 +50,14 @@ public void updateEngineerCount() { } } + /** + * Return the warning threshold for the engineer count + * @return the warning threshold int + */ + public float getThreshold() { + return (float)(0.25 * STARTING_COUNT); + } + /** * Returns the game over state * @return (boolean) true if the game is over; false otherwise