mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 15:19:35 +01:00
Oppdaterer visning av skade og liv med ikoner for liv, skade og kritisk skade
This commit is contained in:
parent
6c7ff8ac8b
commit
0fb3c76e7e
@ -190,18 +190,9 @@ public class BoardActiveScreen extends InteractiveScreen {
|
||||
}
|
||||
roboRallyWrapper.font.getData().setScale(tileDimensions / 44);
|
||||
roboRallyWrapper.font.draw(batch, playerName, viewPortWidth, 2 * tileDimensions * index);
|
||||
roboRallyWrapper.font.draw(batch, "DMG: " + robot.getDamageTaken() + " LV: " + robot.getAmountOfLives(),
|
||||
viewPortWidth, 1.5f * tileDimensions + 2 * tileDimensions * (index - 1));
|
||||
int lastFlagVisited = robot.getLastFlagVisited();
|
||||
if (lastFlagVisited > 0) {
|
||||
TileType flagType = TileType.getTileTypeFromID(robot.getLastFlagVisited() + 16);
|
||||
TextureRegion flagRegion = TextureConverterUtil.convertElement(new Tile(flagType, Direction.NORTH));
|
||||
batch.draw(flagRegion.getTexture(), viewPortWidth + tileDimensions, 2 * tileDimensions *
|
||||
(index - 1), tileDimensions / 2, tileDimensions / 2, tileDimensions,
|
||||
tileDimensions, 1, 1, 0, flagRegion.getRegionX(),
|
||||
flagRegion.getRegionY(), flagRegion.getRegionWidth(), flagRegion.getRegionWidth(),
|
||||
false, false);
|
||||
}
|
||||
drawDamage(batch, robot, index);
|
||||
drawLives(batch, robot, index);
|
||||
drawFlag(batch, robot, index);
|
||||
TextureRegion robotTexture = TextureConverterUtil.convertElement(player.getRobotID());
|
||||
batch.draw(robotTexture, viewPortWidth, 2 * tileDimensions * (index - 1), tileDimensions, tileDimensions);
|
||||
index++;
|
||||
@ -209,6 +200,69 @@ public class BoardActiveScreen extends InteractiveScreen {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the damage of the player
|
||||
* @param batch The sprite batch to use for drawing
|
||||
* @param robot The robot which has visited the flag
|
||||
* @param index The index of the robot in the robot list
|
||||
*/
|
||||
private void drawDamage(SpriteBatch batch, Robot robot, int index) {
|
||||
int offset = 4 * (tileDimensions / 4);
|
||||
int tokenSize = tileDimensions / 4;
|
||||
TextureRegion damageTexture;
|
||||
for (int i = 0; i < Math.min(robot.getDamageTaken(), 10); i++) {
|
||||
if (i == 9) {
|
||||
damageTexture = TextureConverterUtil.getDamageTokenCriticalTexture();
|
||||
} else {
|
||||
damageTexture = TextureConverterUtil.getDamageTokenTexture();
|
||||
}
|
||||
batch.draw(damageTexture.getTexture(), viewPortWidth + offset + ((i % 5) * tokenSize),
|
||||
tileDimensions + tileDimensions / 4 + 2 * tileDimensions * (index - 1) -
|
||||
(tokenSize * ((i / 5))),
|
||||
tileDimensions / 2,
|
||||
tileDimensions / 2, tokenSize, tokenSize, 1,
|
||||
1, 0, damageTexture.getRegionX(), damageTexture.getRegionY(),
|
||||
damageTexture.getRegionWidth(), damageTexture.getRegionWidth(), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the lives of the player
|
||||
* @param batch The sprite batch to use for drawing
|
||||
* @param robot The robot which has visited the flag
|
||||
* @param index The index of the robot in the robot list
|
||||
*/
|
||||
private void drawLives(SpriteBatch batch, Robot robot, int index) {
|
||||
TextureRegion lifeTexture = TextureConverterUtil.getLifeTexture();
|
||||
int heartSize = tileDimensions / 4;
|
||||
for (int i = 0; i < robot.getAmountOfLives(); i++) {
|
||||
batch.draw(lifeTexture.getTexture(), viewPortWidth + heartSize / 2 + i * heartSize,
|
||||
tileDimensions + 2 * tileDimensions * (index - 1), tileDimensions / 2,
|
||||
tileDimensions / 2, heartSize, heartSize, 1,
|
||||
1, 0, lifeTexture.getRegionX(), lifeTexture.getRegionY(),
|
||||
lifeTexture.getRegionWidth(), lifeTexture.getRegionWidth(), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the last flag the player visited
|
||||
* @param batch The sprite batch to use for drawing
|
||||
* @param robot The robot which has visited the flag
|
||||
* @param index The index of the robot in the robot list
|
||||
*/
|
||||
private void drawFlag(SpriteBatch batch, Robot robot, int index) {
|
||||
int lastFlagVisited = robot.getLastFlagVisited();
|
||||
if (lastFlagVisited > 0) {
|
||||
TileType flagType = TileType.getTileTypeFromID(robot.getLastFlagVisited() + 16);
|
||||
TextureRegion flagRegion = TextureConverterUtil.convertElement(new Tile(flagType, Direction.NORTH));
|
||||
batch.draw(flagRegion.getTexture(), viewPortWidth + tileDimensions, 2 * tileDimensions *
|
||||
(index - 1), tileDimensions / 2, tileDimensions / 2, tileDimensions,
|
||||
tileDimensions, 1, 1, 0, flagRegion.getRegionX(),
|
||||
flagRegion.getRegionY(), flagRegion.getRegionWidth(), flagRegion.getRegionWidth(),
|
||||
false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the robot with the corresponding robot id
|
||||
*
|
||||
|
@ -109,13 +109,9 @@ class RoboRallyClientListener extends Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (newHand.isEmpty()) {
|
||||
if (wrapper.getGame().getRobotPowerDown()) {
|
||||
wrapper.getGame().setProgram(new ArrayList<>());
|
||||
wrapper.getGame().setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
||||
} else {
|
||||
wrapper.getGame().setGameState(GameState.CHOOSING_CARDS);
|
||||
}
|
||||
if (newHand.isEmpty() && wrapper.getGame().getRobotPowerDown()) {
|
||||
wrapper.getGame().setProgram(new ArrayList<>());
|
||||
wrapper.getGame().setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
||||
} else {
|
||||
wrapper.getGame().setGameState(GameState.CHOOSING_CARDS);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.Map;
|
||||
public final class TextureConverterUtil {
|
||||
private static final Texture textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
|
||||
private static final Texture robotsTexture = new Texture(Gdx.files.internal("assets/robots.png"));
|
||||
private static final Texture effectsTexture = new Texture(Gdx.files.internal("assets/effects.png"));
|
||||
private static Map<TileType, TextureConverterContainer> tileSheetTileTextureMappings;
|
||||
private static Map<TileType, Boolean> tileSheetTileHasRotatedTextureMappings;
|
||||
private static Map<ParticleType, TextureConverterContainer> tileSheetParticleTextureMappings;
|
||||
@ -39,6 +40,30 @@ public final class TextureConverterUtil {
|
||||
private TextureConverterUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture to use to display damage tokens
|
||||
* @return The damage token texture
|
||||
*/
|
||||
public static TextureRegion getDamageTokenCriticalTexture() {
|
||||
return new TextureRegion(effectsTexture, 2 * 64, 0, 64, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture to use to display damage tokens
|
||||
* @return The damage token texture
|
||||
*/
|
||||
public static TextureRegion getDamageTokenTexture() {
|
||||
return new TextureRegion(effectsTexture, 64, 0, 64, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture to use to display lives
|
||||
* @return The life texture
|
||||
*/
|
||||
public static TextureRegion getLifeTexture() {
|
||||
return new TextureRegion(effectsTexture, 0, 0, 64, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all disposable elements which should be disposed when the software closes
|
||||
*
|
||||
@ -48,6 +73,7 @@ public final class TextureConverterUtil {
|
||||
List<Disposable> disposables = new ArrayList<>();
|
||||
disposables.add(textureSheet);
|
||||
disposables.add(robotsTexture);
|
||||
disposables.add(effectsTexture);
|
||||
return disposables;
|
||||
}
|
||||
|
||||
|
BIN
src/main/resources/assets/effects.png
Normal file
BIN
src/main/resources/assets/effects.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
x
Reference in New Issue
Block a user