highground finished
This commit is contained in:
@@ -36,7 +36,7 @@ public enum GameList {
|
||||
SPLEEF(new SpleefFactory(), GameType.PVP),
|
||||
JUMPDIVE(new JumpDiveFactory(), GameType.JUMPNRUN),
|
||||
SUMO(new SumoFactory(), GameType.PVP),
|
||||
HIGHGROUND(new HighGroundFactory(), GameType.PROTOTYPE);
|
||||
HIGHGROUND(new HighGroundFactory(), GameType.PVP);
|
||||
|
||||
private final GameFactory factory;
|
||||
private final GameType type;
|
||||
|
||||
@@ -10,17 +10,23 @@ import io.github.togar2.pvp.events.PrepareAttackEvent;
|
||||
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.instance.InstanceTickEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class HighGround extends StatelessGame {
|
||||
class HighGround extends StatelessGame {
|
||||
private final int radius;
|
||||
private final int seconds;
|
||||
private final WeakHashMap<Player, Integer> scoreMap = new WeakHashMap<>();
|
||||
|
||||
int radius = 5;
|
||||
public HighGround() {
|
||||
HighGround(int radius, int seconds) {
|
||||
super(Dimension.THE_END.key, "highground", new PointsWinScore());
|
||||
this.radius = radius;
|
||||
this.seconds = seconds;
|
||||
|
||||
this.eventNode().addChild(
|
||||
CombatFeatures.empty()
|
||||
@@ -46,12 +52,23 @@ public class HighGround extends StatelessGame {
|
||||
EntityKnockbackEvent.class,
|
||||
entityKnockbackEvent -> entityKnockbackEvent.setStrength(1.1f)
|
||||
);
|
||||
|
||||
this.eventNode().addListener(InstanceTickEvent.class, instanceTickEvent -> {
|
||||
if (this.isBeforeBeginning || !this.isRunning) return;
|
||||
this.getPlayers().forEach(player -> {
|
||||
if((player.isOnGround() && player.getPosition().y() >= 1) || (!player.isOnGround() && player.getPosition().y() >= 1.5)){
|
||||
this.scoreMap.put(player, this.scoreMap.get(player) + 1);
|
||||
player.setLevel(this.scoreMap.get(player) / 20);
|
||||
player.setExp((this.scoreMap.get(player) % 20) / 20.0f);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
for (int y = 0; y >= -3; y--) {
|
||||
int radius = (Math.abs(y) * 5) + 5;
|
||||
int radius = (Math.abs(y) * 5) + this.radius;
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
double distance = new Pos(x, 0, z).distance(0, 0, 0);
|
||||
@@ -80,6 +97,22 @@ public class HighGround extends StatelessGame {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
this.getPlayers().forEach(player -> this.scoreMap.put(player, 0));
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
this.setTimeLimit(this.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
this.getPlayers().forEach(player -> this.getScore().insertResult(player, this.scoreMap.get(player)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
double theta = this.rnd.nextDouble() * 2 * Math.PI;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
import net.minestom.server.item.Material;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,8 +17,20 @@ public class HighGroundFactory implements GameFactory {
|
||||
return TranslatedComponent.byId("game_Highground#name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatedComponent description() {
|
||||
return TranslatedComponent.byId("game_Highground#description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigManager configuration() {
|
||||
return new ConfigManager()
|
||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 3, 5, 7, 10))
|
||||
.addOption(new NumericOption("seconds", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 30, 60, 90, 120));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||
return new HighGround().setParent(parent);
|
||||
return new HighGround(configuration.get("radius").getAsInt(), configuration.get("seconds").getAsInt()).setParent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user