Add particles on death effect, started working on chicken attack.

This commit is contained in:
Thanos paravantis 2016-01-01 17:39:16 +02:00
parent e89785963a
commit c0a397b9fb
3 changed files with 147 additions and 85 deletions

View File

@ -118,9 +118,7 @@ public class MineWare extends SoloGame implements IThrown
private ArrayList<Class<? extends Challenge>> _challenges = new ArrayList<Class<? extends Challenge>>();
private ArrayList<Class<? extends Challenge>> _challengesCopy = new ArrayList<Class<? extends Challenge>>();
// Location not used at the moment.
private Location _chickens = new Location(WorldData.World, 0, 0, 0);
private DeathEffect _deathEffect = new DeathEffect(this, _chickens);
private DeathEffect _deathEffect = new DeathEffect(this);
@SuppressWarnings("unchecked")
public MineWare(ArcadeManager manager)
@ -166,39 +164,39 @@ public class MineWare extends SoloGame implements IThrown
public void PopulateOrders()
{
// _challenges.add(ChallengeAnvilDance.class);
// _challenges.add(ChallengeArrowRampage.class);
// _challenges.add(ChallengeBlockLobbers.class);
// _challenges.add(ChallengeBouncingBlock.class);
// _challenges.add(ChallengeBuildRace.class);
// _challenges.add(ChallengeChestLoot.class);
// _challenges.add(ChallengeCloudFall.class);
// _challenges.add(ChallengeDogvsCat.class);
// _challenges.add(ChallengeDragonEgg.class);
// _challenges.add(ChallengeFallingBlocks.class);
// _challenges.add(ChallengeFastFood.class);
// _challenges.add(ChallengeFishingDay.class);
// _challenges.add(ChallengeInfestation.class);
// _challenges.add(ChallengeKangarooJump.class);
// _challenges.add(ChallengeKOTL.class);
// _challenges.add(ChallengeLavaRun.class);
// _challenges.add(ChallengeMilkACow.class);
// _challenges.add(ChallengeMineADiamond.class);
// _challenges.add(ChallengeMinecartDance.class);
_challenges.add(ChallengeAnvilDance.class);
_challenges.add(ChallengeArrowRampage.class);
_challenges.add(ChallengeBlockLobbers.class);
_challenges.add(ChallengeBouncingBlock.class);
_challenges.add(ChallengeBuildRace.class);
_challenges.add(ChallengeChestLoot.class);
_challenges.add(ChallengeCloudFall.class);
_challenges.add(ChallengeDogvsCat.class);
_challenges.add(ChallengeDragonEgg.class);
_challenges.add(ChallengeFallingBlocks.class);
_challenges.add(ChallengeFastFood.class);
_challenges.add(ChallengeFishingDay.class);
_challenges.add(ChallengeInfestation.class);
_challenges.add(ChallengeKangarooJump.class);
_challenges.add(ChallengeKOTL.class);
_challenges.add(ChallengeLavaRun.class);
_challenges.add(ChallengeMilkACow.class);
_challenges.add(ChallengeMineADiamond.class);
_challenges.add(ChallengeMinecartDance.class);
_challenges.add(ChallengeMiniOITQ.class);
// _challenges.add(ChallengeNavigateMaze.class);
// _challenges.add(ChallengePickASide.class);
// _challenges.add(ChallengePunchThePig.class);
// _challenges.add(ChallengeRedLightGreenLight.class);
// _challenges.add(ChallengeReverseTag.class);
// _challenges.add(ChallengeRushPush.class);
// _challenges.add(ChallengeShootChickens.class);
// _challenges.add(ChallengeSmashOff.class);
// _challenges.add(ChallengeStandOnColor.class);
// _challenges.add(ChallengeTntLauncher.class);
// _challenges.add(ChallengeTreasureDigger.class);
// _challenges.add(ChallengeVolleyPig.class);
// _challenges.add(ChallengeWaveCrush.class);
_challenges.add(ChallengeNavigateMaze.class);
_challenges.add(ChallengePickASide.class);
_challenges.add(ChallengePunchThePig.class);
_challenges.add(ChallengeRedLightGreenLight.class);
_challenges.add(ChallengeReverseTag.class);
_challenges.add(ChallengeRushPush.class);
_challenges.add(ChallengeShootChickens.class);
_challenges.add(ChallengeSmashOff.class);
_challenges.add(ChallengeStandOnColor.class);
_challenges.add(ChallengeTntLauncher.class);
_challenges.add(ChallengeTreasureDigger.class);
_challenges.add(ChallengeVolleyPig.class);
_challenges.add(ChallengeWaveCrush.class);
// ============== trashed ==============
// _challenges.add(ChallengeSimonSays.class);
@ -496,14 +494,9 @@ public class MineWare extends SoloGame implements IThrown
return;
Player player = event.getEntity();
Location death = player.getLocation().clone();
// _deathEffect.watch(player, death);
_challenge.getLost().add(player);
LoseLife(event.getEntity(), true);
_deathEffect.playDeath(player, death);
}
@EventHandler
@ -892,9 +885,11 @@ public class MineWare extends SoloGame implements IThrown
public void LoseLife(Player player, boolean isDeath)
{
Location death = player.getLocation().clone();
if (!isDeath)
{
Manager.addSpectator(player, true);
Manager.addSpectator(player, false);
}
if (_challenge == null || _challenge.IsCompleted(player))
@ -934,6 +929,8 @@ public class MineWare extends SoloGame implements IThrown
Manager.addSpectator(player, false);
}
}
_deathEffect.playDeath(player, death);
}
public void endCurrentChallenge() // TODO

View File

@ -0,0 +1,95 @@
package nautilus.game.arcade.game.games.mineware.effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.mineware.MineWare;
public class ChickenAttack
{
private MineWare _host;
private JavaPlugin _plugin;
private Location _center;
private Location _corner1;
private Location _corner2;
private Location[] _spawnpoints = new Location[4];
private int _chickenSpawnAmount = 12;
public ChickenAttack(MineWare host, Location center, Location corner1, Location corner2)
{
_host = host;
_plugin = host.getArcadeManager().getPlugin();
_center = center;
_corner1 = corner1;
_corner2 = corner2;
Block block = _center.getBlock();
_spawnpoints = new Location[] {
block.getRelative(BlockFace.NORTH).getLocation(),
block.getRelative(BlockFace.EAST).getLocation(),
block.getRelative(BlockFace.SOUTH).getLocation(),
block.getRelative(BlockFace.WEST).getLocation()
};
}
public void start(Player player)
{
player.teleport(_center);
player.setGameMode(GameMode.ADVENTURE);
UtilTextMiddle.display(null, C.cRed + C.Bold + "Chicken Attack!", 5, 40, 5);
player.playSound(player.getLocation(), Sound.FIZZ, 1.0F, 1.0F);
new BukkitRunnable()
{
@Override
public void run()
{
spawnChickens();
}
}.runTaskLater(_plugin, 40L);
}
private void spawnChickens()
{
int spawnAmount = _chickenSpawnAmount / _spawnpoints.length;
for (int i = 0; i < _spawnpoints.length; i++)
{
Location spawn = _spawnpoints[i];
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, spawn.clone().add(0, 0.2, 0), 0.2F, 0.2F, 0.2F, 0.0F, 20, ViewDist.NORMAL);
World world = spawn.getWorld();
for (int j = 0; j < spawnAmount; j++)
{
Chicken chicken = world.spawn(spawn, Chicken.class);
customizeChicken(chicken);
}
}
}
private void customizeChicken(Chicken chicken)
{
//
}
}

View File

@ -19,7 +19,6 @@ import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
@ -34,18 +33,16 @@ public class DeathEffect
private MineWare _host;
private JavaPlugin _plugin;
private DeathText _deathText = new DeathText();
private Location _chickens; // Not used at the moment.
private ArrayList<DeathEffectData> _data = new ArrayList<DeathEffectData>();
public DeathEffect(MineWare host, Location chickens)
public DeathEffect(MineWare host)
{
_host = host;
_plugin = host.getArcadeManager().getPlugin();
_chickens = chickens;
}
public void playDeath(Player player, Location death)
{
{
DeathEffectData data = new DeathEffectData(player, death);
_data.add(data);
@ -58,17 +55,8 @@ public class DeathEffect
if (!belowFirst.isEmpty() || !belowSecond.isEmpty())
startFoodSpawnTask(data);
// removeFinishedEffect(data);
System.out.println("Death effect triggered for " + player.getName() + ".");
}
public void watch(Player player, Location death)
{
Location modified = death.clone().add(0, 2.0, 0);
modified.setYaw(90);
player.teleport(modified);
}
private void startFoodSpawnTask(DeathEffectData data)
{
@ -108,8 +96,8 @@ public class DeathEffect
{
if (food.isValid())
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, food.getLocation(), 0.0F, 0.0F,
0.0F, 0.0F, 1, ViewDist.MAX);
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, food.getLocation(), 0.0F, 0.0F,
0.0F, 0.0F, 1, ViewDist.NORMAL);
food.remove();
}
}
@ -139,7 +127,7 @@ public class DeathEffect
data.setChickenHead(chickenHead);
playHeadRotation(data);
Hologram hologram = getRandomHologram(loc);
hologram.start();
data.setHologram(hologram);
@ -147,19 +135,16 @@ public class DeathEffect
private Hologram getRandomHologram(Location loc)
{
Hologram hologram = new Hologram(
_host.getArcadeManager().getHologramManager(),
loc.clone().add(0, 1.3, 0),
C.cAqua + C.Bold + _deathText.getRandom() + C.Reset
);
Hologram hologram = new Hologram(_host.getArcadeManager().getHologramManager(), loc.clone().add(0, 1.3, 0),
C.cAqua + C.Bold + _deathText.getRandom() + C.Reset);
return hologram;
}
private void playHeadRotation(DeathEffectData data)
{
ArmorStand chickenHead = data.getChickenHead();
new BukkitRunnable()
{
int i;
@ -186,7 +171,7 @@ public class DeathEffect
}
}.runTaskTimer(_plugin, 1L, 1L);
}
private void removeChickenHead(DeathEffectData data)
{
ArmorStand chickenHead = data.getChickenHead();
@ -202,6 +187,9 @@ public class DeathEffect
return;
}
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getLocation().clone().add(0, 1.0, 0), 0.2F,
0.2F, 0.2F, 0.0F, 10, ViewDist.NORMAL);
chickenHead.remove();
data.getHologram().stop();
}
@ -224,23 +212,6 @@ public class DeathEffect
}.runTaskLater(_plugin, 10L);
}
private void removeFinishedEffect(DeathEffectData data)
{
new BukkitRunnable()
{
@Override
public void run()
{
if (!_data.isEmpty() && data.hasFinished())
{
_data.remove(data);
System.out.println("Removing Data: " + data.getPlayer().getName());
cancel();
}
}
}.runTaskTimer(_plugin, 0L, 1L);
}
public void removeSpawnedEntities()
{
for (DeathEffectData data : _data)
@ -252,13 +223,12 @@ public class DeathEffect
food.remove();
}
}
data.getFoodItems().clear();
data.getChickenHead().remove();
data.getHologram().stop();
}
_data.clear();
System.out.println("Clearing Data.");
}
}