示例#1
0
    private void disposicionGeneradoresSitiosOcultos()
    {
        float percentage = 50 - (dificultad - 1) * 10;

        if (percentage < 20)
        {
            percentage = 15;
        }

        int auxRand = Random.Range(0, 100);

        if (auxRand <= percentage)
        {
            //print("Salgo con " + auxRand);
            int auxRandElement = Random.Range(1, numeroElementos + 1);


            //print("Elementos " + auxRandElement);

            Vector3 position;


            float auxDiv = 0;
            switch (tamanyo)
            {
            case roomSize.small:
                auxDiv = (tHab / (numeroElementos));
                break;

            case roomSize.medium:
                auxDiv = (tHab / (numeroElementos));
                break;

            case roomSize.large:
                auxDiv = (tHab / (numeroElementos));
                break;
            }
            List <int> elements = new List <int>();

            while (elements.Count < auxRandElement)
            {
                int auxPos = Random.Range(1, numeroElementos + 1);

                if (!elements.Contains(auxPos))
                {
                    position   = limiteIzquierdo;
                    position.x = position.x + (auxPos * auxDiv);
                    position.z = -64.04f;

                    //print("Pongo el "+ (elements.Count+1) + " en la posicion "+auxPos);

                    GameObject objeto = Instantiate(generadorPrefab, position, Quaternion.identity);
                    objeto.transform.position = new Vector3(position.x - 40, position.y, position.z);
                    objeto.GetComponent <GeneradorObjetos>().nivel  = dificultad;
                    objeto.GetComponent <GeneradorObjetos>().estilo = estilo;

                    GameObject auxObj = objeto.GetComponent <GeneradorObjetos>().generateObjects(GeneradorObjetos.tipo.SitioOculto);
                    auxObj.transform.name = "Sitio Oculto " + (elements.Count);
                    objeto.transform.SetParent(this.transform);
                    auxObj.transform.SetParent(this.transform);
                    cantSitiosOcultos++;
                    elements.Add(auxPos);
                }
            }
        }
        edificio.setCantSitiosOcultos(cantSitiosOcultos, this.id);
    }