To test this out, you're going to modify the existing item collection logic in Hero Born by using a stack to store possible loot that can be collected:
- Open GameBehavior.cs and add in a new stack variable named lootStack:
// 1
public Stack<string> lootStack = new Stack<string>();
- Update the Initialize method with the following code to add new items to the stack:
public void Initialize()
{
_state = "Manager initialized..";
_state.FanceyDebug();
Debug.Log(_state);
// 2
lootStack.Push("Sword of Doom");
lootStack.Push("HP+");
lootStack.Push("Golden Key");
lootStack.Push("Winged Boot");
lootStack.Push("Mythril Bracers");
}
- Add a new method to the bottom of the script to print out the stack information:
// 3
public void PrintLootReport()
{
Debug.LogFormat("There are {0} random loot items waiting for
you!", lootStack...