Update second Lava Run to patch obsidian bugs

This commit is contained in:
Thanos Paravantis 2016-06-18 20:56:33 +03:00
parent ce7bb82d67
commit bccce7593f

View File

@ -28,8 +28,9 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
*/ */
public class ChallengeLavaRun extends Challenge public class ChallengeLavaRun extends Challenge
{ {
private int _arenaStartSize;
private Block _obsidian; private Block _obsidian;
private Block _lastObsidian; private boolean _shouldMoveObsidian;
private List<Block> _platform; private List<Block> _platform;
private int _mapY = 4; private int _mapY = 4;
private long _delay; private long _delay;
@ -54,6 +55,7 @@ public class ChallengeLavaRun extends Challenge
public ArrayList<Location> createSpawns() public ArrayList<Location> createSpawns()
{ {
ArrayList<Location> spawns = new ArrayList<Location>(); ArrayList<Location> spawns = new ArrayList<Location>();
_arenaStartSize = getArenaSize();
int size = getArenaSize() - 3; int size = getArenaSize() - 3;
for (int x = -size; x <= size; x++) for (int x = -size; x <= size; x++)
@ -77,22 +79,54 @@ public class ChallengeLavaRun extends Challenge
public void onStart() public void onStart()
{ {
_delay = System.currentTimeMillis() + 2000; _delay = System.currentTimeMillis() + 2000;
_obsidian = generateObsidianBlock(); _obsidian = createObsidianBlock();
createLava(); createLava();
disguisePlayers(); disguisePlayers();
} }
@Override @EventHandler
public void onEnd() public void onUpdate(UpdateEvent event)
{ {
if (_lastObsidian != null) if (event.getType() != UpdateType.TICK)
return;
if (!isChallengeValid())
return;
if (_delay > System.currentTimeMillis())
return;
if (_shouldMoveObsidian)
{ {
addBlock(_lastObsidian); resetBlock(_obsidian);
generatePlatform();
_obsidian = createObsidianBlock();
blockBreakEffect(_obsidian, false);
playSound();
_delay = System.currentTimeMillis();
if (_delayMin > 0)
{
_delayMin -= 100;
_delay += _delayMin;
}
_disappearingBlocks++;
_shouldMoveObsidian = false;
} }
else if (_obsidian != null) else
{ {
addBlock(_obsidian); if (isPlatformEmpty())
{
_delay = System.currentTimeMillis() + 1500;
_shouldMoveObsidian = true;
}
else
{
destroyPlatform();
}
} }
} }
@ -120,53 +154,6 @@ public class ChallengeLavaRun extends Challenge
event.AddMod("Ensure Death", null, 9999, false); event.AddMod("Ensure Death", null, 9999, false);
} }
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!isChallengeValid())
return;
if (_delay > System.currentTimeMillis())
return;
if (_obsidian == null)
{
resetBlock(_lastObsidian);
_obsidian = generateObsidianBlock();
generatePlatform();
setBlock(_obsidian, Material.OBSIDIAN);
blockBreakEffect(_obsidian, false);
playSound();
_delay = System.currentTimeMillis();
if (_delayMin > 0)
{
_delayMin -= 100;
_delay += _delayMin;
}
_disappearingBlocks++;
}
else
{
if (isPlatformEmpty())
{
_delay = System.currentTimeMillis() + 1500;
_lastObsidian = _obsidian;
_obsidian = null;
}
else
{
destroyPlatform();
}
}
}
private void generatePlatform() private void generatePlatform()
{ {
_platform = new ArrayList<>(); _platform = new ArrayList<>();
@ -201,13 +188,9 @@ public class ChallengeLavaRun extends Challenge
} }
} }
private Block generateObsidianBlock() private Block createObsidianBlock()
{ {
Block block = getCenter().add( Block block = getCenter().add(UtilMath.r(_arenaStartSize), _mapY, UtilMath.r(_arenaStartSize)).getBlock();
UtilMath.r(21) - 9.5,
_mapY,
UtilMath.r(21) - 9.5).getBlock();
setBlock(block, Material.OBSIDIAN); setBlock(block, Material.OBSIDIAN);
return block; return block;
} }