private void RandomizeRoles() { //removes 3 random unnecessary roles from the pool List <EnumPlayerRole> nonNecessaryRoles = new List <EnumPlayerRole>(); for (int j = 0; j < mValidUserRoles.Count; j++) { if (mValidUserRoles[j] != EnumPlayerRole.ASSASSIN && mValidUserRoles[j] != EnumPlayerRole.WEALTHY_COUPLE && mValidUserRoles[j] != EnumPlayerRole.DISTANT_COUSIN) { nonNecessaryRoles.Add(mValidUserRoles [j]); } } List <int> randomNums = new List <int>(); for (int k = 0; k < mExtraPlayerAmount; k++) { int rand = -1; do { rand = Random.Range(0, nonNecessaryRoles.Count); } while(randomNums.Contains(rand)); randomNums.Add(rand); mRestaurantScript.addUnusedRole(nonNecessaryRoles [rand]); mValidUserRoles.Remove(nonNecessaryRoles[rand]); } //shuffles the roles around into a new list List <EnumPlayerRole> shuffedRoles = new List <EnumPlayerRole>(); int randomIndex; while (mValidUserRoles.Count > 0) { randomIndex = Random.Range(0, mValidUserRoles.Count); shuffedRoles.Add(mValidUserRoles[randomIndex]); mValidUserRoles.RemoveAt(randomIndex); } Debug.Log("ROLE COUNT: " + shuffedRoles.Count); for (int i = 0; i < shuffedRoles.Count; ++i) { Player player = new Player(mUsernames[i], shuffedRoles[i]); mRestaurantScript.addPlayer(player); Debug.Log("PLAYER COUNT: " + mRestaurantScript.getAlivePlayers().Count); Debug.Log(player.ToString()); } }