From 4148af92140b66add2aff7ce411a621b89c23dc3 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 12:16:50 +0100 Subject: [PATCH] Teleport players "correctly" to their lanes --- .../game/arcade/game/games/moba/Moba.java | 21 ++++++++++++++++--- .../game/arcade/game/games/moba/MobaRole.java | 10 ++++----- .../moba/structure/tower/TowerManager.java | 15 ++++++++++++- 3 files changed, 37 insertions(+), 9 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 c0ff0f7e8..e5a3632f5 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 @@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -74,6 +75,7 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; private final BossManager _boss; + private final TowerManager _tower; public Moba(ArcadeManager manager) { @@ -117,7 +119,8 @@ public class Moba extends TeamGame _boss = boss; _listeners.add(boss); - Listener tower = new TowerManager(this); + TowerManager tower = new TowerManager(this); + _tower = tower; _listeners.add(tower); new CompassModule() @@ -340,8 +343,20 @@ public class Moba extends TeamGame // Teleport players to their respective spawns GameTeam team = GetTeam(player); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + MobaLane lane = mobaPlayer.Role.getLane(); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); + + // Face the location toward the first tower of that lane + Tower tower = _tower.getFirsrtTower(lane); + if (tower != null) + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); + } + else + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation()))); + } + player.teleport(toTeleport); } } 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 9f74a4a3f..29e746afd 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,6 +1,5 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -13,14 +12,15 @@ public enum MobaRole WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; - private String _name; - private MobaLane _lane; - private Color _color; - private ChatColor _chatColor; + private final String _name; + private final MobaLane _lane; + private final Color _color; + private final ChatColor _chatColor; MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; + _lane = lane; _color = color; _chatColor = chatColor; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index d5bc87989..fc8ae6a06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -181,7 +181,7 @@ public class TowerManager implements Listener event.setCancelled(true); tower.damage(event.getDamage()); - if (Recharge.Instance.use(player, "Tower Sound", 1500, false, false)) + if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); } @@ -189,6 +189,19 @@ public class TowerManager implements Listener } } + public Tower getFirsrtTower(MobaLane lane) + { + for (Tower tower : _towers) + { + if (tower.isFirstTower() && tower.getLane() == lane) + { + return tower; + } + } + + return null; + } + // /* // Hacky work arounds!!!! // */