Hello everyone so currently I am choosing random game objects to trigger think of them like different mini-games. I want them to each have a certain percentage to activate to keep stuff active such as 25,25,20,20,10 and I have written the code below and it does the job but not very well just want to see what others suggest! even if its something as simple as making random.range more random all answers are helpful!!
void SwapMachine()
{
if (lastMono != null && lastMono.doneTurn())
{
int index = Random.Range(0, 100);
Debug.Log(index);
if (index <= 25)
{
Right = 0;
Up = 0;
Down = 0;
Slot = 0;
TriggerMiniGame(gameEvents[0]);
Left++;
// if(Left > 3)
Reset(Left, 0);
}
else if (index > 25 && index <= 50)
{
Left = 0;
Up = 0;
Down = 0;
Slot = 0;
TriggerMiniGame(gameEvents[1]);
Right++;
// if(Right > 3)
Reset(Right, 1);
}
else if (index > 50 && index <= 70)
{
Left = 0;
Right = 0;
Down = 0;
Slot = 0;
TriggerMiniGame(gameEvents[2]);
Up++;
//if (Up > 3)
Reset(Up, 2);
}
else if (index > 70 && index <= 90)
{
Left = 0;
Right = 0;
Up = 0;
Slot = 0;
TriggerMiniGame(gameEvents[3]);
Down++;
//if (Down > 3)
Reset(Down, 3);
}
else if ( index > 90)
{
Left = 0;
Right = 0;
Up = 0;
Down = 0;
TriggerMiniGame(gameEvents[4]);
Slot++;
// if(Slot > 3)
Reset(Slot, 4);
}
else
{
Debug.Log("should not trigger, something is wrong");
}
}
}