Add more polish
This commit is contained in:
parent
abb983ac04
commit
ab35e96ca1
@ -0,0 +1,92 @@
|
||||
package nautilus.game.arcade.game.games.alieninvasion;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Alien
|
||||
{
|
||||
|
||||
private static final int RADIUS = 3;
|
||||
private static final ItemStack BLASTER = new ItemStack(Material.DIAMOND_BARDING);
|
||||
private static final ItemStack HELMET = new ItemStack(Material.GLASS);
|
||||
|
||||
private PhaserProjectile _phaser;
|
||||
private ArmorStand _stand;
|
||||
private Skeleton _skeleton;
|
||||
private Location _center;
|
||||
|
||||
private double _theta;
|
||||
|
||||
public Alien(ArcadeManager manager, Location location)
|
||||
{
|
||||
_phaser = new PhaserProjectile(manager);
|
||||
_stand = location.getWorld().spawn(location, ArmorStand.class);
|
||||
_skeleton = UtilVariant.spawnWitherSkeleton(location);
|
||||
_center = location;
|
||||
|
||||
_stand.setSmall(true);
|
||||
_stand.setVisible(false);
|
||||
_stand.setGravity(false);
|
||||
_stand.setPassenger(_skeleton);
|
||||
_stand.setRemoveWhenFarAway(false);
|
||||
|
||||
_skeleton.setMaxHealth(4);
|
||||
_skeleton.setRemoveWhenFarAway(false);
|
||||
|
||||
EntityEquipment equipment = _skeleton.getEquipment();
|
||||
equipment.setItemInHand(BLASTER);
|
||||
equipment.setHelmet(HELMET);
|
||||
|
||||
UtilEnt.silence(_stand, true);
|
||||
UtilEnt.vegetate(_skeleton);
|
||||
|
||||
_theta = Math.random();
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
double x = RADIUS * Math.cos(_theta);
|
||||
double z = RADIUS * Math.sin(_theta);
|
||||
|
||||
_center.add(x, 0, z);
|
||||
((CraftLivingEntity) _stand).getHandle().setPosition(_center.getX(), _center.getY(), _center.getZ());
|
||||
_center.subtract(x, 0, z);
|
||||
|
||||
_theta += Math.PI / 30;
|
||||
|
||||
if (Math.random() < 0.95)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(_skeleton.getLocation(), 15))
|
||||
{
|
||||
_phaser.shoot(_skeleton, UtilAlg.getTrajectory(_skeleton.getEyeLocation(), player.getEyeLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
boolean remove = !_stand.isValid() || !_skeleton.isValid();
|
||||
|
||||
if (remove)
|
||||
{
|
||||
_stand.remove();
|
||||
_skeleton.remove();
|
||||
}
|
||||
|
||||
return !remove;
|
||||
}
|
||||
}
|
@ -24,14 +24,13 @@ import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class AlienInvasion extends SoloGame
|
||||
{
|
||||
@ -64,12 +63,16 @@ public class AlienInvasion extends SoloGame
|
||||
|
||||
private final List<DragonScore> _score = new ArrayList<>(16);
|
||||
|
||||
private final Set<Alien> _aliens = new HashSet<>();
|
||||
|
||||
public AlienInvasion(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.AlienInvasion, new Kit[]{new KitPlayer(manager)}, DESCRIPTION);
|
||||
|
||||
WorldTimeSet = 18000;
|
||||
DamagePvP = false;
|
||||
DamageFall = false;
|
||||
HungerSet = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -167,8 +170,14 @@ public class AlienInvasion extends SoloGame
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
Manager.GetCondition().Factory().Invisible(GetName(), player, null, Integer.MAX_VALUE, 0, false, false, false);
|
||||
_score.add(new DragonScore(player, 0));
|
||||
}
|
||||
|
||||
for (Team team : Scoreboard.getHandle().getTeams())
|
||||
{
|
||||
team.setCanSeeFriendlyInvisibles(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -180,22 +189,42 @@ public class AlienInvasion extends SoloGame
|
||||
}
|
||||
|
||||
_lastBeam = System.currentTimeMillis();
|
||||
_nextBeam = 5000;
|
||||
_nextBeam = 10000;
|
||||
|
||||
ItemStack sword = new ItemStack(Material.STONE_SWORD);
|
||||
ItemStack helmet = new ItemStack(Material.GLASS);
|
||||
ItemStack glass = new ItemStack(Material.GLASS);
|
||||
|
||||
CreatureAllowOverride = true;
|
||||
for (Location location : WorldData.GetDataLocs("BLUE"))
|
||||
{
|
||||
Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location);
|
||||
|
||||
skeleton.getEquipment().setHelmet(helmet);
|
||||
skeleton.getEquipment().setItemInHand(sword);
|
||||
skeleton.setMaxHealth(4);
|
||||
skeleton.getEquipment().setHelmet(glass);
|
||||
}
|
||||
|
||||
for (Location location : WorldData.GetDataLocs("LIGHT_BLUE"))
|
||||
{
|
||||
_aliens.add(new Alien(Manager, location));
|
||||
}
|
||||
CreatureAllowOverride = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateAliens(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK || !IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Alien alien : _aliens)
|
||||
{
|
||||
alien.update();
|
||||
}
|
||||
|
||||
_aliens.removeIf(alien -> !alien.isValid());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateBeam(UpdateEvent event)
|
||||
{
|
||||
@ -212,7 +241,7 @@ public class AlienInvasion extends SoloGame
|
||||
}
|
||||
|
||||
_lastBeam = System.currentTimeMillis();
|
||||
_nextBeam -= 50;
|
||||
_nextBeam -= 100;
|
||||
_lastBeamId++;
|
||||
|
||||
Manager.runSyncTimer(new BukkitRunnable()
|
||||
@ -224,14 +253,25 @@ public class AlienInvasion extends SoloGame
|
||||
{
|
||||
for (Entry<Player, Double> entry : UtilPlayer.getInRadius(beam.getLastLocation(), 20).entrySet())
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(entry.getKey(), null, null, DamageCause.CUSTOM, 20 * entry.getValue(), false, true, false, "Alien Invasion", "Phaser");
|
||||
Manager.GetDamage().NewDamageEvent(entry.getKey(), null, null, DamageCause.CUSTOM, 20 * entry.getValue(), false, true, false, GetName(), "Photo Torpedo");
|
||||
}
|
||||
|
||||
int killIfBefore = 0;
|
||||
|
||||
for (int i = 0; i < _path.size(); i++)
|
||||
{
|
||||
if (UtilMath.offsetSquared(beam.getLastLocation(), _path.get(i++)) < 25)
|
||||
{
|
||||
killIfBefore = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (DragonScore score : _score)
|
||||
{
|
||||
if (score.Score <= _lastBeamId)
|
||||
if (score.Score <= killIfBefore)
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(score.Player, null, null, DamageCause.CUSTOM, 9999, false, true, false, GetName(), "Phaser");
|
||||
Manager.GetDamage().NewDamageEvent(score.Player, null, null, DamageCause.CUSTOM, 9999, false, true, false, GetName(), "Photo Torpedo");
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,4 +386,15 @@ public class AlienInvasion extends SoloGame
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location GetSpectatorLocation()
|
||||
{
|
||||
if (SpectatorSpawn == null)
|
||||
{
|
||||
return new Location(WorldData.World, 0, 158, 0);
|
||||
}
|
||||
|
||||
return SpectatorSpawn;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
package nautilus.game.arcade.game.games.alieninvasion;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.particles.effects.LineParticle;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class Beam extends LineParticle
|
||||
{
|
||||
|
||||
private static final int EXPLOSION_RADIUS = 15;
|
||||
private static final int EXPLOSION_RADIUS = 20;
|
||||
private static final int BEAM_BLOCK_TIME = 1500;
|
||||
|
||||
private final ArcadeManager _manager;
|
||||
@ -40,8 +41,13 @@ public class Beam extends LineParticle
|
||||
|
||||
if (hit)
|
||||
{
|
||||
_manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(last, EXPLOSION_RADIUS).keySet(), last, false);
|
||||
last.getWorld().playSound(last, Sound.EXPLODE, 2f, 0.75f);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, last, 4, 1, 4, 0.5F, 10, ViewDist.LONG);
|
||||
|
||||
Set<Block> blocks = UtilBlock.getInRadius(last, EXPLOSION_RADIUS).keySet();
|
||||
//blocks.removeIf(block -> block.getRelative(BlockFace.DOWN).getType() == Material.AIR);
|
||||
|
||||
blocks.forEach(block -> MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,72 @@
|
||||
package nautilus.game.arcade.game.games.alieninvasion;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PhaserProjectile implements IThrown
|
||||
{
|
||||
|
||||
private ArcadeManager _manager;
|
||||
|
||||
public PhaserProjectile(ArcadeManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void shoot(LivingEntity shooter, Vector direction)
|
||||
{
|
||||
Snowball snowball = shooter.launchProjectile(Snowball.class);
|
||||
|
||||
snowball.setVelocity(direction.multiply(2));
|
||||
|
||||
_manager.GetProjectile().AddThrow(snowball, shooter, this, -1, true, true, true, false, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.getThrower() instanceof Player)
|
||||
{
|
||||
if (target instanceof Player)
|
||||
{
|
||||
data.getThrown().remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) data.getThrower();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1, 0.7F);
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.CLOUD, data.getThrown().getLocation(), 0.5F, 0.5F, 0.5F, 0.05F, 5, ViewDist.NORMAL);
|
||||
_manager.GetDamage().NewDamageEvent(target, data.getThrower(), (Projectile) data.getThrown(), DamageCause.CUSTOM, 2, false, true, true, UtilEnt.getName(data.getThrower()), "Blaster");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Idle(ProjectileUser data)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Expire(ProjectileUser data)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package nautilus.game.arcade.game.games.alieninvasion.kit;
|
||||
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkLeap;
|
||||
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,29 +15,27 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class KitPlayer extends Kit
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION = {
|
||||
""
|
||||
};
|
||||
|
||||
private static final Perk[] PERKS = {
|
||||
new PerkLeap("Leap", 1, 1, 8000, 4),
|
||||
new PerkDoubleJump("Leap", 1, 1, true, 10000, true),
|
||||
new PerkBlaster()
|
||||
};
|
||||
|
||||
private static final ItemStack[] PLAYER_ITEMS = {
|
||||
new ItemStack(Material.IRON_AXE)
|
||||
new ItemBuilder(Material.DIAMOND_BARDING)
|
||||
.setTitle(C.cBlue + C.Scramble + "ABC " + C.cAqua + "Super Snow Blaster 3000" + C.cBlue + C.Scramble + " ABC")
|
||||
.build()
|
||||
};
|
||||
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_STONE);
|
||||
private static final ItemStack IN_HAND = new ItemStack(Material.DIAMOND_BARDING);
|
||||
|
||||
public KitPlayer(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Player", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
|
||||
super(manager, "Player", KitAvailability.Free, new String[0], PERKS, EntityType.SKELETON, IN_HAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
player.getInventory().addItem(PLAYER_ITEMS);
|
||||
player.setExp(0.999F);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
package nautilus.game.arcade.game.games.alieninvasion.kit;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.games.alieninvasion.PhaserProjectile;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class PerkBlaster extends Perk
|
||||
{
|
||||
|
||||
private PhaserProjectile _phaser;
|
||||
|
||||
public PerkBlaster()
|
||||
{
|
||||
super("Space Blaster", new String[0]);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void interact(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getItem() == null || event.getItem().getType() != Material.DIAMOND_BARDING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasPerk(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(player, GetName(), 200, false, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_phaser == null)
|
||||
{
|
||||
_phaser = new PhaserProjectile(Manager);
|
||||
}
|
||||
|
||||
_phaser.shoot(player, player.getLocation().getDirection());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user