SteamWar/FightSystem
Archiviert
13
1

added explosion
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Zeanon 2022-01-14 17:02:51 +01:00
Ursprung 02ac3cd665
Commit 8d2fe1df85

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.winconditions.Winconditions;
@ -13,10 +14,13 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Fireball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.util.Vector;
public class Meteor {
public class Meteor implements Listener {
public static final Random random = new Random();
@ -39,6 +43,13 @@ public class Meteor {
currentCountdown.enable();
}
@EventHandler
public void explode(ProjectileHitEvent event) {
if (event.getEntity() instanceof Fireball) {
event.getEntity().getWorld().createExplosion(event.getEntity().getLocation(), current.explosionSize);
}
}
public void drop() {
int xOffset = getStart(xLength);
int zOffset = getStart(zLength);
@ -51,13 +62,13 @@ public class Meteor {
fireballRed.setDirection(new Vector(0, -1, 0));
fireballRed.setBounce(false);
fireballRed.setIsIncendiary(false);
fireballRed.setYield(current.minExplosion + random.nextInt(current.maxExplosion - current.minExplosion));
fireballRed.setYield(current.explosionSize);
Fireball fireballBlue = world.spawn(blueStart.toLocation(world), Fireball.class);
fireballBlue.setDirection(new Vector(0, -1, 0));
fireballBlue.setBounce(false);
fireballBlue.setIsIncendiary(false);
fireballBlue.setYield(current.minExplosion + random.nextInt(current.maxExplosion - current.minExplosion));
fireballBlue.setYield(current.explosionSize);
}
private int getStart(int regionSize) {
@ -71,6 +82,8 @@ public class Meteor {
}
public Meteor() {
new StateDependentListener(Winconditions.METEOR, FightState.Running, this);
new StateDependent(Winconditions.METEOR, FightState.Running) {
@Override
public void enable() {
@ -116,27 +129,25 @@ public class Meteor {
private enum State {
PRE(60, 80, 1, 0, 0),
FIRST(40, 60, 3, 1, 3),
SECOND(30, 40, 4, 2, 4),
THIRD(20, 30, 4, 3, 6),
FOURTH(10, 20, 5, 4, 7),
LAST(5, 10, 0, 5, 10);
PRE(60, 80, 1, 0),
FIRST(40, 60, 3, 1),
SECOND(30, 40, 4, 2),
THIRD(20, 30, 4, 3),
FOURTH(10, 20, 5, 4),
LAST(5, 10, 0, 5);
State(int minTime, int maxTime, int switchAfter, int minExplosion, int maxExplosion) {
State(int minTime, int maxTime, int switchAfter, int explosionSize) {
this.MIN_TIME = minTime;
this.MAX_TIME = maxTime;
this.SWITCH_AFTER = switchAfter;
this.minExplosion = minExplosion;
this.maxExplosion = maxExplosion;
this.explosionSize = explosionSize;
}
private final int MIN_TIME; //NOSONAR
private final int MAX_TIME; //NOSONAR
private final int SWITCH_AFTER; //NOSONAR
private final int minExplosion; //NOSONAR
private final int maxExplosion; //NOSONAR
private final int explosionSize; //NOSONAR
public Meteor.State getNext() {