Refactor Block Lobbers and Bouncing Block
This commit is contained in:
parent
4789f640b2
commit
3f13c5f518
@ -72,8 +72,11 @@ public abstract class Challenge implements Listener
|
|||||||
|
|
||||||
protected ChallengeSettings Settings;
|
protected ChallengeSettings Settings;
|
||||||
protected ChallengeData Data;
|
protected ChallengeData Data;
|
||||||
|
|
||||||
protected static final int TICK_MULTIPLIER = 20;
|
protected static final int TICK_MULTIPLIER = 20;
|
||||||
|
private static final int TITLE_FADE_IN_TICKS = 5;
|
||||||
|
private static final int TITLE_STAY_TICKS = 40;
|
||||||
|
private static final int TITLE_FADE_OUT_TICKS = 5;
|
||||||
|
|
||||||
public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
|
public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
|
||||||
{
|
{
|
||||||
@ -512,6 +515,11 @@ public abstract class Challenge implements Listener
|
|||||||
Host.Manager.GetCondition().Factory().Cloak(reason, player, player, 7777, true, false);
|
Host.Manager.GetCondition().Factory().Cloak(reason, player, player, 7777, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void alert(Player player, String message)
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(null, message, TITLE_FADE_IN_TICKS, TITLE_STAY_TICKS, TITLE_FADE_OUT_TICKS, player);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void setBlock(Block block, Material type, byte data)
|
public void setBlock(Block block, Material type, byte data)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,7 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
|||||||
*/
|
*/
|
||||||
public class ChallengeAnvilDance extends Challenge
|
public class ChallengeAnvilDance extends Challenge
|
||||||
{
|
{
|
||||||
|
private static final int MAP_HEIGHT = 1;
|
||||||
private static final int MAP_SPAWN_SHIFT = 2;
|
private static final int MAP_SPAWN_SHIFT = 2;
|
||||||
private static final int SMOOTH_BRICK_DATA_RANGE = 3;
|
private static final int SMOOTH_BRICK_DATA_RANGE = 3;
|
||||||
|
|
||||||
@ -84,9 +85,9 @@ public class ChallengeAnvilDance extends Challenge
|
|||||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||||
int size = getArenaSize() - MAP_SPAWN_SHIFT;
|
int size = getArenaSize() - MAP_SPAWN_SHIFT;
|
||||||
|
|
||||||
for (Location location : circle(getCenter(), size, 1, true, false, 0))
|
for (Location location : circle(getCenter(), size, MAP_HEIGHT, true, false, 0))
|
||||||
{
|
{
|
||||||
spawns.add(location.add(0.5, 1.1, 0.5));
|
spawns.add(location.add(0.5, MAP_HEIGHT, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
return spawns;
|
return spawns;
|
||||||
@ -97,7 +98,7 @@ public class ChallengeAnvilDance extends Challenge
|
|||||||
{
|
{
|
||||||
_arenaStartSize = getArenaSize();
|
_arenaStartSize = getArenaSize();
|
||||||
|
|
||||||
for (Location location : circle(getCenter(), _arenaStartSize, 1, false, false, 0))
|
for (Location location : circle(getCenter(), _arenaStartSize, MAP_HEIGHT, false, false, 0))
|
||||||
{
|
{
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
setBlock(block, Material.SMOOTH_BRICK);
|
setBlock(block, Material.SMOOTH_BRICK);
|
||||||
|
@ -32,11 +32,11 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
|||||||
public class ChallengeArrowRampage extends Challenge
|
public class ChallengeArrowRampage extends Challenge
|
||||||
{
|
{
|
||||||
private static final int LOCKED_INVENTORY_SLOT = 4;
|
private static final int LOCKED_INVENTORY_SLOT = 4;
|
||||||
private static final int ARENA_MIN_SIZE = 9;
|
private static final int MAP_MIN_SIZE = 9;
|
||||||
private static final int MAP_SPAWN_SHIFT = 2;
|
private static final int MAP_SPAWN_SHIFT = 2;
|
||||||
private static final int MAP_HEIGHT = 3;
|
private static final int MAP_HEIGHT = 3;
|
||||||
private static final int MAP_SPAWN_HEIGHT = MAP_HEIGHT + 1;
|
private static final int MAP_SPAWN_HEIGHT = MAP_HEIGHT + 1;
|
||||||
|
|
||||||
private static final int HEIGHT_LVL0 = 0;
|
private static final int HEIGHT_LVL0 = 0;
|
||||||
private static final int HEIGHT_LVL1 = 1;
|
private static final int HEIGHT_LVL1 = 1;
|
||||||
private static final int HEIGHT_LVL2 = 2;
|
private static final int HEIGHT_LVL2 = 2;
|
||||||
@ -45,11 +45,11 @@ public class ChallengeArrowRampage extends Challenge
|
|||||||
private static final byte WOOL_DATA_LVL1 = 4;
|
private static final byte WOOL_DATA_LVL1 = 4;
|
||||||
private static final byte WOOL_DATA_LVL2 = 5;
|
private static final byte WOOL_DATA_LVL2 = 5;
|
||||||
private static final int WOOL_DATA_RANGE_LVL3 = 16;
|
private static final int WOOL_DATA_RANGE_LVL3 = 16;
|
||||||
|
|
||||||
private static final int JUMP_EFFECT_AMPLIFIER = 2;
|
private static final int JUMP_EFFECT_AMPLIFIER = 2;
|
||||||
private static final int ARROW_EXPLOSION_RADIUS = 3;
|
private static final int ARROW_EXPLOSION_RADIUS = 3;
|
||||||
private static final int ARROW_HIT_BLOCK_MAX_DISTANCE = 4;
|
private static final int ARROW_HIT_BLOCK_MAX_DISTANCE = 4;
|
||||||
|
|
||||||
public ChallengeArrowRampage(BawkBawkBattles host)
|
public ChallengeArrowRampage(BawkBawkBattles host)
|
||||||
{
|
{
|
||||||
super(
|
super(
|
||||||
@ -68,7 +68,7 @@ public class ChallengeArrowRampage extends Challenge
|
|||||||
public ArrayList<Location> createSpawns()
|
public ArrayList<Location> createSpawns()
|
||||||
{
|
{
|
||||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||||
int size = getArenaSize(ARENA_MIN_SIZE) - MAP_SPAWN_SHIFT;
|
int size = getArenaSize(MAP_MIN_SIZE) - MAP_SPAWN_SHIFT;
|
||||||
|
|
||||||
for (int x = -size; x < size; x++)
|
for (int x = -size; x < size; x++)
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@ public class ChallengeArrowRampage extends Challenge
|
|||||||
@Override
|
@Override
|
||||||
public void createMap()
|
public void createMap()
|
||||||
{
|
{
|
||||||
int size = getArenaSize(ARENA_MIN_SIZE);
|
int size = getArenaSize(MAP_MIN_SIZE);
|
||||||
|
|
||||||
for (int x = -size; x <= size; x++)
|
for (int x = -size; x <= size; x++)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,22 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
|||||||
*/
|
*/
|
||||||
public class ChallengeBlockLobbers extends Challenge
|
public class ChallengeBlockLobbers extends Challenge
|
||||||
{
|
{
|
||||||
private List<Material> _throwTypes = new ArrayList<>(Arrays.asList(
|
private static final int MAP_HEIGHT = 1;
|
||||||
|
private static final int MAP_MIN_SIZE = 11;
|
||||||
|
private static final int WOOL_DATA_RANGE = 16;
|
||||||
|
private static final int INVENTORY_HOTBAR_SIZE = 9;
|
||||||
|
|
||||||
|
private static final double FALLING_BLOCK_HEIGHT_ADD = 0.4;
|
||||||
|
private static final double FALLING_BLOCK_VECTOR_MULTIPLY = 1.5;
|
||||||
|
private static final double FALLING_BLOCK_VECTOR_HEIGHT_ADD = 0.3;
|
||||||
|
private static final double FALLING_BLOCK_VECTOR_HEIGHT_MAX = 10.0;
|
||||||
|
private static final float FALLING_BLOCK_HITBOX_GROW = 0.2F;
|
||||||
|
|
||||||
|
private static final double KNOCKBACK_VECTOR_MULTIPLY = 0.8;
|
||||||
|
private static final double KNOCKBACK_VECTOR_HEIGHT_ADD = 0.3;
|
||||||
|
private static final double KNOCKBACK_VECTOR_HEIGHT_MAX = 0.5;
|
||||||
|
|
||||||
|
private static final List<Material> THROW_TYPES = new ArrayList<>(Arrays.asList(
|
||||||
Material.STONE,
|
Material.STONE,
|
||||||
Material.COBBLESTONE,
|
Material.COBBLESTONE,
|
||||||
Material.GRASS,
|
Material.GRASS,
|
||||||
@ -60,9 +75,9 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
{
|
{
|
||||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||||
|
|
||||||
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
|
for (Location location : circle(getCenter(), getArenaSize(), MAP_HEIGHT, false, false, 0))
|
||||||
{
|
{
|
||||||
spawns.add(location.add(0.5, 1.1, 0.5));
|
spawns.add(location.add(0.5, MAP_HEIGHT, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
return spawns;
|
return spawns;
|
||||||
@ -71,10 +86,10 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
@Override
|
@Override
|
||||||
public void createMap()
|
public void createMap()
|
||||||
{
|
{
|
||||||
for (Location location : circle(getCenter(), getArenaSize(11), 1, false, false, 0))
|
for (Location location : circle(getCenter(), getArenaSize(MAP_MIN_SIZE), MAP_HEIGHT, false, false, 0))
|
||||||
{
|
{
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
setBlock(block, Material.WOOL, (byte) UtilMath.r(16));
|
setBlock(block, Material.WOOL, (byte) UtilMath.r(WOOL_DATA_RANGE));
|
||||||
|
|
||||||
addBlock(block);
|
addBlock(block);
|
||||||
}
|
}
|
||||||
@ -96,33 +111,22 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
if (event.getType() != UpdateType.FAST)
|
if (event.getType() != UpdateType.FAST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Player player : getPlayersAlive())
|
for (Player player : getPlayersIn(true))
|
||||||
{
|
{
|
||||||
Material material = UtilMath.randomElement(_throwTypes);
|
|
||||||
|
|
||||||
if (Data.isDone(player))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
Material material = UtilMath.randomElement(THROW_TYPES);
|
||||||
|
|
||||||
if (inventory.contains(material))
|
if (inventory.contains(material))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
if (UtilInv.getAmount(player, material) <= INVENTORY_HOTBAR_SIZE)
|
||||||
{
|
{
|
||||||
if (inventory.getItem(i) != null)
|
inventory.addItem(new ItemStack(material));
|
||||||
{
|
|
||||||
if (inventory.getItem(i).getType() == material)
|
|
||||||
{
|
|
||||||
if (inventory.getItem(i).getAmount() < 10)
|
|
||||||
inventory.addItem(new ItemStack(material));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
inventory.addItem(new ItemStack(material));
|
{
|
||||||
|
inventory.addItem(new ItemStack(material));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,13 +146,12 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
|
|
||||||
Material material = player.getItemInHand().getType();
|
Material material = player.getItemInHand().getType();
|
||||||
|
|
||||||
if (!_throwTypes.contains(material))
|
if (!THROW_TYPES.contains(material))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FallingBlock falling = player.getWorld().spawnFallingBlock(player.getLocation().add(0, 0.4, 0), material, (byte) 0);
|
FallingBlock falling = player.getWorld().spawnFallingBlock(player.getLocation().add(0, FALLING_BLOCK_HEIGHT_ADD, 0), material, (byte) 0);
|
||||||
UtilAction.velocity(falling, player.getLocation().getDirection(), 1.5, false, 0.0, 0.3, 10.0, true);
|
UtilAction.velocity(falling, player.getLocation().getDirection(), FALLING_BLOCK_VECTOR_MULTIPLY, false, 0.0, FALLING_BLOCK_VECTOR_HEIGHT_ADD, FALLING_BLOCK_VECTOR_HEIGHT_MAX, true);
|
||||||
Host.Manager.GetProjectile().AddThrow(falling, player, Host, -1, true, false, true, true, 0.2f);
|
Host.Manager.GetProjectile().AddThrow(falling, player, Host, -1, true, false, true, true, FALLING_BLOCK_HITBOX_GROW);
|
||||||
|
|
||||||
UtilInv.remove(player, material, (byte) 0, 1);
|
UtilInv.remove(player, material, (byte) 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +182,10 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
if (!isChallengeValid())
|
if (!isChallengeValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_throwTypes.contains(event.getEntity().getItemStack().getType()))
|
if (THROW_TYPES.contains(event.getEntity().getItemStack().getType()))
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -201,7 +206,7 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
if (target.equals(data.getThrower()))
|
if (target.equals(data.getThrower()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.getThrown().getLocation(), target.getLocation()), 0.8, false, 0, 0.3, 0.5, true);
|
UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.getThrown().getLocation(), target.getLocation()), KNOCKBACK_VECTOR_MULTIPLY, false, 0, KNOCKBACK_VECTOR_HEIGHT_ADD, KNOCKBACK_VECTOR_HEIGHT_MAX, true);
|
||||||
data.getThrown().remove();
|
data.getThrown().remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,17 +216,17 @@ public class ChallengeBlockLobbers extends Challenge
|
|||||||
|
|
||||||
if (handType == Material.AIR || handType == null)
|
if (handType == Material.AIR || handType == null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= 8; i++)
|
for (int i = 0; i <= INVENTORY_HOTBAR_SIZE; i++)
|
||||||
{
|
{
|
||||||
ItemStack current = player.getInventory().getItem(i);
|
ItemStack current = player.getInventory().getItem(i);
|
||||||
|
|
||||||
if (current == null)
|
if (current == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (current.getType() != Material.AIR)
|
if (current != null && current.getType() != Material.AIR)
|
||||||
{
|
{
|
||||||
player.getInventory().setHeldItemSlot(i);
|
player.getInventory().setHeldItemSlot(i);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import mineplex.core.common.util.C;
|
|||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilTextBottom;
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -38,10 +37,34 @@ import nautilus.game.arcade.game.games.mineware.challenge.LogicTracker;
|
|||||||
*/
|
*/
|
||||||
public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
||||||
{
|
{
|
||||||
|
private static final int SCORE_GOAL = 10;
|
||||||
|
|
||||||
|
private static final int MAP_MIN_SIZE = 9;
|
||||||
|
private static final int MAP_SPAWN_SHIFT = 2;
|
||||||
|
private static final int MAP_HEIGHT = 1;
|
||||||
|
|
||||||
|
private static final byte PLATFORM_BLOCK_DATA = 0;
|
||||||
|
private static final int JUMP_EFFECT_MULTIPLIER = 6;
|
||||||
|
|
||||||
|
private static final double TRAP_SPAWN_CHANCE = 0.2;
|
||||||
|
private static final byte TRAP_BLOCK_DATA = 14;
|
||||||
|
private static final int TRAP_SCORE_LOSS_MAX = 2;
|
||||||
|
private static final int TRAP_SCORE_LOSS_MIN = 1;
|
||||||
|
|
||||||
|
private static final float SCORE_SOUND_VOLUME = 0.2F;
|
||||||
|
private static final float SCORE_SOUND_PITCH = 0.2F;
|
||||||
|
private static final int SCORE_BLOCK_HEIGHT = 6;
|
||||||
|
private static final int SCORE_BLOCK_HEIGHT_ADD = 5;
|
||||||
|
private static final int SCORE_BLOCK_HEIGHT_MAX = SCORE_BLOCK_HEIGHT + SCORE_BLOCK_HEIGHT_ADD;
|
||||||
|
private static final int SCORE_BLOCK_SPAWN_SHIFT = 2;
|
||||||
|
private static final int SCORE_BLOCK_BOUND_MULTIPLY = 2;
|
||||||
|
private static final double SCORE_FIREWORK_LOCATION_ADD = 0.5;
|
||||||
|
|
||||||
|
private static final int MILLISECONDS_UNTIL_NEXT_SCORE_LOSS = 300;
|
||||||
|
|
||||||
private List<Player> _stepTracker = new ArrayList<>();
|
private List<Player> _stepTracker = new ArrayList<>();
|
||||||
private List<Block> _blocks = new ArrayList<>();
|
private List<Block> _blocks = new ArrayList<>();
|
||||||
private Map<Player, Integer> _score = new HashMap<>();
|
private Map<Player, Integer> _score = new HashMap<>();
|
||||||
private static int _goal = 10;
|
|
||||||
|
|
||||||
public ChallengeBouncingBlock(BawkBawkBattles host)
|
public ChallengeBouncingBlock(BawkBawkBattles host)
|
||||||
{
|
{
|
||||||
@ -51,7 +74,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
"Bouncing Block",
|
"Bouncing Block",
|
||||||
"Jump and punch floating wool blocks.",
|
"Jump and punch floating wool blocks.",
|
||||||
"Avoid landing on red wool.",
|
"Avoid landing on red wool.",
|
||||||
"First to " + _goal + " wins!");
|
"First to " + SCORE_GOAL + " wins!");
|
||||||
|
|
||||||
Settings.setUseMapHeight();
|
Settings.setUseMapHeight();
|
||||||
}
|
}
|
||||||
@ -60,11 +83,11 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
public ArrayList<Location> createSpawns()
|
public ArrayList<Location> createSpawns()
|
||||||
{
|
{
|
||||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||||
int size = getArenaSize(9) - 2;
|
int size = getArenaSize(MAP_MIN_SIZE) - MAP_SPAWN_SHIFT;
|
||||||
|
|
||||||
for (Location location : circle(getCenter(), size, 1, true, false, 0))
|
for (Location location : circle(getCenter(), size, MAP_HEIGHT, true, false, 0))
|
||||||
{
|
{
|
||||||
spawns.add(location.add(0.5, 1.1, 0.5));
|
spawns.add(location.add(0.5, MAP_HEIGHT, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
return spawns;
|
return spawns;
|
||||||
@ -73,18 +96,18 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
@Override
|
@Override
|
||||||
public void createMap()
|
public void createMap()
|
||||||
{
|
{
|
||||||
for (Location location : circle(getCenter(), getArenaSize(9), 1, false, false, 0))
|
for (Location location : circle(getCenter(), getArenaSize(MAP_MIN_SIZE), MAP_HEIGHT, false, false, 0))
|
||||||
{
|
{
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
setBlock(block, Material.WOOL);
|
setBlock(block, Material.WOOL);
|
||||||
|
|
||||||
if (Math.random() < 0.2)
|
if (Math.random() < TRAP_SPAWN_CHANCE)
|
||||||
{
|
{
|
||||||
setData(block, (byte) 14);
|
setData(block, (byte) TRAP_BLOCK_DATA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setData(block, (byte) 0);
|
setData(block, (byte) PLATFORM_BLOCK_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
addBlock(block);
|
addBlock(block);
|
||||||
@ -98,7 +121,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
{
|
{
|
||||||
Host.StrictAntiHack = false;
|
Host.StrictAntiHack = false;
|
||||||
|
|
||||||
addEffect(PotionEffectType.JUMP, 6);
|
addEffect(PotionEffectType.JUMP, JUMP_EFFECT_MULTIPLIER);
|
||||||
|
|
||||||
for (Player player : getPlayersAlive())
|
for (Player player : getPlayersAlive())
|
||||||
{
|
{
|
||||||
@ -205,15 +228,14 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
private void hitBlock(Player player, Block block)
|
private void hitBlock(Player player, Block block)
|
||||||
{
|
{
|
||||||
increment(player, 1);
|
increment(player, 1);
|
||||||
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 0.2f, 0.2f);
|
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, SCORE_SOUND_VOLUME, SCORE_SOUND_PITCH);
|
||||||
|
resetBlock(block);
|
||||||
setBlock(block, Material.AIR);
|
spawnRandomWool();
|
||||||
spawnRandomWool(getArenaSize(9), (UtilMath.r(6) + 5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCompleted(Player player)
|
private void checkCompleted(Player player)
|
||||||
{
|
{
|
||||||
if (_score.get(player) >= _goal)
|
if (_score.get(player) >= SCORE_GOAL)
|
||||||
{
|
{
|
||||||
setCompleted(player);
|
setCompleted(player);
|
||||||
UtilTextBottom.display(C.cGreen + C.Bold + "Completed!", player);
|
UtilTextBottom.display(C.cGreen + C.Bold + "Completed!", player);
|
||||||
@ -227,16 +249,16 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
|
|
||||||
private boolean canLooseScore(Player player)
|
private boolean canLooseScore(Player player)
|
||||||
{
|
{
|
||||||
return Recharge.Instance.use(player, "Movement", 300, false, false) && _score.get(player) > 0;
|
return Recharge.Instance.use(player, "Score Loss", MILLISECONDS_UNTIL_NEXT_SCORE_LOSS, false, false) && _score.get(player) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int subtractFromScore(Player player)
|
private int subtractFromScore(Player player)
|
||||||
{
|
{
|
||||||
int amount = 2;
|
int amount = TRAP_SCORE_LOSS_MAX;
|
||||||
|
|
||||||
if (_score.get(player) == 1)
|
if (_score.get(player) == 1)
|
||||||
{
|
{
|
||||||
amount = 1;
|
amount = TRAP_SCORE_LOSS_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtract(player, amount);
|
subtract(player, amount);
|
||||||
@ -245,7 +267,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
|
|
||||||
private void showSubtractMessage(Player player, int amount)
|
private void showSubtractMessage(Player player, int amount)
|
||||||
{
|
{
|
||||||
UtilTextMiddle.display(null, "Score decreased by " + C.cRed + amount + C.Reset + "!", 5, 40, 5, player);
|
alert(player, "Score decreased by " + C.cRed + amount + C.Reset + "!");
|
||||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0F, 1.0F);
|
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,33 +279,28 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final double SCORE_BLOCK_SPAWN_CHANCE = 0.1;
|
||||||
|
private static final int SCORE_BLOCK_DATA_RANGE = 16;
|
||||||
|
|
||||||
private void spawnStartingWool()
|
private void spawnStartingWool()
|
||||||
{
|
{
|
||||||
whileLoop: while (_blocks.size() <= Math.ceil(Host.getPlayersWithRemainingLives() / 2) + 1)
|
whileLoop: while (_blocks.size() <= Settings.getMaxCompletedCount() + 1)
|
||||||
{
|
{
|
||||||
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
|
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
|
||||||
{
|
{
|
||||||
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
|
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
|
||||||
{
|
{
|
||||||
for (int y = 5; y <= 11; y++)
|
for (int y = SCORE_BLOCK_HEIGHT; y <= SCORE_BLOCK_HEIGHT_MAX; y++)
|
||||||
{
|
{
|
||||||
Block block = getCenter().getBlock().getRelative(x, y, z);
|
Block block = getCenter().getBlock().getRelative(x, y, z);
|
||||||
|
|
||||||
if (block.isEmpty() || block.getType() == null)
|
if (block.isEmpty() || block.getType() == null)
|
||||||
{
|
{
|
||||||
if (UtilMath.r(50) == 0)
|
if (Math.random() < SCORE_BLOCK_SPAWN_CHANCE)
|
||||||
{
|
{
|
||||||
Byte color = (byte) UtilMath.r(16);
|
spawnRandomWoolAt(x, y, z);
|
||||||
|
|
||||||
while (color == 14)
|
if (_blocks.size() >= Settings.getMaxCompletedCount() + 1)
|
||||||
{
|
|
||||||
color = (byte) UtilMath.r(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
setBlock(block, Material.WOOL, (byte) UtilMath.r(16));
|
|
||||||
_blocks.add(block);
|
|
||||||
|
|
||||||
if (_blocks.size() >= Math.ceil(Host.getPlayersWithRemainingLives() / 2) + 1)
|
|
||||||
{
|
{
|
||||||
break whileLoop;
|
break whileLoop;
|
||||||
}
|
}
|
||||||
@ -295,25 +312,30 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
private void spawnRandomWool()
|
||||||
private void spawnRandomWool(int size, int height)
|
|
||||||
{
|
{
|
||||||
size = size - 2;
|
int size = getArenaSize(MAP_MIN_SIZE) - SCORE_BLOCK_SPAWN_SHIFT;
|
||||||
int x = UtilMath.r(size * 2) - size;
|
|
||||||
int y = height;
|
|
||||||
int z = UtilMath.r(size * 2) - size;
|
|
||||||
|
|
||||||
|
int x = UtilMath.r(size * SCORE_BLOCK_BOUND_MULTIPLY) - size;
|
||||||
|
int y = SCORE_BLOCK_HEIGHT + UtilMath.r(SCORE_BLOCK_HEIGHT_ADD);
|
||||||
|
int z = UtilMath.r(size * SCORE_BLOCK_BOUND_MULTIPLY) - size;
|
||||||
|
|
||||||
|
spawnRandomWoolAt(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void spawnRandomWoolAt(int x, int y, int z)
|
||||||
|
{
|
||||||
Block b = getCenter().getBlock().getRelative(x, y, z);
|
Block b = getCenter().getBlock().getRelative(x, y, z);
|
||||||
Byte color = (byte) UtilMath.r(16);
|
Byte color = (byte) UtilMath.r(SCORE_BLOCK_DATA_RANGE);
|
||||||
|
|
||||||
while (color == 14)
|
while (color == TRAP_BLOCK_DATA)
|
||||||
{
|
{
|
||||||
color = (byte) UtilMath.r(16);
|
color = (byte) UtilMath.r(SCORE_BLOCK_DATA_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlock(b, Material.WOOL, color);
|
setBlock(b, Material.WOOL, color);
|
||||||
|
UtilFirework.playFirework(b.getLocation().add(SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD), Type.BALL, DyeColor.getByWoolData(b.getData()).getColor(), false, false);
|
||||||
UtilFirework.playFirework(b.getLocation().add(0.5, 0.5, 0.5), Type.BALL, DyeColor.getByWoolData(b.getData()).getColor(), false, false);
|
|
||||||
|
|
||||||
_blocks.add(b);
|
_blocks.add(b);
|
||||||
}
|
}
|
||||||
@ -323,8 +345,10 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
int score = _score.get(player);
|
int score = _score.get(player);
|
||||||
int updatedScore = score + amount;
|
int updatedScore = score + amount;
|
||||||
|
|
||||||
if (updatedScore <= 10)
|
if (updatedScore <= SCORE_GOAL)
|
||||||
|
{
|
||||||
_score.put(player, updatedScore);
|
_score.put(player, updatedScore);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void subtract(Player player, int amount)
|
private void subtract(Player player, int amount)
|
||||||
@ -333,9 +357,13 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker
|
|||||||
int updatedScore = score - amount;
|
int updatedScore = score - amount;
|
||||||
|
|
||||||
if (updatedScore > 0)
|
if (updatedScore > 0)
|
||||||
|
{
|
||||||
_score.put(player, updatedScore);
|
_score.put(player, updatedScore);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_score.put(player, 0);
|
_score.put(player, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user