QuiverPayload added

Basic implementation added
This commit is contained in:
Sam 2016-07-24 21:27:31 +01:00
parent a8503d2fb8
commit 76da92f42e
3 changed files with 209 additions and 0 deletions

View File

@ -81,6 +81,8 @@ public enum GameDisplay
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61), Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
QuiverPayload("One in the Quiver Payload", Material.ARROW, (byte)0, GameCategory.ARCADE, 62),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999),
Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998); Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998);

View File

@ -59,6 +59,7 @@ import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare; import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeams; import nautilus.game.arcade.game.games.quiver.QuiverTeams;
import nautilus.game.arcade.game.games.quiver.modes.BunnyHop ; import nautilus.game.arcade.game.games.quiver.modes.BunnyHop ;
import nautilus.game.arcade.game.games.rings.ElytraRings; import nautilus.game.arcade.game.games.rings.ElytraRings;
@ -154,6 +155,7 @@ public enum GameType
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare), OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
Paintball(Paintball.class, GameDisplay.Paintball), Paintball(Paintball.class, GameDisplay.Paintball),
Quiver(Quiver.class, GameDisplay.Quiver), Quiver(Quiver.class, GameDisplay.Quiver),
QuiverPayload(QuiverPayload.class, GameDisplay.QuiverPayload),
QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams), QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams),
Runner(Runner.class, GameDisplay.Runner), Runner(Runner.class, GameDisplay.Runner),
SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy),

View File

@ -0,0 +1,205 @@
package nautilus.game.arcade.game.games.quiver;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.material.MaterialData;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.hologram.Hologram;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.quiver.kits.KitBarrage;
import nautilus.game.arcade.game.games.quiver.kits.KitBeserker;
import nautilus.game.arcade.game.games.quiver.kits.KitHeadHunter;
import nautilus.game.arcade.game.games.quiver.kits.KitNecromancer;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer;
import nautilus.game.arcade.kit.Kit;
public class QuiverPayload extends TeamGame
{
private static final double PAYLOAD_CAPTURE_RANGE = 3;
private Minecart _minecart;
private Hologram _hologram;
private GameTeam _teamDirection;
private Vector _lastDirection;
public QuiverPayload(ArcadeManager manager)
{
super(manager, GameType.QuiverPayload, new Kit[] {
new KitBeserker(manager),
new KitNewNinja(manager),
new KitBarrage(manager),
new KitHeadHunter(manager),
new KitPyromancer(manager),
new KitNecromancer(manager),
}, new String[] {
"Testing Description",
});
this.DeathOut = false;
this.DamageTeamSelf = true;
this.TeamArmorHotbar = true;
this.HungerSet = 20;
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
if (GetTeamList().isEmpty())
{
return;
}
Scoreboard.Reset();
if (_teamDirection != null)
{
Scoreboard.Write(_teamDirection.getDisplayName());
}
else
{
Scoreboard.Write("None");
}
Scoreboard.Draw();
}
@EventHandler
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Live)
{
Location location = WorldData.GetDataLocs("BLACK").get(0);
_minecart = location.getWorld().spawn(location, Minecart.class);
_hologram = new Hologram(Manager.getHologramManager(), location, "None");
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
_hologram.setFollowEntity(_minecart);
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || _minecart == null)
{
return;
}
Map<GameTeam, Integer> mostPlayers = new HashMap<>();
for (GameTeam gameTeam : GetTeamList())
{
mostPlayers.put(gameTeam, 0);
}
for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), PAYLOAD_CAPTURE_RANGE))
{
GameTeam gameTeam = GetTeam(player);
mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1);
}
int mostPlayersCount = 0;
for (GameTeam gameTeam : mostPlayers.keySet())
{
int playerCount = mostPlayers.get(gameTeam);
if (playerCount > mostPlayersCount)
{
_teamDirection = gameTeam;
}
else if (playerCount == mostPlayersCount)
{
_teamDirection = null;
}
}
//TODO DO NOT HARDCODE
if (_teamDirection == null)
{
return;
}
if (_teamDirection.equals(GetTeamList().get(0)))
{
if (_lastDirection == null)
{
_minecart.setVelocity(new Vector(-0.1, 0, 0));
}
else
{
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
}
}
else
{
if (_lastDirection == null)
{
_minecart.setVelocity(new Vector(0.1, 0, 0));
_lastDirection = _minecart.getVelocity();
}
else
{
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
_lastDirection = _minecart.getVelocity();
}
}
}
@EventHandler
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCollisionCancelled(true);
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
}