Payload logic progress

This commit is contained in:
Sam 2016-07-27 19:56:31 +01:00
parent 80eb7b2fd3
commit 888d3fb1aa

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Minecart; import org.bukkit.entity.Minecart;
@ -19,6 +20,7 @@ import org.bukkit.material.MaterialData;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
@ -50,6 +52,8 @@ public class QuiverPayload extends TeamGame
private Hologram _hologram; private Hologram _hologram;
private GameTeam _teamDirection; private GameTeam _teamDirection;
private Vector _lastDirection; private Vector _lastDirection;
private boolean _postiveVector;
private boolean _oldVector;
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>(); private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
@ -104,11 +108,12 @@ public class QuiverPayload extends TeamGame
{ {
Location location = WorldData.GetDataLocs("BLACK").get(0); Location location = WorldData.GetDataLocs("BLACK").get(0);
_minecart = location.getWorld().spawn(location, Minecart.class); _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)); _minecart.setDisplayBlock(new MaterialData(Material.TNT));
_hologram.setFollowEntity(_minecart); _hologram.setFollowEntity(_minecart);
_hologram.start();
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
player.getInventory().addItem(Quiver.SUPER_ARROW); player.getInventory().addItem(Quiver.SUPER_ARROW);
@ -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<>(); Map<GameTeam, Integer> mostPlayers = new HashMap<>();
@ -186,6 +191,8 @@ public class QuiverPayload extends TeamGame
{ {
GameTeam gameTeam = GetTeam(player); GameTeam gameTeam = GetTeam(player);
Bukkit.broadcastMessage(gameTeam.GetFormattedName() + " " + player.getName());
mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1); mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1);
} }
@ -197,6 +204,26 @@ public class QuiverPayload extends TeamGame
if (playerCount > mostPlayersCount) 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; _teamDirection = gameTeam;
} }
else if (playerCount == mostPlayersCount) else if (playerCount == mostPlayersCount)
@ -209,33 +236,55 @@ public class QuiverPayload extends TeamGame
if (_teamDirection == null) if (_teamDirection == null)
{ {
return; if (mostPlayersCount == 0)
}
if (_teamDirection.equals(GetTeamList().get(0)))
{
if (_lastDirection == null)
{ {
_minecart.setVelocity(new Vector(-0.1, 0, 0)); _hologram.setText("None");
} }
else else
{ {
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); _hologram.setText("Contested");
} }
_lastDirection = _minecart.getVelocity();
_minecart.setVelocity(new Vector(0, 0, 0));
return;
} }
else
if (_lastDirection == null)
{ {
if (_lastDirection == null) if (_postiveVector)
{ {
_minecart.setVelocity(new Vector(0.1, 0, 0)); _minecart.setVelocity(new Vector(0.1, 0, 0));
} }
else else
{ {
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); _minecart.setVelocity(new Vector(-0.1, 0, 0));
} }
_lastDirection = _minecart.getVelocity();
} }
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());
} }
} }
@ -271,7 +320,7 @@ public class QuiverPayload extends TeamGame
public void onCombatDeath(CombatDeathEvent event) public void onCombatDeath(CombatDeathEvent event)
{ {
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null) if (player == null)
{ {
return; return;