public void InitSingleplayerGame(string playerName) { Type = GameType.Singleplayer; foreach (UI_LobbySlot slot in UiSlots) { slot.SetInactive(); } UsedColors.Clear(); Color partyColor = PartyNameGenerator.GetPartyColor(playerName, UsedColors); UsedColors.Add(partyColor); FillNextFreeSlot(playerName, partyColor, LobbySlotType.Human); OrganizeSlots(); }
public void AddBot() { string botName = PartyNameGenerator.GetRandomPartyName(); Color botColor = PartyNameGenerator.GetPartyColor(botName, UsedColors); UsedColors.Add(botColor); FillNextFreeSlot(botName, botColor, LobbySlotType.Bot); if (Type == GameType.MultiplayerHost) { NetworkPlayer.Server.UpdateLobbySlotsServerRpc(); } else { OrganizeSlots(); } }
/// <summary> /// Gets called on the server when a player joins /// </summary> public void PlayerJoined(NetworkConnectionData connectionData) { Color playerColor = PartyNameGenerator.GetPartyColor(connectionData.Name, UsedColors); UsedColors.Add(playerColor); FillNextFreeSlot(connectionData.Name, playerColor, LobbySlotType.Human, connectionData.ClientId); OrganizeSlots(); // Send lobby data (slots and rules) to newly connected client if (Type == GameType.MultiplayerHost) { NetworkPlayer.Server.UpdateLobbySlotsServerRpc(); for (int i = 0; i < Rules.Count; i++) { if (Rules[i].value != 0) { NetworkPlayer.Server.LobbyRuleChangedServerRpc(i, Rules[i].value); } } } }
public void InitHostMultiplayerGame(string playerName) { Type = GameType.MultiplayerHost; foreach (UI_LobbySlot slot in UiSlots) { slot.SetInactive(); } UsedColors.Clear(); Color partyColor = PartyNameGenerator.GetPartyColor(playerName, UsedColors); UsedColors.Add(partyColor); FillNextFreeSlot(playerName, partyColor, LobbySlotType.Human, NetworkPlayer.LocalClientId); OrganizeSlots(); StartGameButtonText.text = "Start"; StartGameButton.enabled = true; foreach (Dropdown rule in Rules) { rule.enabled = true; } }