I want to make simple guessing game. Players guessing letters from secretary. If player choice is in secretary then player get some point. Now I have 4 lists of letters sorted by points value:
//List of letters:
private string[] fivePointsLetters = { "q", "w", "ď", "x", "ň", "ú", "g", "ä", "ô", "ó" };
private List<string> fourPointsLetters = new List<string> { "f", "ů", "š", "č", "ž", "ý", "ch", "í", "ú", "é", "á", "ý" };
private List<string> threePointsLetters = new List<string> { "ř", "h", "é", "b", "c", "ě", "j", "z", "á", "k", "f", "v", "r", "y" };
private List<string> twoPointsLetters = new List<string> { "a", "e", "i", "o", "u", "d", "n", "t", "v", "s", "l", "k", "r", "p", "í", "m" };
GameManager pick random 4 twoPointLetters
, random 3 threePointLetters
, random 2 fourPointLetters
and only 1 fivePointLetters
. Now happens, that in this 10 picked letters there are not correct letters from secretary. So I devise that I should create new List with only correct letters(split answer string). And then GameManager should pick from this List not all values, but for example 30% correct letters. So player can pick one of 10 letters, but only 3 letters will be correct in secretary.
Problem is that I do not know how to pick for example only 30% values from List. Is there any solution or have you any idea how to do this please?
EDIT:
Picking random letters example:
for (int i = 0; i < button2b_value.Count; i++)
{
List<string> filteredStrings = twoPointsLetters.Except(usedLetters).Except(button2b_value).ToList();
if (filteredStrings.Count == 0)
{
Debug.LogWarning("No possible 2 point letters in list");
}
else
{
int index = UnityEngine.Random.Range(0, filteredStrings.Count);
view.RPC("Set2ButtonsValuesRPC", RpcTarget.All, filteredStrings[index], i);
}
}