Skip to content

Commit

Permalink
Merge pull request #55 from Our-Magic-Journey/better-planet
Browse files Browse the repository at this point in the history
Better planet
  • Loading branch information
AmonDeShir authored Jan 10, 2024
2 parents 3b5c33d + 95e83de commit 976c6c7
Show file tree
Hide file tree
Showing 49 changed files with 225 additions and 56 deletions.
18 changes: 18 additions & 0 deletions assets/animations/ship/ship_0.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ship_0.png
format: RGBA8888
filter: Nearest, Nearest
repeat: none
move
rotate: false
xy: 0,0
size: 45,45
orig: 45,45
offset: 0,0
index: 0
move
rotate: false
xy: 45,0
size: 45,45
orig: 45,45
offset: 0,0
index: 1
Binary file added assets/animations/ship/ship_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions assets/animations/ship/ship_1.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ship_1.png
format: RGBA8888
filter: Nearest, Nearest
repeat: none
move
rotate: false
xy: 0,0
size: 45,45
orig: 45,45
offset: 0,0
index: 0
move
rotate: false
xy: 45,0
size: 45,45
orig: 45,45
offset: 0,0
index: 1
Binary file added assets/animations/ship/ship_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions assets/animations/ship/ship_2.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ship_2.png
format: RGBA8888
filter: Nearest, Nearest
repeat: none
move
rotate: false
xy: 0,0
size: 32,32
orig: 32,32
offset: 0,0
index: 0
move
rotate: false
xy: 32,0
size: 32,32
orig: 32,32
offset: 0,0
index: 1
move
rotate: false
xy: 64,0
size: 32,32
orig: 32,32
offset: 0,0
index: 2
Binary file added assets/animations/ship/ship_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions assets/assets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ images/planet-field.png
images/planet-field-over.png
images/planet-field-down.png
images/planet-field-color.png
images/planet-field-color2.png
images/casino.png
images/casino-over.png
images/casino-down.png
Expand All @@ -48,9 +49,9 @@ images/event-over.png
images/event-down.png
images/map-done.png
images/board-background.png
images/player0.png
images/player1.png
images/player2.png
animations/ship/ship_0.atlas
animations/ship/ship_1.atlas
animations/ship/ship_2.atlas
animations/planet/mustafar.atlas
animations/planet/paradise.atlas
animations/planet/anch-to.atlas
Expand Down
Binary file modified assets/images/casino-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/casino-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/casino.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/hiper-hub-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/hiper-hub-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/hiper-hub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/mine-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/mine-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/mine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/nebula-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/nebula-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/nebula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/planet-field-color2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/start-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/start-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/teleport-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/teleport-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/teleport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/unknown-jump-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/unknown-jump-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/unknown-jump.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions core/src/xyz/magicjourney/nebulaquest/board/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,8 @@ public void movePlayerToNebula(Player player, int field) {
this.setPlayerPosition(player, field, true);
}
}

public void removePlayer(Player player) {
this.players.get(player).remove();
}
}
6 changes: 3 additions & 3 deletions core/src/xyz/magicjourney/nebulaquest/board/Pawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

import xyz.magicjourney.nebulaquest.animation.AnimatedImage;
import xyz.magicjourney.nebulaquest.player.Player;

public class Pawn extends Group {
protected Player player;
protected Image image;
protected AnimatedImage image;
protected int field;

public Pawn(Player player, AssetManager assets) {
this.player = player;
this.image = new Image(player.getShip(assets));
this.image = player.getShip(assets);
this.field = 0;
this.setSize(40, 40);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import xyz.magicjourney.nebulaquest.entity.entities.planet.Planet;

public class PlanetField extends Field {
Planet entity;
AnimatedImage planet;
Image color;
Label price;
Label name;
protected Planet entity;
protected AnimatedImage planet;
protected Image color;
protected Label price;
protected Label name;

public PlanetField(Planet entity, AssetManager assets) {
super(entity, assets);
Expand Down
10 changes: 3 additions & 7 deletions core/src/xyz/magicjourney/nebulaquest/dice/Dice.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ public Dice(AssetManager assets) {
this.rollNumber = 0;

this.debugRolls = new int[] {
12, 1,
12, 1,
12, 2,
2, 2, 1,
12, 11,
12, 11,
12, 11
12, 12, 6, 3,
12, 12, 6, 6,
12, 12, 6, 10,
};
}

Expand Down
7 changes: 7 additions & 0 deletions core/src/xyz/magicjourney/nebulaquest/entity/Buyable.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ default String getInteractiveablePanelName(Player player) {
default boolean isDecisionRequired(Player player) {
return this.mustPayFee(player) || this.canByBought();
}

default void sell() {
if (this.getOwner().isPresent()) {
this.getOwner().get().giveMoney(this.getValue());
this.setOwner(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int getFee() {

@Override
public void setOwner(Player player) {
this.owner = Optional.of(player);
this.owner = Optional.ofNullable(player);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Optional<Player> getOwner() {

@Override
public void setOwner(Player player) {
this.owner = Optional.of(player);
this.owner = Optional.ofNullable(player);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ public Optional<Player> getOwner() {

@Override
public void setOwner(Player player) {
this.description = "Attention, Explorer! This planet has already been claimed by " + player.getName() + ". If you wish to visit or stay on this celestial body, a fee must be paid to " + player.getName();
this.owner = Optional.of(player);
if (player != null) {
this.description = "Attention, Explorer! This planet has already been claimed by " + player.getName() + ". If you wish to visit or stay on this celestial body, a fee must be paid to " + player.getName();
}
else {
this.description = "This planet is owned by the Republic, and there is no entrance fee. You have the chance to acquire this planet as your own by being the first to step onto it. Beware, though, if someone else buys it, you'll need to pay a fee.";
}

this.owner = Optional.ofNullable(player);
}

public PlanetRegion getRegion() {
Expand Down
28 changes: 20 additions & 8 deletions core/src/xyz/magicjourney/nebulaquest/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import java.util.ArrayList;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;

import xyz.magicjourney.nebulaquest.animation.AnimatedImage;
import xyz.magicjourney.nebulaquest.entity.Buyable;
import xyz.magicjourney.nebulaquest.entity.Describable;
import xyz.magicjourney.nebulaquest.event.ParameterizedEvent;
Expand All @@ -18,6 +15,7 @@ public class Player implements Describable {
private static int nextID = 0;

protected ParameterizedEvent<Player> changedEvent;
protected ParameterizedEvent<Player> bankruptEvent;

protected int id;
protected String name;
Expand All @@ -28,8 +26,9 @@ public Player(String name) {
this.name = name;
this.id = generateId();
this.money = 10000;
this.changedEvent = new ParameterizedEvent<>();
this.properties = new ArrayList<>();
this.changedEvent = new ParameterizedEvent<>();
this.bankruptEvent = new ParameterizedEvent<>();
}

private int generateId() {
Expand Down Expand Up @@ -95,16 +94,29 @@ public void giveMoney(int value) {
this.setMoney(this.getMoney() + value);
}

public TextureRegionDrawable getShip(AssetManager assets) {
return new TextureRegionDrawable(new TextureRegion(assets.get("images/player" + id + ".png", Texture.class)));
public AnimatedImage getShip(AssetManager assets) {
return new AnimatedImage("animations/ship/ship_" + id + ".atlas", "move", 0.1f, true, assets);
}

@Override
public Actor getIcon(AssetManager assets) {
return new Image(this.getShip(assets));
return this.getShip(assets);
}

public ParameterizedEventGetter<Player> onChange() {
return this.changedEvent;
}

public void bankrupt() {
for (Buyable property : properties) {
property.setOwner(null);
}

properties.clear();
this.bankruptEvent.emit(this);
}

public ParameterizedEventGetter<Player> onBankrupt() {
return this.bankruptEvent;
}
}
23 changes: 21 additions & 2 deletions core/src/xyz/magicjourney/nebulaquest/screen/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import xyz.magicjourney.nebulaquest.entity.entities.planet.PlanetRegion;
import xyz.magicjourney.nebulaquest.music.MusicManager;
import xyz.magicjourney.nebulaquest.player.Player;
import xyz.magicjourney.nebulaquest.ui.dialog.MessageBox;
import xyz.magicjourney.nebulaquest.ui.panel.InteractivePanel;
import xyz.magicjourney.nebulaquest.ui.panel.MenuPanel;
import xyz.magicjourney.nebulaquest.ui.panel.OptionPanel;
Expand All @@ -41,6 +42,7 @@ public class GameScreen extends AbstractScreen {
protected MenuPanel menuPanel;
protected Dice dice;
protected boolean playerMoved;
protected MessageBox winMessageBox;

public GameScreen(SpriteBatch batch, AssetManager assets, ScreenManager screenManager, MusicManager musicManager) {
super(batch, assets, screenManager, musicManager);
Expand All @@ -52,6 +54,8 @@ public GameScreen(SpriteBatch batch, AssetManager assets, ScreenManager screenMa
this.populateRegions();
this.populateBoard();

this.players.forEach((player) -> player.onBankrupt().subscribe(handlePlayerBankrupt));

this.activePlayer = this.players.get(0);
this.activeEntity = this.entities.get(0);
this.playerMoved = false;
Expand Down Expand Up @@ -135,6 +139,9 @@ public void create() {
this.board = new Board(this.entities, this.players, this.assets, this.handleFieldEnter);
this.dice = new Dice(assets);

this.winMessageBox = new MessageBox("", assets);
this.winMessageBox.onAccepted().subscribe(() -> screenManager.select("main-menu"));

this.tourPanel = new TourPanel(assets, this.players);
this.tourPanel.setPosition(751, 72);

Expand Down Expand Up @@ -215,7 +222,7 @@ public void create() {
this.displayEntityInInteractivePanel(field.getEntity());
}
else {
this.interactivePanel.selectDescription(field.getEntity());
this.interactivePanel.selectDescription(field.getEntity(), this.activePlayer);
}
};

Expand All @@ -237,4 +244,16 @@ protected void displayEntityInInteractivePanel(Entity entity) {
this.interactivePanel.select("Description", this.activePlayer, entity);
}
}
}

protected Consumer<Player> handlePlayerBankrupt = (player) -> {
this.players.remove(player);

if (this.players.size() == 1) {
this.winMessageBox.setText(this.players.get(0).getName() + " is the winner!");
this.winMessageBox.show(this.stage);
}

this.board.removePlayer(player);
this.tourPanel.removePlayer(player);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import xyz.magicjourney.nebulaquest.board.Board;
import xyz.magicjourney.nebulaquest.dice.Dice;
import xyz.magicjourney.nebulaquest.entity.Describable;
import xyz.magicjourney.nebulaquest.entity.Entity;
import xyz.magicjourney.nebulaquest.player.Player;
import xyz.magicjourney.nebulaquest.ui.panel.views.AbstractInteractiveView;
Expand Down Expand Up @@ -45,7 +44,7 @@ public InteractivePanel(AssetManager assets, Dice dice, TourPanel tourPanel, Pla
this.views.put("TeleportPayFee", new TeleportPayFeeInteractiveView(assets, this, tourPanel));
this.views.put("Mine", new MineInteractiveView(assets, this, tourPanel));
this.views.put("UnknownJump", new UnknownJumpInteractiveView(assets, this, tourPanel, board));

this.content.pad(4, 4, 4, 4);
this.select("Bank");
}
Expand Down Expand Up @@ -75,10 +74,7 @@ public void reset() {
}
}

public void selectDescription(Describable entity) {
this.select("Description");

var view = (DescriptionInteractiveView) this.views.get("Description");
view.display(entity);
public void selectDescription(Entity entity, Player player) {
this.select("Description", player, entity);
}
}
Loading

0 comments on commit 976c6c7

Please sign in to comment.