Your next task is to grab the last item added to lootStack. In our example, the last element is determined programmatically in the Initialize method, but you can imagine how the elements could be randomized or added based on some parameter. Either way, update PrintLootReport with the following code:
public void PrintLootReport()
{
// 1
var currentItem = lootStack.Pop()
// 2
var nextItem = lootStack.Peek()
// 3
Debug.LogFormat("You got a {0}! You've got a good chance of finding
a {1} next!", currentItem, nextItem);
Debug.LogFormat("There are {0} random loot items waiting for you!",
lootStack.Count);
}
Here's what's going on:
- Calls Pop on lootStack, removes the next item on the stack, and stores it.
- Calls Peek on lootStack and stores the next item on the stack without removing it.
- Adds a new debug log to print out the item that was popped off and the next item on the stack...