protected void RoundActive() { RoundTimerSeconds = Math.RoundToInt(_timeToEndRound - Time.Now); var roundActive = Time.Now < _timeToEndRound; var humansLeft = Enumerable.Count(_players.Where(x => x.Team == (int)Team.Human)); if (roundActive && humansLeft > 0) { return; } if (!roundActive && humansLeft > 0) { MyHud.BroadcastMessage("Round has ended, humans win!"); } else if (humansLeft == 0) { MyHud.BroadcastMessage("Round has ended, barrels win!"); } BroadcastRoundOver(); _roundOverTime = Time.Now + RoundOverTime; SwitchPhase(Phase.RoundOver); }
public override void OnPlayerDied(Player player, Controllable controllable) { if (player == null) { return; } MyHud.BroadcastMessage($"{player.Name} has died"); if (Authority) { var position = controllable.Position; var eyeAngles = controllable.EyeAngles; var deathCamera = new DeathCamera(); deathCamera.Spawn(); player.Controlling = deathCamera; deathCamera.Position = position; deathCamera.Teleport(position); deathCamera.EyeAngles = eyeAngles; deathCamera.ClientEyeAngles = eyeAngles; if (Phase == Phase.RoundActive && player.Team == (int)Team.Human) { player.Team = (int)Team.Barrel; } if (Phase != Phase.RoundOver) { RespawnPlayerLater(player, deathCamera, 3.0); } } }
public override void OnPlayerDied(Player player, Controllable controllable) { base.OnPlayerDied(player); if (player == null) { return; } MyHud.BroadcastMessage($"{player.Name} has died."); if (Authority) { var position = controllable.Position; var eyeAngles = controllable.EyeAngles; var deathCamera = new DeathCamera(); deathCamera.Spawn(); player.Controlling = deathCamera; deathCamera.Position = position; deathCamera.Teleport(position); deathCamera.EyeAngles = eyeAngles; deathCamera.ClientEyeAngles = eyeAngles; // Handle team role shit } }
protected void TTTPrepareRound() { if (Time.Now < _timeToPrepRound) { return; } if (TTTNotEnoughPlayers()) { TTTChangePhase(Phase.Wait); return; } MyHud.BroadcastMessage($"A new round begins in {TTTPrepTimeSeconds} seconds. Prepare yourself!"); foreach (var player in _players) { if (player == null) { continue; } player.Team = (int)Team.Terror; RespawnPlayer(player); } BroadcastTTTPrepareRound(); _timeToStartRound = Time.Now + TTTPrepTimeSeconds; TTTChangePhase(Phase.Begin); }
public override void OnPlayerLeave(Player player) { base.OnPlayerLeave(player); _players.Remove(player); MyHud.BroadcastMessage($"{player.Name} left the game"); }
public override void OnPlayerJoined(Player player) { base.OnPlayerJoined(player); _players.Add(player); MyHud.BroadcastMessage($"{player.Name} has joined."); if (Authority) { player.Team = (Phase == Phase.Prep) ? (int)Team.Terror : (int)Team.Spectator; RespawnPlayer(player); } }
public override void OnPlayerJoined(Player player) { if (Phase == Phase.RoundActive) { player.Team = (int)Team.Barrel; } else { // Start player off as spectator player.Team = (int)Team.Spectator; } _players.Add(player); MyHud.BroadcastMessage($"{player.Name} joined the game"); if (Authority) { RespawnPlayer(player); } }
protected void RoundWarmup() { if (Time.Now < _timeToStartRound) { return; } var barrel = _players[Random.Int(0, _players.Count - 1)]; if (PlayerCount == 1) { barrel = null; } foreach (var player in _players) { if (player == null || player == barrel) { continue; } player.Team = (int)Team.Human; RespawnPlayer(player); } if (barrel != null) { barrel.Team = (int)Team.Barrel; RespawnPlayer(barrel); MyHud.BroadcastMessage($"{barrel.Name} is the barrel!"); } Round++; BroadcastRoundStarted(); _timeToEndRound = Time.Now + RoundTime; SwitchPhase(Phase.RoundActive); }
protected void RoundStarting() { if (Time.Now < _timeToRoundWarmup) { return; } MyHud.BroadcastMessage("Round warmup has started!"); foreach (var player in _players) { if (player == null) { continue; } player.Team = (int)Team.Human; RespawnPlayer(player); } _timeToStartRound = Time.Now + RoundWarmupTime; SwitchPhase(Phase.RoundWarmup); }