Ultimates added to QuiverPayload

This commit is contained in:
Sam 2016-07-24 22:06:14 +01:00
parent ef797aa599
commit 576b92a5ce
2 changed files with 218 additions and 217 deletions

View File

@ -1,12 +1,9 @@
package nautilus.game.arcade.game.games.quiver; package nautilus.game.arcade.game.games.quiver;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -16,8 +13,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
@ -27,12 +22,10 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
@ -45,9 +38,7 @@ 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.KitNecromancer;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja; import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer; import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer;
import nautilus.game.arcade.game.games.quiver.ultimates.Ultimate;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.stats.SharpShooterStatTracker; import nautilus.game.arcade.stats.SharpShooterStatTracker;
import nautilus.game.arcade.stats.WinWithoutBowStatTracker; import nautilus.game.arcade.stats.WinWithoutBowStatTracker;
import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker;
@ -58,10 +49,8 @@ public class Quiver extends SoloGame
private HashMap<Player, Integer> _combo = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _combo = new HashMap<Player, Integer>();
private HashMap<Player, Integer> _bestCombo = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _bestCombo = new HashMap<Player, Integer>();
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>(); private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
private Objective _scoreObj; private Objective _scoreObj;
private boolean _coloredMessage;
public static final ItemStack SUPER_ARROW = new ItemBuilder(Material.ARROW).setTitle(C.cYellow + "Super Arrow").build(); public static final ItemStack SUPER_ARROW = new ItemBuilder(Material.ARROW).setTitle(C.cYellow + "Super Arrow").build();
@ -207,17 +196,6 @@ public class Quiver extends SoloGame
//Score //Score
AddKill(player); AddKill(player);
incrementUltimate(player, 5);
for (CombatComponent combatComponent : event.GetLog().GetAttackers())
{
if (combatComponent.IsPlayer())
{
Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
incrementUltimate(assitedPlayer, 2);
}
}
} }
@EventHandler @EventHandler
@ -402,123 +380,6 @@ public class Quiver extends SoloGame
} }
} }
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (!IsLive())
{
return;
}
_coloredMessage = !_coloredMessage;
for (Player player : GetPlayers(true))
{
Kit kit = GetKit(player);
if (kit == null || !IsAlive(player))
{
continue;
}
if (!_ultimatePercentage.containsKey(player.getUniqueId()))
{
_ultimatePercentage.put(player.getUniqueId(), 0D);
}
double percentage = _ultimatePercentage.get(player.getUniqueId());
if (percentage >= 100)
{
UtilTextBottom.display((_coloredMessage ? C.cWhiteB : C.cAquaB) + "ULTIMATE READY (PRESS Q)", player);
continue;
}
String percentageFormatted = new DecimalFormat("0.0").format(percentage);
UtilTextBottom.displayProgress("Ultimate", percentage / 100, percentageFormatted + "%", player);
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
{
continue;
}
incrementUltimate(player, ultimate.getChargeIncreasePerSecond());
}
}
}
}
@EventHandler
public void onPlayerDrop(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
Kit kit = GetKit(player);
if (kit == null)
{
return;
}
if (_ultimatePercentage.get(player.getUniqueId()) < 100)
{
return;
}
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
ultimate.activate(player);
_ultimatePercentage.put(player.getUniqueId(), 0D);
}
}
}
public void incrementUltimate(Player player, double percentage)
{
Kit kit = GetKit(player);
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
{
return;
}
}
}
_ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage);
}
@EventHandler //TODO DEBUG COMMANDS
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if (event.getMessage().startsWith("/maxpower"))
{
event.setCancelled(true);
incrementUltimate(player, 100);
}
}
@Override @Override
public List<Player> getWinners() public List<Player> getWinners()
{ {

View File

@ -1,23 +1,31 @@
package nautilus.game.arcade.game.games.quiver; package nautilus.game.arcade.game.games.quiver;
import java.text.DecimalFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Minecart; import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent; import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
@ -29,7 +37,9 @@ 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.KitNecromancer;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja; import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer; import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer;
import nautilus.game.arcade.game.games.quiver.ultimates.Ultimate;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
public class QuiverPayload extends TeamGame public class QuiverPayload extends TeamGame
{ {
@ -41,20 +51,17 @@ public class QuiverPayload extends TeamGame
private GameTeam _teamDirection; private GameTeam _teamDirection;
private Vector _lastDirection; private Vector _lastDirection;
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
private boolean _coloredMessage;
public QuiverPayload(ArcadeManager manager) public QuiverPayload(ArcadeManager manager)
{ {
super(manager, GameType.QuiverPayload, new Kit[] { super(manager, GameType.QuiverPayload, new Kit[] {
new KitBeserker(manager), new KitBeserker(manager), new KitNewNinja(manager), new KitBarrage(manager), new KitHeadHunter(manager), new KitPyromancer(manager), new KitNecromancer(manager),
new KitNewNinja(manager),
new KitBarrage(manager),
new KitHeadHunter(manager),
new KitPyromancer(manager),
new KitNecromancer(manager),
}, new String[] { }, new String[] { "Testing Description", });
"Testing Description",
});
this.DeathOut = false; this.DeathOut = false;
this.DamageTeamSelf = true; this.DamageTeamSelf = true;
@ -89,6 +96,7 @@ public class QuiverPayload extends TeamGame
Scoreboard.Draw(); Scoreboard.Draw();
} }
@EventHandler @EventHandler
public void onGameStateChange(GameStateChangeEvent event) public void onGameStateChange(GameStateChangeEvent event)
{ {
@ -106,71 +114,123 @@ public class QuiverPayload extends TeamGame
@EventHandler @EventHandler
public void onUpdate(UpdateEvent event) public void onUpdate(UpdateEvent event)
{ {
if (event.getType() != UpdateType.FAST || _minecart == null) if (event.getType() == UpdateType.SEC)
{ {
return;
}
Map<GameTeam, Integer> mostPlayers = new HashMap<>(); if (!IsLive())
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; return;
} }
else if (playerCount == mostPlayersCount)
_coloredMessage = !_coloredMessage;
for (Player player : GetPlayers(true))
{ {
_teamDirection = null; Kit kit = GetKit(player);
if (kit == null || !IsAlive(player))
{
continue;
}
if (!_ultimatePercentage.containsKey(player.getUniqueId()))
{
_ultimatePercentage.put(player.getUniqueId(), 0D);
}
double percentage = _ultimatePercentage.get(player.getUniqueId());
if (percentage >= 100)
{
UtilTextBottom.display((_coloredMessage ? C.cWhiteB : C.cAquaB) + "ULTIMATE READY (PRESS Q)", player);
continue;
}
String percentageFormatted = new DecimalFormat("0.0").format(percentage);
UtilTextBottom.displayProgress("Ultimate", percentage / 100, percentageFormatted + "%", player);
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
{
continue;
}
incrementUltimate(player, ultimate.getChargeIncreasePerSecond());
}
}
} }
} }
//TODO DO NOT HARDCODE if (event.getType() == UpdateType.FAST || _minecart != null)
if (_teamDirection == null)
{ {
return;
}
if (_teamDirection.equals(GetTeamList().get(0))) Map<GameTeam, Integer> mostPlayers = new HashMap<>();
{
if (_lastDirection == null) for (GameTeam gameTeam : GetTeamList())
{ {
_minecart.setVelocity(new Vector(-0.1, 0, 0)); 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));
}
_lastDirection = _minecart.getVelocity();
} }
else else
{ {
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1)); if (_lastDirection == null)
{
_minecart.setVelocity(new Vector(0.1, 0, 0));
}
else
{
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
}
_lastDirection = _minecart.getVelocity();
} }
_lastDirection = _minecart.getVelocity();
}
else
{
if (_lastDirection == null)
{
_minecart.setVelocity(new Vector(0.1, 0, 0));
}
else
{
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
}
_lastDirection = _minecart.getVelocity();
} }
} }
@ -202,4 +262,84 @@ public class QuiverPayload extends TeamGame
} }
} }
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
{
return;
}
incrementUltimate(player, 5);
for (CombatComponent combatComponent : event.GetLog().GetAttackers())
{
if (combatComponent.IsPlayer())
{
Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
incrementUltimate(assitedPlayer, 2);
}
}
}
@EventHandler
public void onPlayerDrop(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
Kit kit = GetKit(player);
if (kit == null)
{
return;
}
if (_ultimatePercentage.get(player.getUniqueId()) < 100)
{
return;
}
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
ultimate.activate(player);
_ultimatePercentage.put(player.getUniqueId(), 0D);
}
}
}
public void incrementUltimate(Player player, double percentage)
{
Kit kit = GetKit(player);
for (Perk perk : kit.GetPerks())
{
if (perk instanceof Ultimate)
{
Ultimate ultimate = (Ultimate) perk;
if (ultimate.getLastUltimate().containsKey(player.getUniqueId()))
{
return;
}
}
}
_ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage);
}
@EventHandler // TODO DEBUG COMMANDS
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if (event.getMessage().startsWith("/maxpower"))
{
event.setCancelled(true);
incrementUltimate(player, 100);
}
}
} }