Ultimates added to QuiverPayload
This commit is contained in:
parent
ef797aa599
commit
576b92a5ce
@ -1,12 +1,9 @@
|
||||
package nautilus.game.arcade.game.games.quiver;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -16,8 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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.inventory.ItemStack;
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
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.damage.CustomDamageEvent;
|
||||
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.KitNewNinja;
|
||||
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.Perk;
|
||||
import nautilus.game.arcade.stats.SharpShooterStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutBowStatTracker;
|
||||
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> _bestCombo = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
||||
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
|
||||
|
||||
private Objective _scoreObj;
|
||||
private boolean _coloredMessage;
|
||||
|
||||
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
|
||||
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
|
||||
@ -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
|
||||
public List<Player> getWinners()
|
||||
{
|
||||
|
@ -1,23 +1,31 @@
|
||||
package nautilus.game.arcade.game.games.quiver;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
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.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
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.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
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.GameType;
|
||||
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.KitNewNinja;
|
||||
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.Perk;
|
||||
|
||||
public class QuiverPayload extends TeamGame
|
||||
{
|
||||
@ -41,20 +51,17 @@ public class QuiverPayload extends TeamGame
|
||||
private GameTeam _teamDirection;
|
||||
private Vector _lastDirection;
|
||||
|
||||
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
|
||||
|
||||
private boolean _coloredMessage;
|
||||
|
||||
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 KitBeserker(manager), new KitNewNinja(manager), new KitBarrage(manager), new KitHeadHunter(manager), new KitPyromancer(manager), new KitNecromancer(manager),
|
||||
|
||||
}, new String[] {
|
||||
"Testing Description",
|
||||
});
|
||||
}, new String[] { "Testing Description", });
|
||||
|
||||
this.DeathOut = false;
|
||||
this.DamageTeamSelf = true;
|
||||
@ -89,6 +96,7 @@ public class QuiverPayload extends TeamGame
|
||||
|
||||
Scoreboard.Draw();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
@ -106,11 +114,62 @@ public class QuiverPayload extends TeamGame
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST || _minecart == null)
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.FAST || _minecart != null)
|
||||
{
|
||||
|
||||
Map<GameTeam, Integer> mostPlayers = new HashMap<>();
|
||||
|
||||
for (GameTeam gameTeam : GetTeamList())
|
||||
@ -141,7 +200,7 @@ public class QuiverPayload extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
//TODO DO NOT HARDCODE
|
||||
// TODO DO NOT HARDCODE
|
||||
|
||||
if (_teamDirection == null)
|
||||
{
|
||||
@ -173,6 +232,7 @@ public class QuiverPayload extends TeamGame
|
||||
_lastDirection = _minecart.getVelocity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user