Ejemplo n.º 1
0
        private void AssignRoles()
        {
            var players = new List <Player>();

            players.AddRange(FindObjectsOfType <Player>());

            var rng = new System.Random();

            rng.Shuffle(players);

            // required roles will be filled first
            var roles = new List <Role>();

            roles.Add(Role.Impostor);

            rng.Shuffle(PLAYER_COLORS);

            var roleIndex = 0;

            for (var i = 0; i < players.Count; i++)
            {
                if (roleIndex < roles.Count)
                {
                    players[i].SetRoleFromServer(roles[roleIndex]);
                    roleIndex++;
                }
                else
                {
                    players[i].SetRoleFromServer(Role.CrewMate);
                }

                players[i].PlayerColor.Value = PLAYER_COLORS[i];
            }
        }
Ejemplo n.º 2
0
        public List <MatchData> GetMatches()
        {
            if (matches.Count <= 6)
            {
                return(matches);
            }

            Random random = new Random();

            MatchData[] returnMatches = matches.ToArray();
            random.Shuffle(returnMatches);

            return(returnMatches.ToList().GetRange(0, numberOfMatches));
        }
Ejemplo n.º 3
0
 public static void Shuffle <T>(ref T[] array)
 {
     SharedRandom.Shuffle(ref array);
 }