/**
     * Get the size of the list entity in the current level.
     */
    public int getSizeOfList()
    {
        List <ContainerEntityBehavior> visited = new List <ContainerEntityBehavior>();
        int sizeOfList = 1;
        ContainerEntityBehavior temp = startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>();

        temp.refreshChildList();
        while (temp != null)
        {
            if (temp.GetChildComponent <LinkBehavior>().connectableEntity == null)
            {
                break;
            }
            ContainerEntityBehavior next = temp.GetChildComponent <LinkBehavior>().connectableEntity.GetComponent <ContainerEntityBehavior>();
            next.refreshChildList();
            if (visited.Contains(next))
            {
                return(int.MaxValue); // inifite loop
            }
            visited.Add(temp);
            temp = next;
            sizeOfList++;
        }
        return(sizeOfList);
    }
    /**
     * Returns whether or not this level's win condition has been
     * satisfied based on the current world state.
     */
    bool isWinConditonSatisfied()
    {
        if (winCondition == WinCondition.None)
        {
            return(true); // always beat it when there is no condition.
        }

        switch (winCondition)
        {
        case WinCondition.SortListDuplicatesNotAllBlocks:
            // after ensuring the list is sorted, see if there are duplicates for this case.
            // assuming ascending order sort.
            List <int> unique   = new List <int>();
            var        listSize = getSizeOfList();
            //this dictionary of all the levels at the start isn't helpful
            foreach (PlatformBehavior pb in platformEntities)
            {
                if (!unique.Contains(pb.getValue()))
                {
                    unique.Add(pb.getValue());
                }
            }
            if (unique.Count != listSize)
            {
                return(false);    // there were duplicates.
            }
            return(true);

        case WinCondition.SortListAscending:
        case WinCondition.SortListDescending:
            int sizeOfList = 0;
            if (startingLink == null)
            {
                return(false);
            }

            // count how many platforms are in the level.
            int numberOfTotalPlatformsInLevel = 0;
            foreach (PlatformBehavior pb in platformEntities)
            {
                if (pb.isInLevel)
                {
                    numberOfTotalPlatformsInLevel++;
                }
            }
            if (startingLink.connectableEntity == null)
            {
                return(numberOfTotalPlatformsInLevel == 0);      // if there are no platforms in the level
            }
            startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>().refreshChildList();
            if (startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>() != null &&
                startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>() != null &&
                startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>().connectableEntity == null)
            {
                return(numberOfTotalPlatformsInLevel == 1);      // if there is only one platform in the level
            }
            sizeOfList = 1;
            ContainerEntityBehavior temp = startingLink.connectableEntity.GetComponent <ContainerEntityBehavior>();
            temp.refreshChildList();
            while (temp != null)
            {
                if (temp.GetChildComponent <LinkBehavior>().connectableEntity == null)
                {
                    break;
                }
                ContainerEntityBehavior next = temp.GetChildComponent <LinkBehavior>().connectableEntity.GetComponent <ContainerEntityBehavior>();
                next.refreshChildList();

                if (((winCondition == WinCondition.SortListAscending || winCondition == WinCondition.SortListDuplicatesNotAllBlocks) &&
                     next.GetChildComponent <ValueBehavior>().getValue() < temp.GetChildComponent <ValueBehavior>().getValue()) ||
                    (winCondition == WinCondition.SortListDescending &&
                     next.GetChildComponent <ValueBehavior>().getValue() > temp.GetChildComponent <ValueBehavior>().getValue()))
                {
                    return(false); // not sorted.
                }                  // otherwise just keep on iterating.
                temp = next;
                sizeOfList++;
            }
            return(sizeOfList == numberOfTotalPlatformsInLevel);      // the list is sorted if all platforms in the level are in the list.
        }
        return(false);
    }