Start implementing chicken attack on player death.

This commit is contained in:
Thanos paravantis 2016-01-21 21:35:14 +02:00
parent 821ff58ab0
commit 44de231c7d
3 changed files with 131 additions and 23 deletions

View File

@ -1 +1 @@
{} [[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"]]

View File

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -55,8 +56,9 @@ import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeAnvilDance; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeAnvilDance;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeArrowRampage; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeArrowRampage;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockLobbers; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockLobbers;
@ -69,7 +71,6 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengeDragonEgg;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFallingBlocks; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFallingBlocks;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFastFood; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFastFood;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFishingDay; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFishingDay;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeWaterHorror;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeInfestation; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeInfestation;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKOTL; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKOTL;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKangarooJump; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKangarooJump;
@ -90,7 +91,9 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengeStandOnColor
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTntLauncher; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTntLauncher;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTreasureDigger; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTreasureDigger;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeVolleyPig; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeVolleyPig;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeWaterHorror;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeWaveCrush; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeWaveCrush;
import nautilus.game.arcade.game.games.mineware.effect.ChickenAttack;
import nautilus.game.arcade.game.games.mineware.effect.DeathEffect; import nautilus.game.arcade.game.games.mineware.effect.DeathEffect;
import nautilus.game.arcade.game.games.mineware.effect.DeathEffectData; import nautilus.game.arcade.game.games.mineware.effect.DeathEffectData;
import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent; import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent;
@ -105,8 +108,11 @@ import nautilus.game.arcade.game.games.mineware.stats.MinewareTagMasterTracker;
import nautilus.game.arcade.game.games.mineware.stats.MinewareVeteranTracker; import nautilus.game.arcade.game.games.mineware.stats.MinewareVeteranTracker;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
public class MineWare extends SoloGame implements IThrown public class MineWare extends TeamGame implements IThrown
{ {
private GameTeam _playersTeam;
private GameTeam _chickenTeam;
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
public boolean _currentCrumble = false; public boolean _currentCrumble = false;
@ -123,6 +129,7 @@ public class MineWare extends SoloGame implements IThrown
private ArrayList<Class<? extends Challenge>> _challengesCopy = new ArrayList<Class<? extends Challenge>>(); private ArrayList<Class<? extends Challenge>> _challengesCopy = new ArrayList<Class<? extends Challenge>>();
private DeathEffect _deathEffect = new DeathEffect(this); private DeathEffect _deathEffect = new DeathEffect(this);
private ChickenAttack _chickenAttack;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MineWare(ArcadeManager manager) public MineWare(ArcadeManager manager)
@ -165,6 +172,28 @@ public class MineWare extends SoloGame implements IThrown
new MinewareKangarooAtHeart(this) new MinewareKangarooAtHeart(this)
); );
} }
@EventHandler
public void onTeamCreation(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
for (GameTeam team : GetTeamList())
{
if (team.GetColor() == ChatColor.YELLOW)
{
team.SetName("Players");
_playersTeam = team;
}
else if (team.GetColor() == ChatColor.WHITE)
{
team.SetName("Chickens");
team.SetVisible(false);
_chickenTeam = team;
}
}
}
// Debug Only // Debug Only
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -372,6 +401,22 @@ public class MineWare extends SoloGame implements IThrown
return true; return true;
} }
@EventHandler
public void onInitializeChickens(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
// TODO: Retrieve center and corners from map data.
_chickenAttack = new ChickenAttack(
this,
new Location(WorldData.World, 500, 0, 500),
new Location(WorldData.World, 510, 0, 500),
new Location(WorldData.World, 500, 0, 510)
);
}
@EventHandler @EventHandler
public void onGameLive(GameStateChangeEvent event) public void onGameLive(GameStateChangeEvent event)
@ -380,7 +425,7 @@ public class MineWare extends SoloGame implements IThrown
{ {
return; return;
} }
_challengeTime = System.currentTimeMillis(); _challengeTime = System.currentTimeMillis();
} }
@ -1008,18 +1053,23 @@ public class MineWare extends SoloGame implements IThrown
} }
else else
{ {
if(playersAlive <= 3) if (playersAlive <= 3)
{ {
_places.add(player); _places.add(player);
} }
gameLostMessage(player); gameLostMessage(player);
Scoreboard.ResetScore(player.getName()); Scoreboard.ResetScore(player.getName());
SetPlayerState(player, PlayerState.OUT); // SetPlayerState(player, PlayerState.OUT);
if (isDeath) if (isDeath)
{ {
Manager.addSpectator(player, true); // Manager.addSpectator(player, true);
_chickenAttack.start(player);
}
else
{
SetPlayerState(player, PlayerState.OUT);
} }
} }
} }
@ -1109,7 +1159,6 @@ public class MineWare extends SoloGame implements IThrown
Scoreboard.WriteBlank(); Scoreboard.WriteBlank();
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
int currentLives = getLives(player); int currentLives = getLives(player);
String status; String status;
String currentlyOut = ""; String currentlyOut = "";
@ -1153,11 +1202,11 @@ public class MineWare extends SoloGame implements IThrown
Scoreboard.Draw(); Scoreboard.Draw();
} }
@Override // @Override
public int GetScoreboardScore(Player player) // public int GetScoreboardScore(Player player)
{ // {
return getLives(player); // return getLives(player);
} // }
@EventHandler @EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
@ -1174,6 +1223,16 @@ public class MineWare extends SoloGame implements IThrown
{ {
return _isChallengeStarted; return _isChallengeStarted;
} }
public GameTeam getPlayersTeam()
{
return _playersTeam;
}
public GameTeam getChickenTeam()
{
return _chickenTeam;
}
@Override @Override
public void Idle(ProjectileUser data) public void Idle(ProjectileUser data)

View File

@ -1,7 +1,10 @@
package nautilus.game.arcade.game.games.mineware.effect; package nautilus.game.arcade.game.games.mineware.effect;
import java.util.ArrayList;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -12,10 +15,10 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.disguise.disguises.DisguiseChicken;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.mineware.MineWare;
public class ChickenAttack public class ChickenAttack
@ -24,10 +27,13 @@ public class ChickenAttack
private JavaPlugin _plugin; private JavaPlugin _plugin;
private Location _center; private Location _center;
private World _world;
private Location _corner1; private Location _corner1;
private Location _corner2; private Location _corner2;
private Location[] _spawnpoints = new Location[4]; private Location[] _spawnpoints = new Location[4];
private ArrayList<Chicken> _chickens = new ArrayList<>();
private int _chickenSpawnAmount = 12; private int _chickenSpawnAmount = 12;
public ChickenAttack(MineWare host, Location center, Location corner1, Location corner2) public ChickenAttack(MineWare host, Location center, Location corner1, Location corner2)
@ -36,6 +42,7 @@ public class ChickenAttack
_plugin = host.getArcadeManager().getPlugin(); _plugin = host.getArcadeManager().getPlugin();
_center = center; _center = center;
_world = center.getWorld();
_corner1 = corner1; _corner1 = corner1;
_corner2 = corner2; _corner2 = corner2;
@ -47,6 +54,26 @@ public class ChickenAttack
block.getRelative(BlockFace.SOUTH).getLocation(), block.getRelative(BlockFace.SOUTH).getLocation(),
block.getRelative(BlockFace.WEST).getLocation() block.getRelative(BlockFace.WEST).getLocation()
}; };
createTestPlatform();
spawnChickens();
}
public void createTestPlatform()
{
ArrayList<Block> platform = UtilBlock.getInBoundingBox(_corner1, _corner2, false);
for (Block block : platform)
{
if (block.getLocation().equals(_center))
{
block.setType(Material.DIAMOND_BLOCK);
}
else
{
block.setType(Material.STONE);
}
}
} }
public void start(Player player) public void start(Player player)
@ -56,15 +83,30 @@ public class ChickenAttack
UtilTextMiddle.display(null, C.cRed + C.Bold + "Chicken Attack!", 5, 40, 5); UtilTextMiddle.display(null, C.cRed + C.Bold + "Chicken Attack!", 5, 40, 5);
player.playSound(player.getLocation(), Sound.FIZZ, 1.0F, 1.0F); player.playSound(player.getLocation(), Sound.FIZZ, 1.0F, 1.0F);
debugDeathTask(player);
}
private void debugDeathTask(Player player)
{
new BukkitRunnable() new BukkitRunnable()
{ {
@Override @Override
public void run() public void run()
{ {
spawnChickens(); if (_host.IsLive())
kill(player);
else
cancel();
} }
}.runTaskLater(_plugin, 40L); }.runTaskLater(_plugin, 100L);
}
private void kill(Player player)
{
_host.SetPlayerTeam(player, _host.getChickenTeam(), false);
player.teleport(_host.GetSpectatorLocation());
new DisguiseChicken(player);
} }
private void spawnChickens() private void spawnChickens()
@ -74,9 +116,6 @@ public class ChickenAttack
for (int i = 0; i < _spawnpoints.length; i++) for (int i = 0; i < _spawnpoints.length; i++)
{ {
Location spawn = _spawnpoints[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(); World world = spawn.getWorld();
for (int j = 0; j < spawnAmount; j++) for (int j = 0; j < spawnAmount; j++)
@ -89,6 +128,16 @@ public class ChickenAttack
private void customizeChicken(Chicken chicken) private void customizeChicken(Chicken chicken)
{ {
// _chickens.add(chicken);
}
public void reset()
{
for (Chicken chicken : _chickens)
{
chicken.remove();
}
_chickens.clear();
} }
} }