Skip to content

Commit

Permalink
added currency warning flash for insufficient funds
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 14, 2023
1 parent 58e8378 commit 70da0f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70da0f5

Please sign in to comment.