From 3260550368b7b2496902486fde53aa8bdd431d13 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 19:38:23 +0100 Subject: [PATCH] adding proper forcefield for minions and giants. --- .../arcade/game/games/typewars/TypeWars.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index f6cc42a73..178aaa162 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.hologram.Hologram; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -50,6 +51,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Giant; import org.bukkit.entity.Player; @@ -287,7 +289,7 @@ public class TypeWars extends TeamGame public void Players(UpdateEvent event) { - if(GetState() != GameState.Live) + if(GetState() != GameState.Live && GetState() != GameState.Prepare && GetState() != GameState.End) return; for(Player player : GetPlayers(true)) @@ -306,6 +308,42 @@ public class TypeWars extends TeamGame } } + @EventHandler + public void ForcefieldUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Minion minion : _activeMinions) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, minion.getEntity()) > 2) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(minion.getEntity(), other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + for (Giant giant : _giants.values()) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, giant) > 7) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(giant, other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + } + private Location _tutorialLocationRed, _tutorialLocationBlue; private void initSpawns()