Compare commits
3 Commits
develop
...
develop-ja
| Author | SHA1 | Date | |
|---|---|---|---|
| ee7d434d7e | |||
| 410f7b4027 | |||
| e1515200ab |
@@ -8,6 +8,7 @@ import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGen
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.event.inventory.InventoryPreClickEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
@@ -32,13 +33,20 @@ public class ColorJump extends StatelessGame {
|
||||
Block.PINK_CONCRETE
|
||||
);
|
||||
private Block currentBlock;
|
||||
private Block blockLastRound;
|
||||
private double roundTime = 5;
|
||||
private final double multiplierNextRoundTime = 0.9;
|
||||
|
||||
public ColorJump() {
|
||||
super(Dimension.THE_END.key, "ColorJump", new LastWinsScore());
|
||||
this.getScore().setIgnoreLastPlayers(1);
|
||||
|
||||
this.setGenerator(new CircularPlateTerrainGenerator(100));
|
||||
|
||||
this.eventNode().addListener(
|
||||
InventoryPreClickEvent.class,
|
||||
inventoryPreClickEvent -> inventoryPreClickEvent.setCancelled(true)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,8 +61,11 @@ public class ColorJump extends StatelessGame {
|
||||
|
||||
private void nextRound() {
|
||||
this.generate();
|
||||
|
||||
do {
|
||||
this.currentBlock = this.blocks.get(ThreadLocalRandom.current().nextInt(this.blocks.size()));
|
||||
} while(this.currentBlock == this.blockLastRound);
|
||||
this.blockLastRound = this.currentBlock;
|
||||
|
||||
ItemStack item = ItemStack.of(Objects.requireNonNull(this.currentBlock.registry().material()));
|
||||
this.getPlayers().forEach(player -> {
|
||||
player.getInventory().clear();
|
||||
@@ -67,26 +78,44 @@ public class ColorJump extends StatelessGame {
|
||||
TaskSchedule stop = TaskSchedule.stop();
|
||||
|
||||
scheduler.scheduleTask(() -> {
|
||||
if(!this.isRunning) return stop;
|
||||
this.destroyAllExcept(this.currentBlock);
|
||||
|
||||
scheduler.scheduleTask(() -> {
|
||||
this.nextRound();
|
||||
if(this.isRunning) this.nextRound();
|
||||
return stop;
|
||||
}, TaskSchedule.seconds(3));
|
||||
return stop;
|
||||
}, TaskSchedule.seconds((long) this.roundTime));
|
||||
if(this.roundTime > 0.5)
|
||||
this.roundTime = this.roundTime * 0.9;
|
||||
this.roundTime = this.roundTime * this.multiplierNextRoundTime;
|
||||
if(this.roundTime <= 1) this.roundTime = 1;
|
||||
|
||||
long secondsLeft = Math.max(0, (long) this.roundTime);
|
||||
long totalTicks = (long) (this.roundTime * 20);
|
||||
final long[] remainingTicks = { totalTicks };
|
||||
|
||||
for (int i = Math.min(3, (int) secondsLeft); i >= 0; i--) {
|
||||
int level = i;
|
||||
scheduler.scheduleTask(() -> {
|
||||
this.getPlayers().forEach(player -> player.setLevel(level));
|
||||
|
||||
if (!this.isRunning)
|
||||
return stop;
|
||||
|
||||
if (remainingTicks[0] <= 0) {
|
||||
this.getPlayers().forEach(player -> {
|
||||
player.setExp(0f);
|
||||
player.setLevel(0);
|
||||
});
|
||||
return stop;
|
||||
}, TaskSchedule.seconds(secondsLeft-i));
|
||||
}
|
||||
|
||||
float progress = (float) remainingTicks[0] / totalTicks;
|
||||
|
||||
this.getPlayers().forEach(player -> {
|
||||
player.setExp(progress);
|
||||
player.setLevel((int) Math.ceil(remainingTicks[0] / 20.0));
|
||||
});
|
||||
|
||||
remainingTicks[0]--;
|
||||
return TaskSchedule.tick(1);
|
||||
}, TaskSchedule.tick(1));
|
||||
}
|
||||
|
||||
private void generate() {
|
||||
|
||||
Reference in New Issue
Block a user