stuff, things...things, stuff (Monster Maze)

This commit is contained in:
fooify 2015-09-05 09:30:51 -07:00
parent 9e3f87b71e
commit c648d7c186
2 changed files with 117 additions and 69 deletions

View File

@ -1,11 +1,9 @@
package nautilus.game.arcade.game.games.monstermaze;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
@ -19,6 +17,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.entity.Zombie;
@ -31,13 +30,9 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEnum;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
@ -56,19 +51,17 @@ public class Maze implements Listener
private Location _center;
private ArrayList<Block> _safeZoneGlass = new ArrayList<>(); // game start safe zone stuff
private ArrayList<Location> _playerContainmentUnitLocations = new ArrayList<>(); // probably could use a longer variable name...
private SafePad _safePad = null;
private SafePad _oldSafePad = null;
private int _zoneDecayTimer = 6;
private ArrayList<Player> _playersOnPad = new ArrayList<Player>();
private int _phaseTimer = -1;
private int _padDecayTimer = -1;
private ArrayList<ClientsideBlock> _clientsideBlocks = new ArrayList<>();
private HashMap<Entity, MazeMobWaypoint> _ents = new HashMap<Entity, MazeMobWaypoint>();
@ -104,6 +97,10 @@ public class Maze implements Listener
for (Location loc : _glassBounds)
{
_playerContainmentUnitLocations.add(loc.clone().subtract(0, 1, 0));
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.STAINED_GLASS);
loc.getBlock().getRelative(BlockFace.DOWN).setData((byte)3);
_playerContainmentUnitLocations.add(loc);
loc.getBlock().setType(Material.STAINED_GLASS);
loc.getBlock().setData((byte)3);
@ -152,6 +149,9 @@ public class Maze implements Listener
{
if (!Recharge.Instance.usable(player, "Monster Hit"))
continue;
if(_playersOnPad.contains(player))
continue;
//Hit Snowman
for (Entity ent : _ents.keySet())
@ -165,9 +165,9 @@ public class Maze implements Listener
UtilAction.velocity(player, UtilAlg.getTrajectory(ent, player), 1, false, 0, 0.75, 1.2, true);
//Damage Event
/*Host.Manager.GetDamage().NewDamageEvent(player, (LivingEntity)ent, null,
DamageCause.ENTITY_ATTACK, 6, false, false, false,
"Monster", "Monster Attack");*/
Host.Manager.GetDamage().NewDamageEvent(player, (LivingEntity)ent, null,
DamageCause.ENTITY_ATTACK, 4, false, false, false,
"Monster", "Monster Attack");
}
}
}
@ -210,7 +210,7 @@ public class Maze implements Listener
{
System.err.println("ENTITY HAS NO DIRECTION TO GO, removing entity");
entIterator.remove();
data.getKey().remove();
}
if(nextBlock.size() > 1 && data.getValue().Direction != CardinalDirection.NULL) // they can do a uturn if they're stuck
@ -339,7 +339,7 @@ public class Maze implements Listener
}
}
public void spawn(int numToSpawn)
private void spawn(int numToSpawn)
{
System.out.println("spawning " + numToSpawn + " entities at spawnpoints");
Location loc = UtilAlg.Random(_spawns);
@ -387,15 +387,6 @@ public class Maze implements Listener
ArrayList<Location> goals = new ArrayList<Location>(_goals);
if(_oldSafePad != null) goals.remove(_oldSafePad.getLocation());
if(_disabledWaypoints.size() > 0)
{
for(Block b : _disabledWaypoints)
{
_waypoints.add(b);
}
_disabledWaypoints.clear();
}
_safePad = new SafePad(Host, this, UtilAlg.Random(goals).clone().subtract(0,1,0)); // maybe don't need to clone()
_safePad.build();
UtilFirework.playFirework(_safePad.getLocation(), FireworkEffect.builder().withColor(Color.LIME).build());
@ -448,6 +439,15 @@ public class Maze implements Listener
{
_oldSafePad.destroy();
_oldSafePad = null;
if(_disabledWaypoints.size() > 0)
{
for(Block b : _disabledWaypoints)
{
_waypoints.add(b);
}
_disabledWaypoints.clear();
}
}
}
if(_padDecayTimer == 1)
@ -456,37 +456,6 @@ public class Maze implements Listener
}
}
/*public void decrementZoneTime()
{
if(_zoneDecayTimer == -1) return;
_zoneDecayTimer--;
if(_safeZoneGlass.size() > 0)
{
if(_zoneDecayTimer == 4)
{
setSafeZoneColor((byte)4);
}
else if(_zoneDecayTimer == 3)
{
setSafeZoneColor((byte)1);
}
else if(_zoneDecayTimer == 2)
{
setSafeZoneColor((byte)14);
}
else if(_zoneDecayTimer == 1)
{
destroySafeZone();
}
}
if(_padDecayTimer == 1)
{
_padDecayTimer = -1;
}
}*/
public void decrementPhaseTime()
{
if(_phaseTimer == -1) return;
@ -515,7 +484,7 @@ public class Maze implements Listener
if(_phaseTimer == 1)
{
UtilTextMiddle.display("", C.cRed + _phaseTimer + "...", 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
UtilTextMiddle.display("", C.cRed + C.Bold + _phaseTimer + "...", 5, 40, 5, Host.GetPlayers(true).toArray(new Player[Host.GetPlayers(true).size()]));
}
if(_phaseTimer == 0)
@ -543,7 +512,7 @@ public class Maze implements Listener
}
}
public void checkPlayersOnSafePad()
private void checkPlayersOnSafePad()
{
if(_safePad == null) return;
for(Player p : Host.GetPlayers(true))
@ -571,28 +540,92 @@ public class Maze implements Listener
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 setSafeZoneColor(byte data)
private void buildSafePadBarrier(Player p)
{
if(_safeZoneGlass.size() <= 0) return;
for(Block bl : _safeZoneGlass)
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)
{
bl.setData(data);
_clientsideBlocks.add(new ClientsideBlock(p, b.getLocation(), Material.STAINED_GLASS, (byte)3));
}
}*/
}
/*private void destroySafeZone()
private void removeSafePadBarrier() // for all players ;)
{
if(_safeZoneGlass.size() <= 0) return;
for(Block bl : _safeZoneGlass)
for(ClientsideBlock csb : _clientsideBlocks)
{
bl.setType(Material.AIR);
csb.disable();
}
_safeZoneGlass.clear();
}*/
_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()
{

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.monstermaze;
import org.bukkit.GameMode;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@ -9,8 +10,11 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Team;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
@ -66,7 +70,15 @@ 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);
for (Team team : GetScoreboard().GetScoreboard().getTeams())
team.setCanSeeFriendlyInvisibles(true);
}
else if(event.GetState() == GameState.Recruit)
{
@ -74,7 +86,7 @@ public class MonsterMaze extends SoloGame
_maze = new Maze(this, WorldData.GetDataLocs("GRAY"), WorldData.GetDataLocs("YELLOW"), WorldData.GetDataLocs("RED"), WorldData.GetDataLocs("ORANGE").get(0), WorldData.GetDataLocs("PINK"));
UtilServer.getServer().getPluginManager().registerEvents(_maze, getArcadeManager().getPlugin());
_maze.fillSpawn(150);
_maze.fillSpawn(175);
}
}
@ -84,7 +96,10 @@ public class MonsterMaze extends SoloGame
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));
}
}
@EventHandler