Added spawn barrier

This commit is contained in:
Sam 2016-09-03 18:24:56 +01:00
parent 7eb148cc59
commit e0424c78b2

View File

@ -0,0 +1,82 @@
package nautilus.game.arcade.game.games.quiver.data;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
public class SpawnBarrier
{
private Game _game;
private GameTeam _gameTeam;
private Set<Location> _barriers;
public SpawnBarrier(Game game, GameTeam gameTeam, Set<Location> barriers)
{
_game = game;
_gameTeam = gameTeam;
_barriers = barriers;
for (Location location : _barriers)
{
location.getBlock().setType(Material.AIR);
}
}
public void update()
{
for (Player player : _game.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
if(_game.GetTeam(player).equals(_gameTeam))
{
continue;
}
for (Location location : _gameTeam.GetSpawns())
{
if (UtilMath.offset(player.getLocation(), location) < 5)
{
_game.Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, _game.GetName(), "Spawn Shield");
}
}
for (Location location : _barriers)
{
if (UtilMath.offset(player.getLocation(), location) < 3)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4));
}
UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player);
}
}
}
public GameTeam getGameTeam()
{
return _gameTeam;
}
public Set<Location> getBlocks()
{
return _barriers;
}
}