End the game when a wither is killed

This commit is contained in:
Sam 2017-05-15 19:55:39 +01:00
parent a450b23d22
commit 989c9a028c
4 changed files with 87 additions and 12 deletions

View File

@ -18,6 +18,7 @@ import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.moba.boss.BossManager; 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.fountain.MobaFountain;
import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager;
import nautilus.game.arcade.game.games.moba.kit.*; 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.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -73,12 +75,13 @@ public class Moba extends TeamGame
private final MobaShop _shop; private final MobaShop _shop;
private final GoldManager _goldManager; private final GoldManager _goldManager;
private final BossManager _boss;
public Moba(ArcadeManager manager) 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 HeroHattori(Manager),
new HeroDevon(Manager), new HeroDevon(Manager),
new HeroAnath(Manager), new HeroAnath(Manager),
@ -112,7 +115,8 @@ public class Moba extends TeamGame
MobaFountain fountain = new MobaFountain(this); MobaFountain fountain = new MobaFountain(this);
_listeners.add(fountain); _listeners.add(fountain);
Listener boss = new BossManager(this); BossManager boss = new BossManager(this);
_boss = boss;
_listeners.add(boss); _listeners.add(boss);
new CompassModule() new CompassModule()
@ -368,13 +372,72 @@ public class Moba extends TeamGame
for (MobaPlayer mobaPlayer : _playerData) for (MobaPlayer mobaPlayer : _playerData)
{ {
Player player = mobaPlayer.Player;
HeroKit kit = mobaPlayer.Kit; HeroKit kit = mobaPlayer.Kit;
Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; Perk perk = kit.GetPerks()[kit.GetPerks().length - 1];
// Put Ultimates on cooldown
if (perk instanceof HeroSkill) if (perk instanceof HeroSkill)
{ {
((HeroSkill) perk).useSkill(mobaPlayer.Player); ((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<GameTeam> 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);
}
}
} }
} }

View File

@ -8,11 +8,16 @@ public enum MobaLane
A, A,
B, B,
C; C,
D;
public String getName(GameTeam team) public String getName(GameTeam team)
{ {
if (this == B) if (this == D)
{
return "Jungle";
}
else if (this == B)
{ {
return "Middle"; return "Middle";
} }

View File

@ -1,22 +1,24 @@
package nautilus.game.arcade.game.games.moba; package nautilus.game.arcade.game.games.moba;
import mineplex.core.common.util.C;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
public enum MobaRole public enum MobaRole
{ {
ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA),
HUNTER("Hunter", Color.LIME, ChatColor.GREEN), HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN),
MAGE("Mage", Color.RED, ChatColor.RED), MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED),
WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD),
; ;
private String _name; private String _name;
private MobaLane _lane;
private Color _color; private Color _color;
private ChatColor _chatColor; private ChatColor _chatColor;
MobaRole(String name, Color color, ChatColor chatColor) MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor)
{ {
_name = name; _name = name;
_color = color; _color = color;
@ -28,6 +30,11 @@ public enum MobaRole
return _name; return _name;
} }
public MobaLane getLane()
{
return _lane;
}
public Color getColor() public Color getColor()
{ {
return _color; return _color;

View File

@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown
WitherSkull skull = shooter.launchProjectile(WitherSkull.class); WitherSkull skull = shooter.launchProjectile(WitherSkull.class);
skull.setYield(0); 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); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F);
} }