Ejemplo n.º 1
0
    private void GenerateOre(int x, int y, float value)
    {
        float increaseValue = 0;

        // if (GenerateRandomCavePrefab._map[x,y] == 0 && _gridBehaviour.CheckIsInArray(x,y))
        // if (GenerateRandomCavePrefab._map[x,y] == 0 || _gridBehaviour.CheckIsInArray(x,y))
        if (GenerateRandomCavePrefab._map[x, y] == 0)
        {
            for (int j = 0; j < values.Length; j++) // generates 1 ore
            {
                if (values[j] + increaseValue > value)
                {
                    currentOresPrefabs.Add(Instantiate(oresPrefabsFromResources[j],
                                                       _gridBehaviour.GetWorldPosition(x, y)
                                                       + new Vector3(.5f, .5f),
                                                       Quaternion.identity));
                    currentOresPrefabs[currentOresPrefabs.Count - 1].transform.SetParent(gameObject.transform);
                    break;
                }

                increaseValue += values[j];
            }
        }
    }