Started on Sneaky Assassins kits and power-ups

This commit is contained in:
CoderTim 2014-07-04 11:14:34 -04:00
parent 2fb2aadf66
commit 6365ec5351
7 changed files with 280 additions and 2 deletions

View File

@ -0,0 +1,61 @@
package nautilus.game.arcade.game.games.sneakyassassins;
import mineplex.core.common.util.*;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import org.bukkit.*;
import org.bukkit.block.*;
public class PowerUp
{
private final PowerUpManager powerUpManager;
private final Location location;
private Location effectLocation;
public PowerUp(PowerUpManager powerUpManager, Location location)
{
this.powerUpManager = powerUpManager;
this.location = location;
effectLocation = getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
effectLocation.setY(250);
}
public PowerUpManager getPowerUpManager()
{
return powerUpManager;
}
public Location getLocation()
{
return location;
}
public void activate()
{
Block block = getLocation().getBlock();
block.setType(Material.BEACON);
for(int x = -1; x <= 1; x++)
for(int z = -1; z <= 1; z++)
block.getRelative(x, -1, z).setType(Material.IRON_BLOCK);
}
public void onUpdate(UpdateEvent event)
{
if(event.getType() == UpdateType.FASTEST && effectLocation != null)
{
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(FireworkEffect.Type.BURST).trail(false).build();
UtilFirework.playFirework(effectLocation, effect);
effectLocation.setY(effectLocation.getY() - 2);
if(effectLocation.getY() - getLocation().getY() < 2)
{
effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(FireworkEffect.Type.BALL_LARGE).trail(true).build();
UtilFirework.playFirework(effectLocation, effect);
effectLocation = null;
}
}
}
}

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.sneakyassassins;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
import java.util.*;
public class PowerUpManager implements Listener
{
private final Game game;
private final Random random;
private final List<Location> spawnLocations;
private final Set<PowerUp> powerUps = new HashSet<>();
private Location lastLocation = null;
private int nextSpawnCountdown = -1;
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
{
this.game = game;
this.random = random;
this.spawnLocations = spawnLocations;
getPlugin().getServer().getPluginManager().registerEvents(this, getPlugin());
}
public Random getRandom()
{
return random;
}
public List<Location> getSpawnLocations()
{
return spawnLocations;
}
public Location nextLocation()
{
if(spawnLocations.size() == 1)
lastLocation = spawnLocations.get(0);
else if(spawnLocations.size() > 1)
{
int index = getRandom().nextInt(spawnLocations.size());
if(lastLocation != null)
{
while(spawnLocations.get(index).equals(lastLocation))
index = getRandom().nextInt(spawnLocations.size());
}
lastLocation = spawnLocations.get(index);
}
return lastLocation;
}
public Plugin getPlugin()
{
return getGame().Manager.GetPlugin();
}
public void spawnNextPowerUp()
{
PowerUp powerUp = new PowerUp(this, nextLocation());
getPowerUps().add(powerUp);
powerUp.activate();
}
public Set<PowerUp> getPowerUps()
{
return powerUps;
}
public void schedulePowerUpSpawn(int seconds)
{
nextSpawnCountdown = seconds;
}
public Game getGame()
{
return game;
}
@EventHandler
public void onGameStateChange(GameStateChangeEvent event)
{
if(event.GetGame() == getGame() && event.GetState() == Game.GameState.Live)
schedulePowerUpSpawn(5);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if(event.getType() == UpdateType.SEC && getGame().GetState() == Game.GameState.Live && nextSpawnCountdown >= 0)
{
if(nextSpawnCountdown == 0)
spawnNextPowerUp();
nextSpawnCountdown--;
}
for(PowerUp powerUp : getPowerUps())
powerUp.onUpdate(event);
}
}

View File

@ -0,0 +1,10 @@
package nautilus.game.arcade.game.games.sneakyassassins;
import org.bukkit.block.*;
import org.bukkit.entity.*;
public class PowerUpSpawn
{
private Block beaconBlock;
private Item item;
}

View File

@ -1,12 +1,19 @@
package nautilus.game.arcade.game.games.sneakyassassins;
import mineplex.core.common.util.*;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import nautilus.game.arcade.*;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
import nautilus.game.arcade.kit.*;
import org.bukkit.event.*;
public class SneakyAssassins extends SoloGame
{
private PowerUpManager powerUpManager;
public SneakyAssassins(ArcadeManager manager)
{
super(
@ -24,4 +31,15 @@ public class SneakyAssassins extends SoloGame
this.DamageTeamSelf = true;
}
@Override
public void ParseData()
{
powerUpManager = new PowerUpManager(this, UtilMath.random, WorldData.GetDataLocs("RED"));
}
public PowerUpManager getPowerUpManager()
{
return powerUpManager;
}
}

View File

@ -11,7 +11,7 @@ public class KitRevealer extends SneakyAssassinKit
{
public KitRevealer(ArcadeManager manager)
{
super(manager, "Revealer", KitAvailability.Free, new String[]{""}, new Perk[]{new PerkSmokebomb(Material.INK_SACK, 5, true)}, new ItemStack(Material.EMERALD));
super(manager, "Revealer", KitAvailability.Free, new String[]{""}, new Perk[]{new PerkSmokebomb(Material.INK_SACK, 5, true), new PerkRevealer()}, new ItemStack(Material.EMERALD));
}
@Override

View File

@ -0,0 +1,79 @@
package nautilus.game.arcade.kit.perks;
import mineplex.core.common.util.*;
import mineplex.core.itemstack.*;
import mineplex.core.projectile.*;
import nautilus.game.arcade.kit.*;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.block.*;
import org.bukkit.event.player.*;
public class PerkRevealer extends Perk implements IThrown
{
public PerkRevealer()
{
super("Revealer", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Emerald to " + C.cGreen + "throw Revealer",
});
}
@EventHandler
public void onPlayerThrowRevealer(PlayerInteractEvent event)
{
if(event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if(event.getPlayer().getItemInHand() == null)
return;
if(event.getPlayer().getItemInHand().getType() != Material.EMERALD)
return;
Player player = event.getPlayer();
if(!Kit.HasKit(player))
return;
event.setCancelled(true);
UtilInv.remove(player, Material.EMERALD, (byte) 0, 1);
UtilInv.Update(player);
Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.EMERALD));
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 1d);
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
if(target == null)
return;
if(target instanceof Player)
{
if(!Manager.GetGame().IsAlive((Player) target))
{
return;
}
}
data.GetThrown().remove();
}
@Override
public void Idle(ProjectileUser data)
{
}
@Override
public void Expire(ProjectileUser data)
{
}
}

View File

@ -99,7 +99,7 @@ public class PerkSmokebomb extends Perk
if (other.equals(player))
continue;
Manager.GetCondition().Factory().Blind(GetName(), player, player, getBlindnessDuration(), 0, false, false, true);
Manager.GetCondition().Factory().Blind(GetName(), other, player, getBlindnessDuration(), 0, false, false, true);
}
//Effects