Ejemplo n.º 1
0
        /// <summary>
        /// Server method for color change
        /// </summary>
        public Color GetRandomNewColorFor(int slotId)
        {
            Color oldColor = UiSlots[slotId].Slot.GetColor();
            Color newColor = PartyNameGenerator.GetRandomColor(UsedColors);

            UsedColors.Remove(oldColor);
            UsedColors.Add(newColor);
            return(newColor);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        /// <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);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }