lots of changes to monster maze, check trello for list
This commit is contained in:
parent
c648d7c186
commit
5824ec6df0
@ -47,6 +47,7 @@ public class Maze implements Listener
|
||||
private ArrayList<Location> _goals;
|
||||
private HashSet<Block> _waypoints;
|
||||
private HashSet<Block> _disabledWaypoints;
|
||||
private HashSet<Block> _oldDisabledWaypoints;
|
||||
private ArrayList<Location> _borders;
|
||||
|
||||
private Location _center;
|
||||
@ -61,8 +62,6 @@ public class Maze implements Listener
|
||||
private int _phaseTimer = -1;
|
||||
private int _padDecayTimer = -1;
|
||||
|
||||
private ArrayList<ClientsideBlock> _clientsideBlocks = new ArrayList<>();
|
||||
|
||||
private HashMap<Entity, MazeMobWaypoint> _ents = new HashMap<Entity, MazeMobWaypoint>();
|
||||
|
||||
public Maze(MonsterMaze host, ArrayList<Location> map, ArrayList<Location> spawns, ArrayList<Location> goals, Location center, ArrayList<Location> _glassBounds)
|
||||
@ -75,6 +74,7 @@ public class Maze implements Listener
|
||||
|
||||
_waypoints = new HashSet<Block>();
|
||||
_disabledWaypoints = new HashSet<Block>();
|
||||
_oldDisabledWaypoints = new HashSet<Block>();
|
||||
|
||||
for (Location loc : _map)
|
||||
{
|
||||
@ -91,6 +91,7 @@ public class Maze implements Listener
|
||||
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
_waypoints.add(loc.getBlock());
|
||||
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.GOLD_BLOCK);
|
||||
}
|
||||
|
||||
@ -110,12 +111,18 @@ public class Maze implements Listener
|
||||
|
||||
public void update()
|
||||
{
|
||||
if(_safePad != null)
|
||||
{
|
||||
for(Player p : Host.GetPlayers(true))
|
||||
p.setCompassTarget(_safePad.getLocation());
|
||||
}
|
||||
if (Host.IsLive())
|
||||
{
|
||||
//checkGoal();
|
||||
checkPlayersOnSafePad();
|
||||
move();
|
||||
bump();
|
||||
removeMobsOnSafePad();
|
||||
if(_phaseTimer <= -1)
|
||||
{
|
||||
for(Player p : Host.GetPlayers(true))
|
||||
@ -142,6 +149,34 @@ public class Maze implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
private void removeMobsOnSafePad()
|
||||
{
|
||||
Iterator<Entity> it = _ents.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entity e = it.next();
|
||||
if(_safePad != null)
|
||||
{
|
||||
if(_safePad.isOn(e))
|
||||
{
|
||||
System.out.println("entity on safepad removed");
|
||||
it.remove();
|
||||
e.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(_oldSafePad != null)
|
||||
{
|
||||
if(_oldSafePad.isOn(e))
|
||||
{
|
||||
System.out.println("entity on old safepad removed");
|
||||
it.remove();
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bump()
|
||||
{
|
||||
//Hit Players
|
||||
@ -150,13 +185,15 @@ public class Maze implements Listener
|
||||
if (!Recharge.Instance.usable(player, "Monster Hit"))
|
||||
continue;
|
||||
|
||||
if(_playersOnPad.contains(player))
|
||||
continue;
|
||||
if(_safePad != null)
|
||||
{
|
||||
if(_safePad.isOn(player)) continue;
|
||||
}
|
||||
|
||||
//Hit Snowman
|
||||
for (Entity ent : _ents.keySet())
|
||||
{
|
||||
if (UtilMath.offset2d(player, ent) < 1)
|
||||
if (UtilMath.offset(player, ent) < 1)
|
||||
{
|
||||
Recharge.Instance.useForce(player, "Monster Hit", 1000);
|
||||
|
||||
@ -382,10 +419,13 @@ public class Maze implements Listener
|
||||
{
|
||||
_oldSafePad = _safePad;
|
||||
_oldSafePad.turnOffBeacon();
|
||||
_padDecayTimer = 5;
|
||||
_padDecayTimer = 11;
|
||||
|
||||
_oldDisabledWaypoints = new HashSet<>(_disabledWaypoints);
|
||||
}
|
||||
_disabledWaypoints.clear();
|
||||
ArrayList<Location> goals = new ArrayList<Location>(_goals);
|
||||
if(_oldSafePad != null) goals.remove(_oldSafePad.getLocation());
|
||||
if(_oldSafePad != null) goals.remove(_oldSafePad.getLocation().clone().add(0, 1, 0));
|
||||
|
||||
_safePad = new SafePad(Host, this, UtilAlg.Random(goals).clone().subtract(0,1,0)); // maybe don't need to clone()
|
||||
_safePad.build();
|
||||
@ -419,34 +459,63 @@ public class Maze implements Listener
|
||||
if(_padDecayTimer == -1) return;
|
||||
|
||||
_padDecayTimer--;
|
||||
// 5
|
||||
|
||||
if(_oldSafePad != null)
|
||||
{
|
||||
if(_padDecayTimer == 4)
|
||||
if(_padDecayTimer == 10)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)4);
|
||||
_oldSafePad.setGlassData((byte)5); // green
|
||||
_oldSafePad.turnOffBeacon();
|
||||
_oldSafePad.setCrackedProgress(1);
|
||||
}
|
||||
else if(_padDecayTimer == 9)
|
||||
{
|
||||
_oldSafePad.setCrackedProgress(2);
|
||||
}
|
||||
else if(_padDecayTimer == 8)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)4); // yellow
|
||||
_oldSafePad.setCrackedProgress(3);
|
||||
}
|
||||
else if(_padDecayTimer == 7)
|
||||
{
|
||||
_oldSafePad.setCrackedProgress(4);
|
||||
}
|
||||
else if(_padDecayTimer == 6)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)1); // orange
|
||||
_oldSafePad.setCrackedProgress(5);
|
||||
}
|
||||
else if(_padDecayTimer == 5)
|
||||
{
|
||||
_oldSafePad.setCrackedProgress(6);
|
||||
}
|
||||
else if(_padDecayTimer == 4)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)14); // red
|
||||
_oldSafePad.setCrackedProgress(7);
|
||||
}
|
||||
else if(_padDecayTimer == 3)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)1);
|
||||
_oldSafePad.setCrackedProgress(8);
|
||||
}
|
||||
else if(_padDecayTimer == 2)
|
||||
{
|
||||
_oldSafePad.setGlassData((byte)14);
|
||||
_oldSafePad.setCrackedProgress(9);
|
||||
}
|
||||
else if(_padDecayTimer == 1)
|
||||
{
|
||||
_oldSafePad.setCrackedProgress(-1);
|
||||
_oldSafePad.destroy();
|
||||
_oldSafePad = null;
|
||||
|
||||
if(_disabledWaypoints.size() > 0)
|
||||
if(_oldDisabledWaypoints.size() > 0)
|
||||
{
|
||||
for(Block b : _disabledWaypoints)
|
||||
for(Block b : _oldDisabledWaypoints)
|
||||
{
|
||||
_waypoints.add(b);
|
||||
}
|
||||
_disabledWaypoints.clear();
|
||||
_oldDisabledWaypoints.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -464,7 +533,7 @@ public class Maze implements Listener
|
||||
|
||||
if(_phaseTimer == 15 || _phaseTimer == 10)
|
||||
{
|
||||
UtilTextMiddle.display("", C.cGray + C.Bold + _phaseTimer + " seconds to get to the Safe Zone!", 0, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
|
||||
UtilTextMiddle.display("", C.cAqua + C.Bold + _phaseTimer + " seconds to get to the Safe Pad!", 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
|
||||
}
|
||||
|
||||
if(_phaseTimer == 5 || _phaseTimer == 4)
|
||||
@ -519,112 +588,34 @@ public class Maze implements Listener
|
||||
{
|
||||
if(_safePad.isOn(p) && !_playersOnPad.contains(p))
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Game", C.cGreen + "Great, you made it. Stay on the Safe Pad!"));
|
||||
_playersOnPad.add(p);
|
||||
if(_playersOnPad.size() == 1) // first player
|
||||
{
|
||||
_phaseTimer = 21; // start the countdown
|
||||
_phaseTimer = 20; // start the countdown
|
||||
|
||||
UtilTextMiddle.display(C.cGold + C.Bold + "AWESOME!", C.cGold + "You were the first to make it to the Safe Pad!", 5, 40, 5, p);
|
||||
p.playSound(p.getLocation(), Sound.SUCCESSFUL_HIT, 1.0f, 1.0f);
|
||||
UtilPlayer.message(p, F.main("Game", C.cGreen + "Great, you made it. Stay on the Safe Pad!"));
|
||||
|
||||
ArrayList<Player> pElse = Host.GetPlayers(false);
|
||||
pElse.remove(p);
|
||||
for(Player i : pElse)
|
||||
{
|
||||
UtilPlayer.message(i, C.cRed + C.Bold + p.getName() + " was the first to make it to the Safe Pad!");
|
||||
UtilPlayer.message(i, C.cRed + "Everyone not on the Safe Pad in 20 seconds will die!"); // I don't like this message
|
||||
UtilPlayer.message(i, C.cGray + "Everyone not on the Safe Pad in 20 seconds will die!"); // I don't like this message
|
||||
}
|
||||
} else // not the first
|
||||
{
|
||||
p.playSound(p.getLocation(), Sound.SUCCESSFUL_HIT, 1.0f, 1.0f);
|
||||
UtilTextMiddle.display(C.cGreen + C.Bold + "Great!", C.cGreen + "Stay on the Safe Pad!", 5, 40, 5, p);
|
||||
}
|
||||
|
||||
buildSafePadBarrier(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildSafePadBarrier(Player p)
|
||||
if(!_safePad.isOn(p) && _playersOnPad.contains(p))
|
||||
{
|
||||
ArrayList<Block> _cube = UtilBlock.getInBoundingBox(_safePad.getLocation().clone().add(3, 2, 3), _safePad.getLocation().clone().add(-3, 1, -3), false);
|
||||
ArrayList<Block> _hollowedCube = UtilBlock.getInBoundingBox(_safePad.getLocation().clone().add(2, 2, 2), _safePad.getLocation().clone().add(-2, 1, -2), false);
|
||||
_cube.removeAll(_hollowedCube);
|
||||
|
||||
for(Block b : _cube)
|
||||
{
|
||||
_clientsideBlocks.add(new ClientsideBlock(p, b.getLocation(), Material.STAINED_GLASS, (byte)3));
|
||||
UtilTextMiddle.display(C.cDRed + C.Bold + "Danger!", C.cRed + "Get back to the Safe Pad!", 0, 10, 0, p);
|
||||
//UtilTextBottom.display(C.cRed + "Get back to the Safe Pad!", p);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSafePadBarrier() // for all players ;)
|
||||
{
|
||||
for(ClientsideBlock csb : _clientsideBlocks)
|
||||
{
|
||||
csb.disable();
|
||||
}
|
||||
_clientsideBlocks.clear();
|
||||
}
|
||||
|
||||
private class ClientsideBlock
|
||||
{
|
||||
private Player _player;
|
||||
|
||||
private Location _loc;
|
||||
private Material _mat;
|
||||
private byte _data;
|
||||
|
||||
private Material _origMat;
|
||||
private byte _origData;
|
||||
|
||||
private boolean _shown = false;
|
||||
|
||||
public ClientsideBlock(Player p, Location loc, Material mat, byte data)
|
||||
{
|
||||
_player = p;
|
||||
|
||||
_loc = loc;
|
||||
_mat = mat;
|
||||
_data = data;
|
||||
|
||||
_origMat = _loc.getBlock().getType();
|
||||
_origData = _loc.getBlock().getData();
|
||||
|
||||
enable();
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if(isShown()) return;
|
||||
|
||||
_player.sendBlockChange(_loc, _mat, _data);
|
||||
_shown = true;
|
||||
}
|
||||
|
||||
public void disable()
|
||||
{
|
||||
if(!isShown()) return;
|
||||
|
||||
_player.sendBlockChange(_loc, _origMat, _origData);
|
||||
|
||||
_shown = false;
|
||||
}
|
||||
|
||||
public boolean isShown() // this can break if the block changes and overrides the client-side blocks, but this won't happen if it's being used properly (maybe should add a check?...)
|
||||
{
|
||||
return _shown;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _loc;
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerContainmentUnit()
|
||||
|
@ -40,8 +40,7 @@ public class MonsterMaze extends SoloGame
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Get to the safe pad, but avoid the monsters!",
|
||||
"You can't jump.",
|
||||
"Be the first to make it to the Safe Pad, but avoid the monsters!"
|
||||
});
|
||||
|
||||
this.DamagePvP = false;
|
||||
@ -70,9 +69,6 @@ public class MonsterMaze extends SoloGame
|
||||
}
|
||||
else if(event.GetState() == GameState.Live)
|
||||
{
|
||||
for(Player player : GetPlayers(true))
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
_maze.removePlayerContainmentUnit();
|
||||
|
||||
UtilTextMiddle.display(C.cAqua + C.Bold + "Push F5", C.cWhite + "Monster Maze is best played in 3rd Person", 10, 70, 10);
|
||||
@ -91,14 +87,21 @@ public class MonsterMaze extends SoloGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Antijump(UpdateEvent event)
|
||||
public void PotionEffects(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.SEC) return; // because why not
|
||||
if(!InProgress()) return;
|
||||
for(Player pl : GetPlayers(true))
|
||||
{
|
||||
pl.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000000, 250));
|
||||
pl.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 80, 250));
|
||||
if(GetPlayers(true).size() > 4)
|
||||
{
|
||||
pl.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000000, 250));
|
||||
}
|
||||
else
|
||||
{
|
||||
pl.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,21 @@
|
||||
package nautilus.game.arcade.game.games.monstermaze;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockBreakAnimation;
|
||||
|
||||
public class SafePad
|
||||
{
|
||||
@ -80,11 +83,11 @@ public class SafePad
|
||||
|
||||
public class SafePadBlock
|
||||
{
|
||||
Material _origM;
|
||||
byte _origD;
|
||||
private Material _origM;
|
||||
private byte _origD;
|
||||
|
||||
Material _tempMat;
|
||||
byte _tempData;
|
||||
private Material _tempMat;
|
||||
private byte _tempData;
|
||||
|
||||
Location _loc;
|
||||
|
||||
@ -111,6 +114,16 @@ public class SafePad
|
||||
MapUtil.QuickChangeBlockAt(_loc, _tempMat.getId(), _tempData);
|
||||
}
|
||||
|
||||
public Material getBlockMaterial()
|
||||
{
|
||||
return _loc.getBlock().getType();
|
||||
}
|
||||
|
||||
public byte getBlockData()
|
||||
{
|
||||
return _loc.getBlock().getData();
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _loc;
|
||||
@ -139,7 +152,7 @@ public class SafePad
|
||||
{
|
||||
for(SafePadBlock spb : _blocks)
|
||||
{
|
||||
if(!spb.getLocation().getBlock().getType().equals(Material.STAINED_GLASS)) continue;
|
||||
if(!spb.getBlockMaterial().equals(Material.STAINED_GLASS)) continue;
|
||||
spb.setData(newData);
|
||||
}
|
||||
}
|
||||
@ -148,8 +161,8 @@ public class SafePad
|
||||
{
|
||||
for(SafePadBlock bl : _blocks)
|
||||
{
|
||||
if(bl.getLocation().getBlock().getType().equals(Material.GOLD_BLOCK)) bl.restore();
|
||||
if(bl.getLocation().getBlock().getType().equals(Material.BEACON))
|
||||
if(bl.getBlockMaterial().equals(Material.GOLD_BLOCK)) bl.restore();
|
||||
if(bl.getBlockMaterial().equals(Material.BEACON))
|
||||
{
|
||||
bl.setMaterial(Material.STAINED_GLASS);
|
||||
bl.setData((byte)5);
|
||||
@ -157,6 +170,42 @@ public class SafePad
|
||||
}
|
||||
}
|
||||
|
||||
public void setCrackedProgress(int progress)
|
||||
{
|
||||
int i = 0;
|
||||
Iterator<SafePadBlock> iter = _blocks.iterator();
|
||||
ArrayList<Packet> packets = new ArrayList<Packet>();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
SafePadBlock spb = iter.next();
|
||||
if(!spb.getLocation().getBlock().getType().equals(Material.STAINED_GLASS)) continue;
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STAINED_GLASS, spb.getBlockData()), spb.getLocation(), 0.5f, 0.5f, 0.5f, 0.05f, 8, ViewDist.NORMAL, Host.GetPlayers(false).toArray(new Player[Host.GetPlayers(false).size()]));
|
||||
|
||||
i++;
|
||||
|
||||
Packet packet = new PacketPlayOutBlockBreakAnimation(i, spb.getLocation().getBlockX(), spb.getLocation().getBlockY(), spb.getLocation().getBlockZ(), progress);
|
||||
packets.add(packet);
|
||||
}
|
||||
for(Player p : Host.GetPlayers(false))
|
||||
{
|
||||
Packet[] pcks = new Packet[packets.size()];
|
||||
packets.toArray(pcks);
|
||||
UtilPlayer.sendPacket(p, pcks);
|
||||
}
|
||||
/*for(SafePadBlock spb : _blocks)
|
||||
{
|
||||
if(!spb.getLocation().getBlock().getType().equals(Material.STAINED_GLASS)) continue;
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STAINED_GLASS, spb.getBlockData()), spb.getLocation(), 0.5f, 0.5f, 0.5f, 0.05f, 8, ViewDist.NORMAL, Host.GetPlayers(false).toArray(new Player[Host.GetPlayers(false).size()]));
|
||||
Packet packet = new PacketPlayOutBlockBreakAnimation(1, spb.getLocation().getBlockX(), spb.getLocation().getBlockY(), spb.getLocation().getBlockZ(), progress);
|
||||
for(Player p : Host.GetPlayers(false))
|
||||
{
|
||||
UtilPlayer.sendPacket(p, packet);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
for(SafePadBlock bl : _blocks)
|
||||
|
@ -36,6 +36,9 @@ public class KitHyper extends Kit
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS, (byte)0, 1,
|
||||
C.cYellow + "Safe Pad Tracking Device™"));
|
||||
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte)0, 3,
|
||||
C.cYellow + C.Bold + "Right-click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Speed Boost"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user