SteamWar/FightSystem
Archiviert
13
1

more meteors
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Zeanon 2022-01-15 14:53:00 +01:00
Ursprung fa8d5ce99a
Commit ea833f979e

Datei anzeigen

@ -10,6 +10,7 @@ import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.winconditions.Winconditions; import de.steamwar.fightsystem.winconditions.Winconditions;
import java.util.Random; import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -18,6 +19,7 @@ import org.bukkit.entity.Fireball;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -32,6 +34,7 @@ public class Meteor implements Listener {
private Meteor.State current = Meteor.State.PRE; private Meteor.State current = Meteor.State.PRE;
private int currentDrops = 0; private int currentDrops = 0;
private Meteor.MeteorCountdown currentCountdown; private Meteor.MeteorCountdown currentCountdown;
private BukkitTask currentDropping;
public void startCountdown() { public void startCountdown() {
if (current == Meteor.State.PRE) { if (current == Meteor.State.PRE) {
@ -54,24 +57,32 @@ public class Meteor implements Listener {
} }
public void drop() { public void drop() {
int xOffset = getStart(xLength); final AtomicInteger amount = new AtomicInteger(current.minAmount + random.nextInt(current.maxAmount - current.minAmount));
int zOffset = getStart(zLength);
int yOffset = getHeightStart();
Meteor.Point redStart = new Meteor.Point(Config.RedExtendRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedExtendRegion.getMaxZ() - zOffset); currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
Meteor.Point blueStart = new Meteor.Point(Config.BlueExtendRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BlueExtendRegion.getMinZ() + zOffset); int xOffset = getStart(xLength);
int zOffset = getStart(zLength);
int yOffset = getHeightStart();
Fireball fireballRed = world.spawn(redStart.toLocation(world), Fireball.class); Meteor.Point redStart = new Meteor.Point(Config.RedExtendRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedExtendRegion.getMaxZ() - zOffset);
fireballRed.setDirection(vector); Meteor.Point blueStart = new Meteor.Point(Config.BlueExtendRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BlueExtendRegion.getMinZ() + zOffset);
fireballRed.setBounce(false);
fireballRed.setIsIncendiary(false);
fireballRed.setYield(0);
Fireball fireballBlue = world.spawn(blueStart.toLocation(world), Fireball.class); Fireball fireballRed = world.spawn(redStart.toLocation(world), Fireball.class);
fireballBlue.setDirection(vector); fireballRed.setDirection(vector);
fireballBlue.setBounce(false); fireballRed.setBounce(false);
fireballBlue.setIsIncendiary(false); fireballRed.setIsIncendiary(false);
fireballBlue.setYield(0); fireballRed.setYield(0);
Fireball fireballBlue = world.spawn(blueStart.toLocation(world), Fireball.class);
fireballBlue.setDirection(vector);
fireballBlue.setBounce(false);
fireballBlue.setIsIncendiary(false);
fireballBlue.setYield(0);
if (amount.decrementAndGet() <= 0) {
currentDropping.cancel();
}
}, 0L, 4L);
} }
private int getStart(int regionSize) { private int getStart(int regionSize) {
@ -132,25 +143,29 @@ public class Meteor implements Listener {
private enum State { private enum State {
PRE(60, 80, 1, 0), PRE(60, 80, 1, 0, 0, 0),
FIRST(40, 60, 3, 2), FIRST(40, 60, 3, 2, 1, 3),
SECOND(30, 40, 4, 4), SECOND(30, 40, 4, 4, 2, 5),
THIRD(20, 30, 4, 6), THIRD(20, 30, 4, 6, 3, 7),
FOURTH(10, 20, 5, 8), FOURTH(10, 20, 5, 8, 5, 10),
LAST(5, 10, 0, 10); LAST(5, 10, 0, 10, 7, 15);
State(int minTime, int maxTime, int switchAfter, int explosionSize) { State(int minTime, int maxTime, int switchAfter, int explosionSize, int minAmount, int maxAmount) {
this.MIN_TIME = minTime; this.MIN_TIME = minTime;
this.MAX_TIME = maxTime; this.MAX_TIME = maxTime;
this.SWITCH_AFTER = switchAfter; this.SWITCH_AFTER = switchAfter;
this.explosionSize = explosionSize; this.explosionSize = explosionSize;
this.minAmount = minAmount;
this.maxAmount = maxAmount;
} }
private final int MIN_TIME; //NOSONAR private final int MIN_TIME; //NOSONAR
private final int MAX_TIME; //NOSONAR private final int MAX_TIME; //NOSONAR
private final int SWITCH_AFTER; //NOSONAR private final int SWITCH_AFTER; //NOSONAR
private final int explosionSize; //NOSONAR private final int explosionSize; //NOSONAR
private final int minAmount;
private final int maxAmount;
public Meteor.State getNext() { public Meteor.State getNext() {