I have a list of methods, and I want to select a random method from the list and execute it while a boolean is set to true. I have:
List<Action> myActions = new List<Action>();
public void SetupRobot()
{
myActions.Add(mRobot.turnLeft);
myActions.Add(mRobot.turnRight);
myActions.Add(mRobot.move);
}
private void randomDemo()
{
while (mRandomActive)
{
foreach (Action aAction in myActions)
{
//randomly method and execute
Random rndm = new Random();
}
}
}
Unsure as to how I would select the method from the list with object rndm