Beispiel #1
0
    public void PlacePlayersInTeams(PlayerSpawnMananger psm)
    {
        List <int> players = new List <int>();

        players.AddRange(DataStorage.GetSetControllers.Keys);
        int teamAmount = GetAmountOfTeams(players.Count);
        int teamSize   = GetTeamSize(teamAmount, players.Count);

        Debug.Log("Started");
        List <int> playersToAdd = new List <int>();

        for (int i = 0; i < teamAmount; i++)
        {
            playersToAdd = new List <int>();
            for (int c = 0; c < teamSize; c++)
            {
                int randomPlayerID = players[Mathf.FloorToInt(Random.Range(0, players.Count))];
                playersToAdd.Add(randomPlayerID); //Add a random player to the team
                players.Remove(randomPlayerID);
            }
            GetSetTeams.Add(i, playersToAdd);
        }
        players.Clear();
        SetPlayersTeamColor(psm);
    }
Beispiel #2
0
    /// <summary>
    /// Add a team color to each player
    /// </summary>
    void SetPlayersTeamColor(PlayerSpawnMananger psm)
    {
        PlayerSpawnMananger spawnM = GetComponent <PlayerSpawnMananger>();
        Color teamColor;

        foreach (List <int> team in GetSetTeams.Values)
        {
            teamColor = DataStorage.GetSetPlayerColor[team[0]];
            foreach (int player in team)
            {
                spawnM.GetSetPlayers[player].GetComponent <ColorCustomizer>().SetTeamColor(teamColor);
                Debug.Log("Team count" + team.Count + "Player " + player);
            }
        }
    }