public void JoinTeam(ArenaClient client, int index) { if (Phase == GamePhase.FadeOut) { return; } if (index < 0 || index >= teams.Count) { return; } var team = teams[index]; if (client.TDMTeam == team) { return; } if (client.TDMTeam != null) { client.KillCharacter(); client.TDMTeam.Players.Remove(client); client.GMClass = null; } client.TDMTeam = team; team.Players.Add(client); client.SetTeamID((TeamIdent)index); }
protected virtual NPCInst SpawnCharacter(ArenaClient client, WorldInst world, PosAng spawnPoint) { // only spawn if player has joined the game mode and chosen a class if (client == null || !client.GMJoined || client.GMClass == null) { return(null); } // get rid of old character if there is one client.KillCharacter(); NPCInst npc = CreateNPC(client.GMClass, (int)client.GMTeamID, client.CharInfo); npc.Spawn(world, spawnPoint.Position, spawnPoint.Angles); client.SetControl(npc); // start the warm up phase as soon as the first player joins if (Phase == GamePhase.None && players.Count(p => p.IsCharacter) == 1) { SetPhase(GamePhase.WarmUp); phaseTimer.SetInterval(Scenario.WarmUpDuration); phaseTimer.SetCallback(Fight); phaseTimer.Restart(); } return(npc); }
/// <summary> Does not change the TeamID! </summary> public virtual bool Leave(ArenaClient client) { if (!client.GMJoined) { return(false); } bool res = players.Remove(client); client.KillCharacter(); client.GMClass = null; if (Phase >= GamePhase.Fight && players.Count == 0) { FadeOut(); } return(res); }
public virtual void JoinAsSpectator(ArenaClient client) { client.KillCharacter(); if (!players.Contains(client)) { players.Add(client); } client.SetTeamID(TeamIdent.GMSpectator); if (SpawnWorld != null && Phase <= GamePhase.WarmUp) { client.SetToSpectator(SpawnWorld, Scenario.SpecPoint.Position, Scenario.SpecPoint.Angles); } else { client.SetToSpectator(World, Scenario.SpawnPos.Position, Scenario.SpawnPos.Angles); } }