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.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,6 +75,7 @@ public class Moba extends TeamGame
private final MobaShop _shop;
private final GoldManager _goldManager;
private final BossManager _boss;
public Moba(ArcadeManager 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<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,
B,
C;
C,
D;
public String getName(GameTeam team)
{
if (this == B)
if (this == D)
{
return "Jungle";
}
else if (this == B)
{
return "Middle";
}

View File

@ -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;

View File

@ -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);
}