Update chicken attack

- Remove unnecessary clone() method.
- Change chat message when chicken attack is triggered.
- Rename customizeChicken to setupChicken method.
- Use Math.random() instead of UtilMath.random.nextDouble()*100.
- Add hologram that displays "Chicken Minion" above every chicken.
- Increase look at player radius to 4.
- Use generic List instead of ArrayList.
This commit is contained in:
Thanos Paravantis 2016-06-18 21:01:46 +03:00
parent 0368500ad7
commit fc50c90301
1 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.mineware.effect;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -20,11 +21,11 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.hologram.Hologram;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
@ -39,7 +40,7 @@ public class ChickenAttack
private Location _center;
private Location[] _spawnpoints = new Location[4];
private ArrayList<Chicken> _chickens = new ArrayList<>();
private List<Chicken> _chickens = new ArrayList<>();
private int _chickenSpawnAmount = 12;
public ChickenAttack(BawkBawkBattles host, Location center)
@ -51,10 +52,10 @@ public class ChickenAttack
Block block = _center.getBlock();
_spawnpoints = new Location[] {
block.getRelative(BlockFace.NORTH).getLocation().clone().add(0, 1.0, 0),
block.getRelative(BlockFace.EAST).getLocation().clone().add(0, 1.0, 0),
block.getRelative(BlockFace.SOUTH).getLocation().clone().add(0, 1.0, 0),
block.getRelative(BlockFace.WEST).getLocation().clone().add(0, 1.0, 0)
block.getRelative(BlockFace.NORTH).getLocation().add(0, 1, 0),
block.getRelative(BlockFace.EAST).getLocation().add(0, 1, 0),
block.getRelative(BlockFace.SOUTH).getLocation().add(0, 1, 0),
block.getRelative(BlockFace.WEST).getLocation().add(0, 1, 0)
};
spawnChickens();
@ -73,7 +74,7 @@ public class ChickenAttack
player.teleport(_center);
UtilTextMiddle.display(C.cRed + "Chicken Attack!", "You ran out of lives.", 5, 40, 5, player);
UtilPlayer.message(player, F.main("Game", "Bawk Bawk's followers are attacking you!"));
UtilPlayer.message(player, F.main("Game", "You failed to follow bawk bawk's instructions and you ran out of lives. His minions are now attacking you."));
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1));
@ -147,23 +148,29 @@ public class ChickenAttack
for (int j = 0; j < spawnAmount; j++)
{
Chicken chicken = world.spawn(spawn, Chicken.class);
customizeChicken(chicken);
setupChicken(chicken);
}
}
_host.CreatureAllow = false;
}
private void customizeChicken(Chicken chicken)
private void setupChicken(Chicken chicken)
{
_chickens.add(chicken);
UtilEnt.addLookAtPlayerAI(chicken, 2.0F);
if (UtilMath.random.nextDouble() * 100 < 10.0)
if (Math.random() < 0.1)
{
chicken.setBaby();
}
UtilEnt.addLookAtPlayerAI(chicken, 4);
Hologram holo = new Hologram(_host.Manager.getHologramManager(), chicken.getLocation().add(0, 1, 0), "Chicken Minion");
holo.setFollowEntity(chicken);
holo.start();
}
public boolean isGroupMember(Chicken chicken)
{
return _chickens.contains(chicken);
@ -179,7 +186,7 @@ public class ChickenAttack
_chickens.clear();
}
public ArrayList<Chicken> getChickens()
public List<Chicken> getChickens()
{
return _chickens;
}