From 989c9a028c015ed0d417f5eb692a3af224f2d64c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:55:39 +0100 Subject: [PATCH] End the game when a wither is killed --- .../game/arcade/game/games/moba/Moba.java | 71 +++++++++++++++++-- .../game/arcade/game/games/moba/MobaLane.java | 9 ++- .../game/arcade/game/games/moba/MobaRole.java | 17 +++-- .../boss/wither/WitherSkullProjectile.java | 2 +- 4 files changed, 87 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b3cf92d73..cdca741ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; @@ -38,6 +39,7 @@ import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -73,12 +75,13 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; + private final BossManager _boss; public Moba(ArcadeManager manager) { - super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + super(manager, GameType.MOBA, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); - _kits = new HeroKit[] { + _kits = new HeroKit[]{ new HeroHattori(Manager), new HeroDevon(Manager), new HeroAnath(Manager), @@ -112,7 +115,8 @@ public class Moba extends TeamGame MobaFountain fountain = new MobaFountain(this); _listeners.add(fountain); - Listener boss = new BossManager(this); + BossManager boss = new BossManager(this); + _boss = boss; _listeners.add(boss); new CompassModule() @@ -368,13 +372,72 @@ public class Moba extends TeamGame for (MobaPlayer mobaPlayer : _playerData) { + Player player = mobaPlayer.Player; HeroKit kit = mobaPlayer.Kit; Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + // Put Ultimates on cooldown if (perk instanceof HeroSkill) { ((HeroSkill) perk).useSkill(mobaPlayer.Player); } + + // Teleport players to their respective spawns + GameTeam team = GetTeam(player); + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + player.teleport(toTeleport); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + // Only one team online check + List teamsWithPlayers = new ArrayList<>(GetTeamList().size()); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).isEmpty()) + { + continue; + } + + teamsWithPlayers.add(team); + } + + if (teamsWithPlayers.size() == 1) + { + AnnounceEnd(teamsWithPlayers.get(0)); + SetState(GameState.End); + return; + } + + // Wither Dead check + for (GameTeam team : GetTeamList()) + { + WitherBoss boss = _boss.getWitherBoss(team); + LivingEntity entity = boss.getEntity(); + + // Dead Wither + if (entity == null || !entity.isValid() || entity.isDead()) + { + // Get the other team + for (GameTeam otherTeam : GetTeamList()) + { + if (team.equals(otherTeam)) + { + continue; + } + + AnnounceEnd(otherTeam); + SetState(GameState.End); + } + } } } @@ -646,7 +709,7 @@ public class Moba extends TeamGame { if (kit.getRole() == role && kit.isVisible()) { - kits.add(kit); + kits.add(kit); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java index 4681c4a42..a6426575e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -8,11 +8,16 @@ public enum MobaLane A, B, - C; + C, + D; public String getName(GameTeam team) { - if (this == B) + if (this == D) + { + return "Jungle"; + } + else if (this == B) { return "Middle"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index ee648883c..9f74a4a3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,22 +1,24 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", Color.LIME, ChatColor.GREEN), - MAGE("Mage", Color.RED, ChatColor.RED), - WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), + MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED), + WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; private String _name; + private MobaLane _lane; private Color _color; private ChatColor _chatColor; - MobaRole(String name, Color color, ChatColor chatColor) + MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; _color = color; @@ -28,6 +30,11 @@ public enum MobaRole return _name; } + public MobaLane getLane() + { + return _lane; + } + public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 48c2173ee..753c06575 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown WitherSkull skull = shooter.launchProjectile(WitherSkull.class); skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(3)); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); }