Ejemplo n.º 1
0
    public ItemData GetItem(Constants.ItemPool pool)
    {
        ItemData result = null;

        for (int i = 0; i < pools.Count; i++)
        {
            if (pools[i].itemPool == pool)
            {
                ItemPoolCategory target = pools[i];

                List <ItemData> unlockedItems = new List <ItemData>();

                int itemCount = target.items.Count;

                for (int j = 0; i < itemCount; j++)
                {
                    if (target.items[j].unlocked)
                    {
                        unlockedItems.Add(target.items[j]);
                    }
                }

                if (unlockedItems.Count < 1)
                {
                    return(null);
                }

                int randomIndex = Random.Range(0, unlockedItems.Count);

                return(unlockedItems[randomIndex]);
            }
        }

        return(result);
    }
Ejemplo n.º 2
0
    public ItemData GetItem(Constants.ItemPool pool)
    {
        ItemData result = null;

        //Debug.Log("Seeking " + pool);

        //Debug.Log(pools.Count + " is pool count");

        for (int i = 0; i < pools.Count; i++)
        {
            if (pools[i].itemPool == pool)
            {
                ItemPoolCategory target = pools[i];

                List <ItemData> unlockedItems = new List <ItemData>();

                int itemCount = target.items.Count;

                //Debug.Log(itemCount + " items in " + target.items + " in pool" + pool);

                if (itemCount > 0)
                {
                    for (int j = 0; j < itemCount; j++)
                    {
                        if (target.items[j].unlocked)
                        {
                            unlockedItems.Add(target.items[j]);
                        }
                    }

                    if (unlockedItems.Count < 1)
                    {
                        return(null);
                    }

                    int randomIndex = Random.Range(0, unlockedItems.Count);

                    return(unlockedItems[randomIndex]);
                }
                else
                {
                    Debug.LogError("There are 0 items in the item pool: " + pool.ToString());
                    return(null);
                }
            }
        }

        return(result);
    }