// Use this for initialization
    void Start()
    {
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                Vector3 pos = new Vector3(-4.05f + j * 0.9f, 2.25f + i * 0.5f, 0);;

                if (j == 0 || j == 9 || i == 4)
                {
                    Instantiate(bricks[0], pos, transform.rotation);
                }
                else
                {
                    Instantiate(bricks[i], pos, transform.rotation);
                }
            }
        }
        int oxy = 0;

        bricksInstantiate = GameObject.FindGameObjectsWithTag("Brick");

        while (oxy < numOxygen)
        {
            int            Rdn = UnityEngine.Random.Range(0, bricksInstantiate.Length);
            BrickScript_FA brickScriptInstant = bricksInstantiate[Rdn].GetComponent <BrickScript_FA>();
            if (!brickScriptInstant.haveOxygen)
            {
                brickScriptInstant.haveOxygen = true;
                oxy += 1;
            }
        }
    }
    // Use this for initialization
    void Start()//añade una fila aleatoria y añade 3 de oxigeno
    {
        int Rdn = UnityEngine.Random.Range(0, bricks.Length - 1);

        bricksInScene = GameObject.FindGameObjectsWithTag("Brick");
        foreach (GameObject block in bricksInScene)
        {
            block.transform.position = transform.position = new Vector3(block.transform.position.x, block.transform.position.y - 0.5f, 0.0f);
        }
        for (int i = 0; i < 10; i++)
        {
            Vector3 pos = new Vector3(-4.05f + i * 0.9f, 4.75f, 0);;
            bricksInstantiate[i] = Instantiate(bricks[Rdn], pos, transform.rotation);
        }

        int oxy = 0;

        while (oxy < numOxygen)
        {
            Rdn = UnityEngine.Random.Range(0, bricksInstantiate.Length);
            BrickScript_FA brickScriptInstant = bricksInstantiate[Rdn].GetComponent <BrickScript_FA>();
            if (!brickScriptInstant.haveOxygen)
            {
                brickScriptInstant.haveOxygen = true;
                oxy += 1;
            }
        }
        Destroy(gameObject);
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {//crea los primeros bloques y añade 13 oxigenos en algunos de ellos luego se destruye a si mismo
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                Vector3 pos = new Vector3(-4.05f + j * 0.9f, 2.75f + i * 0.5f, 0);;
                Instantiate(bricks[i], pos, transform.rotation);
            }
        }
        int oxy = 0;

        bricksInstantiate = GameObject.FindGameObjectsWithTag("Brick");

        while (oxy < numOxygen)
        {
            int            Rdn = UnityEngine.Random.Range(0, bricksInstantiate.Length);
            BrickScript_FA brickScriptInstant = bricksInstantiate[Rdn].GetComponent <BrickScript_FA>();
            if (!brickScriptInstant.haveOxygen)
            {
                brickScriptInstant.haveOxygen = true;
                oxy += 1;
            }
        }
        Destroy(gameObject);
    }