Since the lootStack variable in the previous sections could easily be a queue, we'll keep the following code out of our game scripts for efficiency. However, feel free to explore the differences, or similarities, of these classes in your own code.
To create a queue of string elements, use the following:
// Creates a new Queue of string values.
Queue<string> activePlayers = new Queue<string>();
To add elements to the queue, call the Enqueue method with the element you want to add:
// Adds string values to the end of the Queue.
activePlayers.Enqueue("Harrison");
activePlayers.Enqueue("Alex");
activePlayers.Enqueue("Haley");
To see the first element in the queue without removing it, use the Peek method:
// Returns the first element in the Queue without removing it.
var firstPlayer = activePlayers.Peek();
To return and remove the first element in the queue, use the Dequeue method:
// Returns and removes the first element...