mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Oppdaterer visning av programmeringskort med teksturer for hver korttype Closes #80
This commit is contained in:
parent
0fb3c76e7e
commit
1747f1ea21
@ -202,6 +202,7 @@ public class BoardActiveScreen extends InteractiveScreen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the damage of the player
|
* Draws the damage of the player
|
||||||
|
*
|
||||||
* @param batch The sprite batch to use for drawing
|
* @param batch The sprite batch to use for drawing
|
||||||
* @param robot The robot which has visited the flag
|
* @param robot The robot which has visited the flag
|
||||||
* @param index The index of the robot in the robot list
|
* @param index The index of the robot in the robot list
|
||||||
@ -228,6 +229,7 @@ public class BoardActiveScreen extends InteractiveScreen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the lives of the player
|
* Draws the lives of the player
|
||||||
|
*
|
||||||
* @param batch The sprite batch to use for drawing
|
* @param batch The sprite batch to use for drawing
|
||||||
* @param robot The robot which has visited the flag
|
* @param robot The robot which has visited the flag
|
||||||
* @param index The index of the robot in the robot list
|
* @param index The index of the robot in the robot list
|
||||||
@ -246,6 +248,7 @@ public class BoardActiveScreen extends InteractiveScreen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the last flag the player visited
|
* Draws the last flag the player visited
|
||||||
|
*
|
||||||
* @param batch The sprite batch to use for drawing
|
* @param batch The sprite batch to use for drawing
|
||||||
* @param robot The robot which has visited the flag
|
* @param robot The robot which has visited the flag
|
||||||
* @param index The index of the robot in the robot list
|
* @param index The index of the robot in the robot list
|
||||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.Input;
|
|||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
@ -18,15 +19,15 @@ import inf112.fiasko.roborally.gamewrapper.SimpleButton;
|
|||||||
import inf112.fiasko.roborally.networking.containers.ProgramAndPowerdownRequest;
|
import inf112.fiasko.roborally.networking.containers.ProgramAndPowerdownRequest;
|
||||||
import inf112.fiasko.roborally.objects.ProgrammingCard;
|
import inf112.fiasko.roborally.objects.ProgrammingCard;
|
||||||
import inf112.fiasko.roborally.objects.ProgrammingCardDeck;
|
import inf112.fiasko.roborally.objects.ProgrammingCardDeck;
|
||||||
|
import inf112.fiasko.roborally.utility.TextureConverterUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.badlogic.gdx.graphics.Color.BLACK;
|
|
||||||
import static com.badlogic.gdx.graphics.Color.GRAY;
|
|
||||||
import static com.badlogic.gdx.graphics.Color.RED;
|
import static com.badlogic.gdx.graphics.Color.RED;
|
||||||
import static com.badlogic.gdx.graphics.Color.WHITE;
|
import static com.badlogic.gdx.graphics.Color.WHITE;
|
||||||
|
import static com.badlogic.gdx.graphics.Color.YELLOW;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This screen is used to let the user choose their program
|
* This screen is used to let the user choose their program
|
||||||
@ -202,77 +203,47 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
|
|||||||
* Renders the base shape of cards
|
* Renders the base shape of cards
|
||||||
*/
|
*/
|
||||||
private void renderCards() {
|
private void renderCards() {
|
||||||
|
roboRallyWrapper.batch.begin();
|
||||||
for (CardRectangle cardRectangle : cardRectangles) {
|
for (CardRectangle cardRectangle : cardRectangles) {
|
||||||
if (cardRectangle.selected) {
|
if (cardRectangle.selected) {
|
||||||
shapeRenderer.setColor(RED);
|
shapeRenderer.setColor(RED);
|
||||||
shapeRenderer.rect(cardRectangle.rectangle.x - 10, cardRectangle.rectangle.y - 10,
|
shapeRenderer.rectLine(cardRectangle.rectangle.x, cardRectangle.rectangle.y,
|
||||||
cardRectangle.rectangle.width + 20, cardRectangle.rectangle.height + 20);
|
cardRectangle.rectangle.x + cardRectangle.rectangle.width, cardRectangle.rectangle.y +
|
||||||
|
cardRectangle.rectangle.height, 2);
|
||||||
}
|
}
|
||||||
shapeRenderer.setColor(GRAY);
|
TextureRegion cardTexture = TextureConverterUtil.convertElement(cardRectangle.card);
|
||||||
shapeRenderer.rect(cardRectangle.rectangle.x, cardRectangle.rectangle.y,
|
Rectangle rectangle = cardRectangle.rectangle;
|
||||||
cardRectangle.rectangle.width, cardRectangle.rectangle.height);
|
roboRallyWrapper.batch.draw(cardTexture.getTexture(), rectangle.getX(), rectangle.getY(),
|
||||||
|
rectangle.getWidth() / 2, rectangle.getHeight() / 2,
|
||||||
|
rectangle.getWidth(), rectangle.getHeight(), 1, 1, 0,
|
||||||
|
cardTexture.getRegionX(), cardTexture.getRegionY(),
|
||||||
|
cardTexture.getRegionWidth(), cardTexture.getRegionHeight(),
|
||||||
|
false, false);
|
||||||
}
|
}
|
||||||
|
roboRallyWrapper.batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the text displayed on cards
|
* Renders the text displayed on cards
|
||||||
*/
|
*/
|
||||||
private void renderCardText() {
|
private void renderCardText() {
|
||||||
|
roboRallyWrapper.font.setColor(YELLOW);
|
||||||
for (CardRectangle cardRectangle : cardRectangles) {
|
for (CardRectangle cardRectangle : cardRectangles) {
|
||||||
|
roboRallyWrapper.font.getData().setScale(0.8f);
|
||||||
GlyphLayout layout = new GlyphLayout(roboRallyWrapper.font,
|
GlyphLayout layout = new GlyphLayout(roboRallyWrapper.font,
|
||||||
Integer.toString(cardRectangle.card.getPriority()));
|
Integer.toString(cardRectangle.card.getPriority()));
|
||||||
float fontX = (int) (cardRectangle.rectangle.x + (cardRectangle.rectangle.width - layout.width) / 2.0);
|
float fontX = (int) (cardRectangle.rectangle.x + (cardRectangle.rectangle.width - layout.width) - 28);
|
||||||
float fontY = cardRectangle.rectangle.y + cardRectangle.rectangle.height - 30;
|
float fontY = cardRectangle.rectangle.y + cardRectangle.rectangle.height - 21;
|
||||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, layout, fontX, fontY);
|
roboRallyWrapper.font.draw(roboRallyWrapper.batch, layout, fontX, fontY);
|
||||||
drawCardSymbol(cardRectangle);
|
|
||||||
int chosenIndex = chosenCards.indexOf(cardRectangle);
|
int chosenIndex = chosenCards.indexOf(cardRectangle);
|
||||||
if (chosenIndex != -1) {
|
if (chosenIndex != -1) {
|
||||||
roboRallyWrapper.font.setColor(BLACK);
|
roboRallyWrapper.font.setColor(YELLOW);
|
||||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, String.valueOf(chosenIndex + 1),
|
roboRallyWrapper.font.draw(roboRallyWrapper.batch, String.valueOf(chosenIndex + 1),
|
||||||
cardRectangle.rectangle.x + cardRectangle.rectangle.width - 20, cardRectangle.rectangle.y + cardRectangle.rectangle.height - 5);
|
cardRectangle.rectangle.x + 30, cardRectangle.rectangle.y + cardRectangle.rectangle.height - 20);
|
||||||
roboRallyWrapper.font.setColor(WHITE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
roboRallyWrapper.font.setColor(WHITE);
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws the symbol on a card
|
|
||||||
*
|
|
||||||
* @param cardRectangle The card rectangle to draw
|
|
||||||
*/
|
|
||||||
private void drawCardSymbol(CardRectangle cardRectangle) {
|
|
||||||
String text;
|
|
||||||
switch (cardRectangle.card.getAction()) {
|
|
||||||
case MOVE_1:
|
|
||||||
text = "Move 1 forward";
|
|
||||||
break;
|
|
||||||
case MOVE_2:
|
|
||||||
text = "Move 2 forward";
|
|
||||||
break;
|
|
||||||
case MOVE_3:
|
|
||||||
text = "Move 3 forward";
|
|
||||||
break;
|
|
||||||
case BACK_UP:
|
|
||||||
text = "Back up";
|
|
||||||
break;
|
|
||||||
case ROTATE_LEFT:
|
|
||||||
text = "Rotate left";
|
|
||||||
break;
|
|
||||||
case ROTATE_RIGHT:
|
|
||||||
text = "Rotate right";
|
|
||||||
break;
|
|
||||||
case U_TURN:
|
|
||||||
text = "U Turn";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Invalid action on CardRectangle.");
|
|
||||||
}
|
|
||||||
GlyphLayout layout = new GlyphLayout();
|
|
||||||
layout.setText(roboRallyWrapper.font, text, WHITE, cardRectangle.rectangle.width - 20,
|
|
||||||
1, true);
|
|
||||||
float fontX = cardRectangle.rectangle.x;
|
|
||||||
float fontY = cardRectangle.rectangle.y + cardRectangle.rectangle.height - 80;
|
|
||||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, layout, fontX, fontY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,6 @@ import inf112.fiasko.roborally.elementproperties.TileType;
|
|||||||
import inf112.fiasko.roborally.elementproperties.WallType;
|
import inf112.fiasko.roborally.elementproperties.WallType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -242,7 +241,7 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes one damage for a given robot given that it has taken som damage before
|
* Removes one damage for a given robot given that it has taken som damage before
|
||||||
*
|
*
|
||||||
* @param robotID the ID of the robot
|
* @param robotID the ID of the robot
|
||||||
*/
|
*/
|
||||||
@ -253,7 +252,7 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the damage taken of robots in power down to 0
|
* Sets the damage taken of robots in power down to 0
|
||||||
*/
|
*/
|
||||||
public void executePowerDown() {
|
public void executePowerDown() {
|
||||||
for (Robot robot : robots.values()) {
|
for (Robot robot : robots.values()) {
|
||||||
@ -316,23 +315,8 @@ public class Board {
|
|||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (tile.getTileType()) {
|
int tileTypeId = tile.getTileType().getTileTypeID();
|
||||||
case CONVEYOR_BELT_SLOW:
|
return tileTypeId >= 5 && tileTypeId <= 16;
|
||||||
case CONVEYOR_BELT_FAST:
|
|
||||||
case CONVEYOR_BELT_FAST_LEFT:
|
|
||||||
case CONVEYOR_BELT_FAST_RIGHT:
|
|
||||||
case CONVEYOR_BELT_FAST_SIDE_ENTRANCE_LEFT:
|
|
||||||
case CONVEYOR_BELT_FAST_SIDE_ENTRANCE_RIGHT:
|
|
||||||
case CONVEYOR_BELT_FAST_SIDE_ENTRANCES:
|
|
||||||
case CONVEYOR_BELT_SLOW_LEFT:
|
|
||||||
case CONVEYOR_BELT_SLOW_RIGHT:
|
|
||||||
case CONVEYOR_BELT_SLOW_SIDE_ENTRANCE_LEFT:
|
|
||||||
case CONVEYOR_BELT_SLOW_SIDE_ENTRANCE_RIGHT:
|
|
||||||
case CONVEYOR_BELT_SLOW_SIDE_ENTRANCES:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,7 @@ import inf112.fiasko.roborally.elementproperties.RobotID;
|
|||||||
import inf112.fiasko.roborally.elementproperties.TileType;
|
import inf112.fiasko.roborally.elementproperties.TileType;
|
||||||
import inf112.fiasko.roborally.elementproperties.WallType;
|
import inf112.fiasko.roborally.elementproperties.WallType;
|
||||||
import inf112.fiasko.roborally.objects.Particle;
|
import inf112.fiasko.roborally.objects.Particle;
|
||||||
|
import inf112.fiasko.roborally.objects.ProgrammingCard;
|
||||||
import inf112.fiasko.roborally.objects.Robot;
|
import inf112.fiasko.roborally.objects.Robot;
|
||||||
import inf112.fiasko.roborally.objects.Tile;
|
import inf112.fiasko.roborally.objects.Tile;
|
||||||
import inf112.fiasko.roborally.objects.Wall;
|
import inf112.fiasko.roborally.objects.Wall;
|
||||||
@ -30,6 +31,7 @@ public final class TextureConverterUtil {
|
|||||||
private static final Texture textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
|
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 robotsTexture = new Texture(Gdx.files.internal("assets/robots.png"));
|
||||||
private static final Texture effectsTexture = new Texture(Gdx.files.internal("assets/effects.png"));
|
private static final Texture effectsTexture = new Texture(Gdx.files.internal("assets/effects.png"));
|
||||||
|
private static final Texture programmingCardsTexture = new Texture(Gdx.files.internal("assets/programmingcards.png"));
|
||||||
private static Map<TileType, TextureConverterContainer> tileSheetTileTextureMappings;
|
private static Map<TileType, TextureConverterContainer> tileSheetTileTextureMappings;
|
||||||
private static Map<TileType, Boolean> tileSheetTileHasRotatedTextureMappings;
|
private static Map<TileType, Boolean> tileSheetTileHasRotatedTextureMappings;
|
||||||
private static Map<ParticleType, TextureConverterContainer> tileSheetParticleTextureMappings;
|
private static Map<ParticleType, TextureConverterContainer> tileSheetParticleTextureMappings;
|
||||||
@ -40,8 +42,36 @@ public final class TextureConverterUtil {
|
|||||||
private TextureConverterUtil() {
|
private TextureConverterUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the texture representing the programming card
|
||||||
|
*
|
||||||
|
* @param card The card to draw
|
||||||
|
* @return The texture to draw
|
||||||
|
*/
|
||||||
|
public static TextureRegion convertElement(ProgrammingCard card) {
|
||||||
|
switch (card.getAction()) {
|
||||||
|
case MOVE_1:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 0, 0, 250, 400);
|
||||||
|
case MOVE_2:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 250, 0, 250, 400);
|
||||||
|
case MOVE_3:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 2 * 250, 0, 250, 400);
|
||||||
|
case ROTATE_LEFT:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 3 * 250, 0, 250, 400);
|
||||||
|
case ROTATE_RIGHT:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 4 * 250, 0, 250, 400);
|
||||||
|
case BACK_UP:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 5 * 250, 0, 250, 400);
|
||||||
|
case U_TURN:
|
||||||
|
return new TextureRegion(programmingCardsTexture, 6 * 250, 0, 250, 400);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid action encountered.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the texture to use to display damage tokens
|
* Returns the texture to use to display damage tokens
|
||||||
|
*
|
||||||
* @return The damage token texture
|
* @return The damage token texture
|
||||||
*/
|
*/
|
||||||
public static TextureRegion getDamageTokenCriticalTexture() {
|
public static TextureRegion getDamageTokenCriticalTexture() {
|
||||||
@ -50,6 +80,7 @@ public final class TextureConverterUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the texture to use to display damage tokens
|
* Returns the texture to use to display damage tokens
|
||||||
|
*
|
||||||
* @return The damage token texture
|
* @return The damage token texture
|
||||||
*/
|
*/
|
||||||
public static TextureRegion getDamageTokenTexture() {
|
public static TextureRegion getDamageTokenTexture() {
|
||||||
@ -58,6 +89,7 @@ public final class TextureConverterUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the texture to use to display lives
|
* Returns the texture to use to display lives
|
||||||
|
*
|
||||||
* @return The life texture
|
* @return The life texture
|
||||||
*/
|
*/
|
||||||
public static TextureRegion getLifeTexture() {
|
public static TextureRegion getLifeTexture() {
|
||||||
|
BIN
src/main/resources/assets/programmingcards.png
Normal file
BIN
src/main/resources/assets/programmingcards.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
Loading…
x
Reference in New Issue
Block a user