Staggered game teleports/start
This commit is contained in:
parent
27f554ab61
commit
f4cd2fcbb9
@ -72,11 +72,11 @@ public abstract class Game implements Listener
|
||||
private GameState _gameState = GameState.Loading;
|
||||
private long _gameStateTime = System.currentTimeMillis();
|
||||
|
||||
private boolean _prepareCountdown = false;
|
||||
|
||||
private int _countdown = -1;
|
||||
private boolean _countdownForce = false;
|
||||
|
||||
private int _playerCount = 0;
|
||||
|
||||
private String _customWinLine = "";
|
||||
|
||||
//Kits
|
||||
@ -274,16 +274,6 @@ public abstract class Game implements Listener
|
||||
_countdownForce = value;
|
||||
}
|
||||
|
||||
public int GetPlayerCountAtStart()
|
||||
{
|
||||
return _playerCount;
|
||||
}
|
||||
|
||||
public void SetPlayerCountAtStart(int count)
|
||||
{
|
||||
_playerCount = count;
|
||||
}
|
||||
|
||||
public NautHashMap<GameTeam, ArrayList<Player>> GetTeamPreferences()
|
||||
{
|
||||
return _teamPreference;
|
||||
@ -858,6 +848,13 @@ public abstract class Game implements Listener
|
||||
public void AnnounceGame()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
AnnounceGame(player);
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(9000, false);
|
||||
}
|
||||
|
||||
public void AnnounceGame(Player player)
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
|
||||
|
||||
@ -880,10 +877,6 @@ public abstract class Game implements Listener
|
||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||
}
|
||||
|
||||
if (AnnounceSilence)
|
||||
Manager.GetChat().Silence(9000, false);
|
||||
}
|
||||
|
||||
public void AnnounceEnd(GameTeam team)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
@ -1019,4 +1012,14 @@ public abstract class Game implements Listener
|
||||
|
||||
_helpIndex = (_helpIndex + 1)%_help.length;
|
||||
}
|
||||
|
||||
public void StartPrepareCountdown()
|
||||
{
|
||||
_prepareCountdown = true;
|
||||
}
|
||||
|
||||
public boolean CanStartPrepareCountdown()
|
||||
{
|
||||
return _prepareCountdown;
|
||||
}
|
||||
}
|
||||
|
@ -207,14 +207,19 @@ public class GameTeam
|
||||
return GetColor() + "§l" + GetName();
|
||||
}
|
||||
|
||||
public void SpawnTeleport()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
public void SpawnTeleport(Player player)
|
||||
{
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
player.teleport(GetSpawn());
|
||||
}
|
||||
|
||||
public void SpawnTeleport()
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
SpawnTeleport(player);
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<Kit> GetRestrictedKits()
|
||||
|
@ -101,6 +101,8 @@ public abstract class Kit implements Listener
|
||||
perk.Apply(player);
|
||||
|
||||
GiveItems(player);
|
||||
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
|
||||
public abstract void GiveItems(Player player);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -118,6 +119,8 @@ public class GameManager implements Listener
|
||||
}
|
||||
}
|
||||
else if (game.GetState() == GameState.Prepare)
|
||||
{
|
||||
if (game.CanStartPrepareCountdown())
|
||||
{
|
||||
if (UtilTime.elapsed(game.GetStateTime(), 9000))
|
||||
{
|
||||
@ -140,6 +143,7 @@ public class GameManager implements Listener
|
||||
player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.GetState() == GameState.Live)
|
||||
{
|
||||
if (game.GetType() == GameType.Bridge)
|
||||
@ -466,24 +470,28 @@ public class GameManager implements Listener
|
||||
@EventHandler
|
||||
public void PlayerPrepare(GameStateChangeEvent event)
|
||||
{
|
||||
Game game = event.GetGame();
|
||||
final Game game = event.GetGame();
|
||||
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
//Teleport
|
||||
for (GameTeam team : game.GetTeamList())
|
||||
team.SpawnTeleport();
|
||||
|
||||
//Save Initial Player Count
|
||||
game.SetPlayerCountAtStart(game.GetPlayers(true).size());
|
||||
|
||||
//Announce
|
||||
game.AnnounceGame();
|
||||
final ArrayList<Player> players = game.GetPlayers(true);
|
||||
|
||||
//Prepare Players
|
||||
for (Player player : game.GetPlayers(true))
|
||||
for (int i=0 ; i<players.size() ; i++)
|
||||
{
|
||||
final Player player = players.get(i);
|
||||
|
||||
final GameTeam team = game.GetTeam(player);
|
||||
|
||||
UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
//Teleport
|
||||
if (team != null)
|
||||
team.SpawnTeleport(player);
|
||||
|
||||
Manager.Clear(player);
|
||||
UtilInv.Clear(player);
|
||||
|
||||
@ -492,6 +500,18 @@ public class GameManager implements Listener
|
||||
if (game.GetKit(player) != null)
|
||||
game.GetKit(player).ApplyKit(player);
|
||||
}
|
||||
}, i);
|
||||
}
|
||||
|
||||
//Announce Game after every player is TP'd in
|
||||
UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
game.AnnounceGame();
|
||||
game.StartPrepareCountdown();
|
||||
}
|
||||
}, players.size());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user