Fix increasing loop in Overtime

This commit is contained in:
Sam 2016-08-31 13:26:54 +01:00
parent 1bfebf358f
commit 8d222aafec

View File

@ -443,7 +443,7 @@ public class QuiverPayload extends TeamGame
* is determined by calculating which gameTeam has the least amount
* of distance left the push the payload.
*/
if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT))
if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT) && !_isOvertime)
{
/*
* If a particular gameTeam has scored the most points they are
@ -501,6 +501,54 @@ public class QuiverPayload extends TeamGame
SetState(GameState.End);
return;
}
if (event.getType() == UpdateType.SEC && _isOvertime)
{
if (_lastOvertimeTrack.isEmpty())
{
_lastOvertimeTrack.add(_pathMarkers.get(0).getBlock().getRelative(BlockFace.DOWN));
_lastOvertimeTrack.add(_pathMarkers.get(_pathMarkers.size() - 1).getBlock().getRelative(BlockFace.DOWN));
}
List<Block> newTracks = new ArrayList<>();
for (Block block : _lastOvertimeTrack)
{
if (isMinecartNearMarker(block.getLocation()))
{
Location locationA = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_RED));
Location locationB = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_BLUE));
if (UtilMath.offset(_minecart.getLocation(), locationA) < UtilMath.offset(_minecart.getLocation(), locationB))
{
WinnerTeam = GetTeam(org.bukkit.ChatColor.AQUA);
}
else
{
WinnerTeam = GetTeam(org.bukkit.ChatColor.RED);
}
WinnerTeam = _teamDirection;
_payloadState = PayloadState.RESTARTING;
displayEndEffect();
return;
}
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.RAILS)
{
block.setType(Material.AIR);
newTracks.add(other);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F, 30, ViewDist.NORMAL);
break;
}
}
}
_lastOvertimeTrack.clear();
_lastOvertimeTrack.addAll(newTracks);
}
/*
* If the game only has 60 seconds left before it times out we sent
@ -799,53 +847,6 @@ public class QuiverPayload extends TeamGame
{
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _minecart.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 1, 10, ViewDist.LONG);
}
if (event.getType() == UpdateType.SEC && _isOvertime)
{
if (_lastOvertimeTrack.isEmpty())
{
_lastOvertimeTrack.add(_pathMarkers.get(0).getBlock().getRelative(BlockFace.DOWN));
_lastOvertimeTrack.add(_pathMarkers.get(_pathMarkers.size() - 1).getBlock().getRelative(BlockFace.DOWN));
}
Iterator<Block> iterator = _lastOvertimeTrack.iterator();
while (iterator.hasNext())
{
Block block = iterator.next();
if (isMinecartNearMarker(block.getLocation()))
{
Location locationA = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_RED));
Location locationB = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_BLUE));
if (UtilMath.offset(_minecart.getLocation(), locationA) < UtilMath.offset(_minecart.getLocation(), locationB))
{
WinnerTeam = GetTeam(org.bukkit.ChatColor.AQUA);
}
else
{
WinnerTeam = GetTeam(org.bukkit.ChatColor.RED);
}
WinnerTeam = _teamDirection;
_payloadState = PayloadState.RESTARTING;
displayEndEffect();
return;
}
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.RAILS)
{
block.setType(Material.AIR);
iterator.remove();
_lastOvertimeTrack.add(other);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F, 30, ViewDist.NORMAL);
}
}
}
}
}
@Override