improved sidebar (ordered and colored)
This commit is contained in:
@@ -84,7 +84,7 @@ class TurtleGame extends StatelessGame {
|
||||
.forEach(snack -> {
|
||||
this.eat(p, snack);
|
||||
this.generateNewSnack();
|
||||
if(this.scoreMap.values().stream().mapToInt(Integer::intValue).sum() % 3 == 0) this.generateNewBomb();
|
||||
if(this.scoreMap.values().stream().mapToInt(Integer::intValue).sum() % 4 == 0) this.generateNewBomb();
|
||||
});
|
||||
this.bombs.stream()
|
||||
.filter(bomb -> bomb.getBoundingBox().intersectBox(turtle.getPosition().sub(bomb.getPosition()), turtle.getBoundingBox()))
|
||||
@@ -93,7 +93,9 @@ class TurtleGame extends StatelessGame {
|
||||
this.explode(p, bomb);
|
||||
this.generateNewBomb(2);
|
||||
this.speed += this.maxSpeedIncrease / this.getPlayers().size();
|
||||
this.sidebarMap.values().forEach(sidebar -> sidebar.updateLineScore("1", (int) this.speed));
|
||||
this.sidebarMap.values().forEach(sidebar -> sidebar.updateLineContent("1",
|
||||
Component.text("Speed: ").color(NamedTextColor.BLUE)
|
||||
.append(Component.text(String.format("%3d", (int) this.speed)).color(NamedTextColor.RED))));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -106,7 +108,9 @@ class TurtleGame extends StatelessGame {
|
||||
this.snacks.remove(snack);
|
||||
snack.remove();
|
||||
this.scoreMap.put(p, this.scoreMap.get(p) + 1);
|
||||
this.sidebarMap.get(p).updateLineScore("0", this.scoreMap.get(p));
|
||||
this.sidebarMap.get(p).updateLineContent("0",
|
||||
Component.text("Score: ").color(NamedTextColor.GREEN)
|
||||
.append(Component.text(String.format("%3d", this.scoreMap.get(p))).color(NamedTextColor.RED)));
|
||||
}
|
||||
|
||||
protected void explode(Player p, Entity bomb) {
|
||||
@@ -122,7 +126,9 @@ class TurtleGame extends StatelessGame {
|
||||
this.getScore().insertResult(p, this.scoreMap.get(p));
|
||||
this.bombs.remove(bomb);
|
||||
bomb.remove();
|
||||
this.sidebarMap.values().forEach(sidebar -> sidebar.updateLineScore("2", (int) this.turtlePlayerMap.keySet().stream().filter(player -> !player.isFlying()).count()));
|
||||
this.sidebarMap.values().forEach(sidebar -> sidebar.updateLineContent("2",
|
||||
Component.text("Players: ").color(NamedTextColor.AQUA)
|
||||
.append(Component.text(String.format("%3d", (int) this.turtlePlayerMap.keySet().stream().filter(player -> !player.isFlying()).count())).color(NamedTextColor.RED))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,21 +142,29 @@ class TurtleGame extends StatelessGame {
|
||||
Sidebar sidebar = this.sidebarMap.get(p);
|
||||
sidebar.createLine(new Sidebar.ScoreboardLine(
|
||||
"0",
|
||||
Component.text("Score: ").color(NamedTextColor.DARK_GREEN),
|
||||
this.scoreMap.get(p)
|
||||
Component.text("Score: ").color(NamedTextColor.GREEN)
|
||||
.append(Component.text(String.format("%3d", this.scoreMap.get(p))).color(NamedTextColor.RED)),
|
||||
3,
|
||||
Sidebar.NumberFormat.blank()
|
||||
));
|
||||
sidebar.createLine(new Sidebar.ScoreboardLine(
|
||||
"1",
|
||||
Component.text("Speed: ").color(NamedTextColor.DARK_BLUE),
|
||||
(int) this.speed
|
||||
Component.text("Speed: ").color(NamedTextColor.BLUE)
|
||||
.append(Component.text(String.format("%3d", (int) this.speed)).color(NamedTextColor.RED)),
|
||||
2,
|
||||
Sidebar.NumberFormat.blank()
|
||||
));
|
||||
sidebar.createLine(new Sidebar.ScoreboardLine(
|
||||
"2",
|
||||
Component.text("Players: ").color(NamedTextColor.AQUA),
|
||||
this.turtlePlayerMap.size()
|
||||
Component.text("Players: ").color(NamedTextColor.AQUA)
|
||||
.append(Component.text(String.format("%3d", (int) this.turtlePlayerMap.keySet().stream().filter(player -> !player.isFlying()).count())).color(NamedTextColor.RED)),
|
||||
1,
|
||||
Sidebar.NumberFormat.blank()
|
||||
));
|
||||
sidebar.addViewer(p);
|
||||
this.sidebarMap.values().forEach(bar -> bar.updateLineScore("2", this.turtlePlayerMap.size()));
|
||||
this.sidebarMap.values().forEach(bar -> bar.updateLineContent("2",
|
||||
Component.text("Players: ").color(NamedTextColor.AQUA)
|
||||
.append(Component.text(String.format("%3d", (int) this.turtlePlayerMap.keySet().stream().filter(player -> !player.isFlying()).count())).color(NamedTextColor.RED))));
|
||||
|
||||
EntityCreature turtle = this.turtlePlayerMap.get(p);
|
||||
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> {
|
||||
|
Reference in New Issue
Block a user