//remove a faction instance from the lobby public void RemoveFaction(LobbyFaction instance) { if (LobbyFactions.Count <= minLobbyFactions) //make sure there's more than the min allowed amount of lobby factions { UIMgr.ShowInfoMessage($"Can not have less than {minLobbyFactions} factions in lobby."); return; } LobbyFactions.Remove(instance); Destroy(instance.gameObject); UIMgr.ShowInfoMessage($"Faction slot removed."); }
//add a new faction to the lobby public void AddFaction() { if (LobbyFactions.Count >= GetCurrentMap().GetMaxFactions()) //make sure we haven't reached the max factions yet { UIMgr.ShowInfoMessage($"Maximum factions amount {GetCurrentMap().GetMaxFactions()} has been reached."); return; } LobbyFaction newFaction = Instantiate(lobbyFactionPrefab.gameObject).GetComponent <LobbyFaction>(); UIMgr.SetLobbyFactionParent(newFaction.transform); LobbyFactions.Add(newFaction); newFaction.Init(this, LobbyFactions.Count > 1 ? false : true); //make sure one faction only is player controlled UIMgr.ShowInfoMessage($"New faction slot added."); }