Changes to Sneaky Assassin power-ups, including addition of compass power-up.
This commit is contained in:
parent
9e047847c2
commit
16353c4bc9
@ -185,11 +185,11 @@ public class SneakyAssassins extends SoloGame
|
||||
{
|
||||
if (team.IsAlive(player))
|
||||
{
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), 0, true);
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGray + player.getName(), 0, true);
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGray + player.getName(), getPowerUpManager().getPowerUpCount(player), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ public class SneakyAssassins extends SoloGame
|
||||
{
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), 0, true);
|
||||
Scoreboard.WriteOrdered("Powerups", C.cGreen + player.getName(), getPowerUpManager().getPowerUpCount(player), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -43,12 +43,7 @@ public class ArmorPowerUp extends PowerUp
|
||||
boolean powerUp1 = powerUpArmor(player, random);
|
||||
boolean powerUp2 = powerUpArmor(player, random);
|
||||
|
||||
if (powerUp1 || powerUp2)
|
||||
UtilPlayer.message(player, F.main("Power-Up", "Your " + F.item("Armor") + " was upgraded."));
|
||||
else
|
||||
UtilPlayer.message(player, F.main("Power-Up", "Your " + F.item("Armor") + " is already fully upgraded!"));
|
||||
|
||||
return super.powerUpPlayer(player, random);
|
||||
return powerUp1 || powerUp2;
|
||||
}
|
||||
|
||||
public static boolean powerUpArmor(Player player, Random random)
|
||||
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CompassPowerUp extends PowerUp
|
||||
{
|
||||
protected CompassPowerUp()
|
||||
{
|
||||
super(PowerUpType.COMPASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean powerUpPlayer(Player player, Random random)
|
||||
{
|
||||
if (player.getInventory().contains(Material.COMPASS))
|
||||
return false;
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.COMPASS));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -15,17 +15,10 @@ public abstract class PowerUp
|
||||
_powerUpType = powerUpType;
|
||||
}
|
||||
|
||||
public boolean powerUpPlayer(Player player, Random random)
|
||||
{
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 2f, 0.8f);
|
||||
|
||||
player.getInventory().addItem(SneakyAssassinKit.SMOKE_BOMB.clone());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public PowerUpType getPowerUpType()
|
||||
{
|
||||
return _powerUpType;
|
||||
}
|
||||
|
||||
public abstract boolean powerUpPlayer(Player player, Random random);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class PowerUpManager implements Listener
|
||||
private final List<PowerUpItem> _powerUps = new ArrayList<>();
|
||||
private Location _lastLocation = null;
|
||||
private int _nextSpawnCountdown = -1;
|
||||
private final Map<UUID, PowerUpType> _lastPowerUpType = new HashMap<>();
|
||||
private final Map<UUID, Integer> _powerUpCount = new HashMap<>();
|
||||
|
||||
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
|
||||
{
|
||||
@ -148,30 +148,84 @@ public class PowerUpManager implements Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickUpPowerUp(final PlayerPickupItemEvent event)
|
||||
public void onPlayerPickUpPowerUp(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (getGame().IsPlaying(event.getPlayer()))
|
||||
if (!getGame().IsPlaying(event.getPlayer()))
|
||||
return;
|
||||
|
||||
PowerUpItem powerUp = getPowerUpByItem(event.getItem());
|
||||
if (powerUp == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
powerUp.remove();
|
||||
|
||||
int count = incrementPowerUpCount(event.getPlayer());
|
||||
|
||||
if (PowerUpType.SMOKE_BOMB.powerUpPlayer(event.getPlayer(), getRandom()))
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Power-Up", "+1 " + F.item("Smoke Bomb")));
|
||||
|
||||
if (count < 5)
|
||||
{
|
||||
final PowerUpItem powerUp = getPowerUpByItem(event.getItem());
|
||||
PowerUpType.WEAPON.powerUpPlayer(event.getPlayer(), getRandom());
|
||||
PowerUpType.ARMOR.powerUpPlayer(event.getPlayer(), getRandom());
|
||||
|
||||
if (powerUp != null)
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Power-Up", "Your " + F.item("Sword") + " and " + F.item("Armor") + " have been upgraded"));
|
||||
}
|
||||
else if (count == 5)
|
||||
{
|
||||
PowerUpType.COMPASS.powerUpPlayer(event.getPlayer(), getRandom());
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Power-Up", "You now have a " + F.item("Compass") + " for tracking players"));
|
||||
|
||||
getGame().Announce(F.name(event.getPlayer().getName()) + " has become a " + F.skill("Master Assassin"));
|
||||
}
|
||||
|
||||
schedulePowerUpSpawn(10);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdateCompass(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (getGame().GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
Player[] players = Bukkit.getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
if (!getGame().IsPlaying(player))
|
||||
continue;
|
||||
|
||||
if (player.getInventory().contains(Material.COMPASS))
|
||||
continue;
|
||||
|
||||
Player closest = null;
|
||||
double minDistanceSquared = Double.NaN;
|
||||
|
||||
for (Player other : players)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if (other == player)
|
||||
continue;
|
||||
|
||||
PowerUpType lastType = _lastPowerUpType.get(event.getPlayer().getUniqueId());
|
||||
if (lastType == null)
|
||||
lastType = UtilAlg.Random(Arrays.asList(PowerUpType.values()));
|
||||
if (!getGame().IsPlaying(other))
|
||||
continue;
|
||||
|
||||
int nextIndex = (Arrays.asList(PowerUpType.values()).indexOf(lastType) + 1) % PowerUpType.values().length;
|
||||
double distanceSquared = player.getLocation().distanceSquared(other.getLocation());
|
||||
|
||||
PowerUp pu = PowerUpType.values()[nextIndex].getPowerUp();
|
||||
pu.powerUpPlayer(event.getPlayer(), getRandom());
|
||||
powerUp.remove();
|
||||
|
||||
_lastPowerUpType.put(event.getPlayer().getUniqueId(), pu.getPowerUpType());
|
||||
|
||||
schedulePowerUpSpawn(10);
|
||||
if (closest == null || distanceSquared < minDistanceSquared)
|
||||
{
|
||||
closest = other;
|
||||
minDistanceSquared = distanceSquared;
|
||||
}
|
||||
}
|
||||
|
||||
if (closest != null)
|
||||
player.setCompassTarget(closest.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,4 +242,20 @@ public class PowerUpManager implements Listener
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPowerUpCount(Player player)
|
||||
{
|
||||
Integer count = _powerUpCount.get(player.getUniqueId());
|
||||
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
public int incrementPowerUpCount(Player player)
|
||||
{
|
||||
int count = getPowerUpCount(player) + 1;
|
||||
|
||||
_powerUpCount.put(player.getUniqueId(), count);
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public enum PowerUpType
|
||||
{
|
||||
WEAPON(Material.DIAMOND_SWORD, DyeColor.RED),
|
||||
ARMOR(Material.IRON_CHESTPLATE, DyeColor.BLUE);
|
||||
WEAPON(new WeaponPowerUp()),
|
||||
ARMOR(new ArmorPowerUp()),
|
||||
SMOKE_BOMB(new SmokeBombPowerUp()),
|
||||
COMPASS(new CompassPowerUp());
|
||||
|
||||
private final Material _itemType;
|
||||
private final DyeColor _color;
|
||||
private final PowerUp _powerUp;
|
||||
|
||||
PowerUpType(Material type, DyeColor color)
|
||||
PowerUpType(PowerUp powerUp)
|
||||
{
|
||||
_itemType = type;
|
||||
_color = color;
|
||||
_powerUp = powerUp;
|
||||
}
|
||||
|
||||
public Material getItemType()
|
||||
public boolean powerUpPlayer(Player player, Random random)
|
||||
{
|
||||
return _itemType;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return getDyeColor().getColor();
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public PowerUp getPowerUp()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case WEAPON:
|
||||
return new WeaponPowerUp();
|
||||
|
||||
case ARMOR:
|
||||
return new ArmorPowerUp();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return _powerUp.powerUpPlayer(player, random);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SmokeBombPowerUp extends PowerUp
|
||||
{
|
||||
protected SmokeBombPowerUp()
|
||||
{
|
||||
super(PowerUpType.SMOKE_BOMB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean powerUpPlayer(Player player, Random random)
|
||||
{
|
||||
return player.getInventory().addItem(SneakyAssassinKit.SMOKE_BOMB.clone()).isEmpty();
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.powerups;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
@ -37,15 +36,11 @@ public class WeaponPowerUp extends PowerUp
|
||||
{
|
||||
player.getInventory().setItem(swordSlot, new ItemStack(SWORD_PROGRESSION.get(newSwordType)));
|
||||
|
||||
UtilPlayer.message(player, F.main("Power-Up", "Your " + F.item("Sword") + " was upgraded."));
|
||||
|
||||
return super.powerUpPlayer(player, random);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, F.main("Power-Up", "Your " + F.item("Sword") + " is already fully upgraded!"));
|
||||
|
||||
return super.powerUpPlayer(player, random);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user