Exemplo n.º 1
0
    /// <summary>
    /// Converts stockType to an actual prefab model
    /// </summary>
    /// <param name="stockType">StockType you're looking for</param>
    /// <returns>Random prefab of said stockType</returns>
    public GameObject GetStockTypePrefab(StockTypes stockType)
    {
        for (int c = 0; c < stockPrefabs.Length; c++)
        {
            // Collect stock pack
            StockData stockPrefabPack = stockPrefabs[c];

            // Check if stockType matches what you're looking for
            if (stockPrefabPack.GetStockType() == stockType)
            {
                // Check if there's only one prefab model in the pack
                if (stockPrefabPack.GetPrefabs().Length == 1)
                {
                    // Return the one
                    return(stockPrefabPack.GetPrefabs()[0]);
                }
                else
                {
                    // Return a random prefab in the pack
                    return(EssentialFunctions.GetRandomFromArray(stockPrefabPack.GetPrefabs()));
                    //return stockPrefabPack.prefabs[Random.Range(0, stockPrefabPack.prefabs.Length)];
                }
            }
        }

        // Return nothing because it doesn't exist
        return(null);
    }