Ejemplo n.º 1
0
    void SortDolls(List <CharacterCard> lockedList, List <NonPurchasableDollCard> lockedNonPurchasables, List <BaseCard> unlockedList)
    {
        int index = 0;

        if (mailListDollSetup.gameObject.activeSelf)
        {
            index++;
        }

        // Do coin doubler sorting
        string coinDoublerID = dollData.GetDollProductID(DollData.Doll.CoinDoubler);

        foreach (CharacterCard card in lockedList)
        {
            if (string.Equals(card.GetProductID(), coinDoublerID))
            {
                card.transform.SetSiblingIndex(index);
                index++;
            }
        }

        // Sort locked dolls to top
        for (int i = 0; i < lockedList.Count; i++)
        {
            if (string.Equals(lockedList[i].GetProductID(), coinDoublerID))
            {
                continue;
            }

            lockedList[i].transform.SetSiblingIndex(index);
            print($"set {lockedList[i].GetProductID()} to index: {index.ToString()}");
            index++;
        }

        // Position locked non-purchasable dolls after locked normal dolls
        for (int i = 0; i < lockedNonPurchasables.Count; i++)
        {
            lockedNonPurchasables[i].transform.SetSiblingIndex(index);
            print($"set {lockedList[i].GetProductID()} to index: {index.ToString()}");
            index++;
        }

        // Position unlocked dolls after the above
        for (int j = 0; j < unlockedList.Count; j++)
        {
            unlockedList[j].transform.SetSiblingIndex(index);
            print($"set {unlockedList[j].GetProductID()} to index: {index.ToString()}");
            index++;
        }
    }