Stage 4-5: Survivor and Generator systems
This commit is contained in:
parent
4fd7955d56
commit
5a53620b3a
2 changed files with 193 additions and 0 deletions
125
src/main/java/dev/loki/killer/KillerVision.java
Normal file
125
src/main/java/dev/loki/killer/KillerVision.java
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
package dev.loki.killer;
|
||||
|
||||
import dev.loki.player.Killer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillerVision extends BukkitRunnable {
|
||||
|
||||
private static final long PARTICLE_INTERVAL = 5L;
|
||||
private static final int PARTICLE_COUNT = 5;
|
||||
private static final double PARTICLE_SPACING = 0.3;
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private Killer killer;
|
||||
private boolean active;
|
||||
|
||||
public KillerVision(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
public void setKiller(Killer killer) {
|
||||
this.killer = killer;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.active = true;
|
||||
runTaskTimer(plugin, 0L, PARTICLE_INTERVAL);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.active = false;
|
||||
cancel();
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!active || killer == null || !killer.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = killer.getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
spawnRedStain(player);
|
||||
}
|
||||
|
||||
private void spawnRedStain(Player player) {
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
Vector direction = eyeLoc.getDirection();
|
||||
World world = player.getWorld();
|
||||
|
||||
for (int i = 0; i < PARTICLE_COUNT; i++) {
|
||||
double distance = 1.0 + (i * PARTICLE_SPACING);
|
||||
Location particleLoc = eyeLoc.clone().add(direction.clone().multiply(distance));
|
||||
|
||||
particleLoc.setY(particleLoc.getY() - 0.5);
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
particleLoc,
|
||||
1,
|
||||
0, 0, 0,
|
||||
0,
|
||||
new Particle.DustOptions(org.bukkit.Color.RED, 1.0f)
|
||||
);
|
||||
}
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.DRIPPING_LAVA,
|
||||
eyeLoc.clone().add(direction.clone().multiply(0.5)),
|
||||
2,
|
||||
0.1, 0.1, 0.1,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
public void spawnAttackEffect(Location location) {
|
||||
World world = location.getWorld();
|
||||
if (world == null) return;
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.CRIT,
|
||||
location,
|
||||
20,
|
||||
0.5, 0.5, 0.5,
|
||||
0.1
|
||||
);
|
||||
|
||||
world.spawnParticle(
|
||||
Particle.REDSTONE,
|
||||
location,
|
||||
15,
|
||||
0.3, 0.3, 0.3,
|
||||
0,
|
||||
new Particle.DustOptions(org.bukkit.Color.MAROON, 1.5f)
|
||||
);
|
||||
}
|
||||
|
||||
public void spawnLungeEffect(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
Vector direction = loc.getDirection();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Location particleLoc = loc.clone().add(direction.clone().multiply(i * 0.3));
|
||||
world.spawnParticle(
|
||||
Particle.SWEEP_ATTACK,
|
||||
particleLoc,
|
||||
1,
|
||||
0.2, 0.2, 0.2,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue