Payload logic progress
This commit is contained in:
parent
80eb7b2fd3
commit
888d3fb1aa
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Minecart;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
@ -50,6 +52,8 @@ public class QuiverPayload extends TeamGame
|
||||
private Hologram _hologram;
|
||||
private GameTeam _teamDirection;
|
||||
private Vector _lastDirection;
|
||||
private boolean _postiveVector;
|
||||
private boolean _oldVector;
|
||||
|
||||
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
|
||||
|
||||
@ -104,10 +108,11 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
Location location = WorldData.GetDataLocs("BLACK").get(0);
|
||||
_minecart = location.getWorld().spawn(location, Minecart.class);
|
||||
_hologram = new Hologram(Manager.getHologramManager(), location, "None");
|
||||
_hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None");
|
||||
|
||||
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
|
||||
_hologram.setFollowEntity(_minecart);
|
||||
_hologram.start();
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
@ -172,7 +177,7 @@ public class QuiverPayload extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.FAST || _minecart != null)
|
||||
if (event.getType() == UpdateType.FAST && _minecart != null)
|
||||
{
|
||||
|
||||
Map<GameTeam, Integer> mostPlayers = new HashMap<>();
|
||||
@ -186,6 +191,8 @@ public class QuiverPayload extends TeamGame
|
||||
{
|
||||
GameTeam gameTeam = GetTeam(player);
|
||||
|
||||
Bukkit.broadcastMessage(gameTeam.GetFormattedName() + " " + player.getName());
|
||||
|
||||
mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1);
|
||||
}
|
||||
|
||||
@ -197,6 +204,26 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
if (playerCount > mostPlayersCount)
|
||||
{
|
||||
if (_teamDirection == null)
|
||||
{
|
||||
if (GetTeamList().get(0).equals(gameTeam))
|
||||
{
|
||||
_postiveVector = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_postiveVector = false;
|
||||
}
|
||||
}
|
||||
else if (_teamDirection.equals(gameTeam))
|
||||
{
|
||||
_postiveVector = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_postiveVector = false;
|
||||
}
|
||||
|
||||
_teamDirection = gameTeam;
|
||||
}
|
||||
else if (playerCount == mostPlayersCount)
|
||||
@ -209,33 +236,55 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
if (_teamDirection == null)
|
||||
{
|
||||
if (mostPlayersCount == 0)
|
||||
{
|
||||
_hologram.setText("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
_hologram.setText("Contested");
|
||||
}
|
||||
|
||||
_minecart.setVelocity(new Vector(0, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_teamDirection.equals(GetTeamList().get(0)))
|
||||
{
|
||||
if (_lastDirection == null)
|
||||
{
|
||||
_minecart.setVelocity(new Vector(-0.1, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
|
||||
}
|
||||
_lastDirection = _minecart.getVelocity();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_lastDirection == null)
|
||||
if (_postiveVector)
|
||||
{
|
||||
_minecart.setVelocity(new Vector(0.1, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
_minecart.setVelocity(new Vector(-0.1, 0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_oldVector == _postiveVector)
|
||||
{
|
||||
_minecart.setVelocity(_lastDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
_minecart.setVelocity(_lastDirection.multiply(-1));
|
||||
}
|
||||
|
||||
_oldVector = _postiveVector;
|
||||
}
|
||||
|
||||
if (UtilBlock.solid(_minecart.getVelocity().add(_minecart.getVelocity().normalize()).toLocation(_minecart.getWorld()).getBlock()))
|
||||
{
|
||||
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(5));
|
||||
}
|
||||
else
|
||||
{
|
||||
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
|
||||
}
|
||||
|
||||
_lastDirection = _minecart.getVelocity();
|
||||
}
|
||||
_hologram.setText(_teamDirection.GetFormattedName());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user