private void startGameButton_Click(object sender, EventArgs e)
{
int[] t_numbers;
MessageBox.Show("Game started...");
GetRandomLocate(out t_numbers);
string str = "";
foreach (var t in t_numbers)
str += t.ToString() + " ";
MessageBox.Show(str);
}
private void GetRandomLocate(out int[] t_numbers)
{
Random random = new Random();
bool flag = true;
t_numbers = new int[Logic.size];
for (int i = 0; i < Logic.size; i++)
t_numbers[i] = -1;
for(int i = 0;i<Logic.size;i++)
{
while(flag)
{
int rnd = random.Next(0, Logic.size + 1);
int ind = 0;
foreach (var t in t_numbers)
if (t == rnd)
ind = 1;
if (ind == 0)
{
t_numbers[i] = rnd;
flag = !flag;
}
else
flag = true;
}
}
}
var rnd = new Random();
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ];
for(var i; i < arr.Length; i++)
{
var newPosition = rnd.Next(arr.Length);
var temp = arr[newPosition];
arr[newPosition] = arr[i];
arr[i] = temp;
}
t_numbers.Any(x => x == number)
Random random = new Random();
t_numbers = new int[Logic.size];
List<int> numbers = new List<int>();
int randomIndex = -1;
for (int i = 0; i < Logic.size; i++)
numbers.Add(i);
int i = 0;
do
{
randomIndex = random.Next(0, numbers.Count);
t_numbers[i++] = numbers[randomIndex];
numbers.RemoveAt(randomIndex);
} while(numbers.Count > 0);