Example #1
0
    //OVERLOAD: Applies the command method to every element of the troopstack. ONLY for Stack<TroopClass>
    public static void IterateAll(Stack <TroopClass> troopStack, TroopCommand command)
    {
        Stack <TroopClass> temp = new Stack <TroopClass>();

        while (troopStack.Count > 0)
        {
            TroopClass troop = (TroopClass)troopStack.Pop();
            command(troop);
            temp.Push(troop);
        }
        while (temp.Count > 0)
        {
            troopStack.Push(temp.Pop());
        }
        return;
    }
 // Use this for initialization
 void Start()
 {
     cmdUI = FindObjectOfType <TroopCommand>();
 }