Example #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        audioS = GetComponent <AudioSource>();
    }
    protected void Start()
    {
        zRot = transform.localEulerAngles.z;

        base.Start();
        pPad = GameObject.Find("pressurePad").GetComponent <PadScript>();

        GetComponent <Rigidbody>().centerOfMass -= new Vector3(0, 1.5f, 0);
    }
    void Start()
    {
        padScript    = GameObject.Find("Pad").GetComponent <PadScript>();
        sphereScript = GameObject.Find("Sphere").GetComponent <SphereScript>();
        cannon.SetActive(false);


        GameObject brickArea = GameObject.Find("BrickArea");

        float brickWidth = (brickArea.renderer.bounds.size.x - brickWidthGap * (brickColumns - 1)) / brickColumns;

        print(brickWidth);

        float brickHeight = (brickArea.renderer.bounds.size.z - brickHeightGap * (brickRows - 1)) / brickRows;

        print(brickHeight);

        Vector3 bricksStart = new Vector3();

        bricksStart   = brickArea.transform.position - brickArea.renderer.bounds.size / 2;
        bricksStart.z = brickArea.transform.position.z + brickArea.renderer.bounds.size.z / 2;

        bricksStart.x += brickWidth / 2;
        bricksStart.z -= brickHeight / 2;

        print(bricksStart);


        int   index = 0;
        float x = bricksStart.x, z = bricksStart.z;

        for (int i = 0; i < brickRows; i++)
        {
            for (int j = 0; j < brickColumns; j++)
            {
                float yPos = 0;

                bricks[index]            = (Transform)Instantiate(prefabBrick, new Vector3(x, yPos, z), new Quaternion(0, 180, 0, 0));
                bricks[index].localScale = new Vector3(brickWidth, bricks[index].localScale.y, brickHeight);
                index++;

                x += brickWidth + brickWidthGap;
            }
            x = bricksStart.x;            // reset x bricks start to initial one

            z -= brickHeight + brickHeightGap;
        }


        _brickCounter = bricks.Length;
        _count        = 0;
    }
    void Start()
    {
        padScript = GameObject.Find("Pad").GetComponent<PadScript>();
        sphereScript = GameObject.Find("Sphere").GetComponent<SphereScript>();
        cannon.SetActive(false);

        int index = 0;
        int x = 0, z = 0;

        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 12; j++)
            {
                float yPos = 0;
                bricks[index] = (Transform)Instantiate(prefabBrick, new Vector3(x, yPos, z), new Quaternion(0,180,0,0));
                index++;
                x += 3;
            }
            x=0;
            z += -2;
        }
        _brickCounter = bricks.Length;
        _count = 0;
    }
    void Start()
    {
        padScript    = GameObject.Find("Pad").GetComponent <PadScript>();
        sphereScript = GameObject.Find("Sphere").GetComponent <SphereScript>();
        cannon.SetActive(false);

        int index = 0;
        int x = 0, z = 0;

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 12; j++)
            {
                float yPos = 0;
                bricks[index] = (Transform)Instantiate(prefabBrick, new Vector3(x, yPos, z), new Quaternion(0, 180, 0, 0));
                index++;
                x += 3;
            }
            x  = 0;
            z += -2;
        }
        _brickCounter = bricks.Length;
        _count        = 0;
    }
    void Start()
    {
        padScript = GameObject.Find("Pad").GetComponent<PadScript>();
        sphereScript = GameObject.Find("Sphere").GetComponent<SphereScript>();
        cannon.SetActive(false);

        GameObject brickArea = GameObject.Find("BrickArea");

        float brickWidth  = ( brickArea.renderer.bounds.size.x - brickWidthGap * (brickColumns - 1) ) / brickColumns;
        print (brickWidth);

        float brickHeight = ( brickArea.renderer.bounds.size.z - brickHeightGap * (brickRows - 1) ) / brickRows;
        print (brickHeight);

        Vector3 bricksStart = new Vector3();

        bricksStart = brickArea.transform.position -  brickArea.renderer.bounds.size/2;
        bricksStart.z = brickArea.transform.position.z +  brickArea.renderer.bounds.size.z/2;

        bricksStart.x += brickWidth / 2;
        bricksStart.z -= brickHeight / 2;

        print (bricksStart);

        int index = 0;
        float x = bricksStart.x, z = bricksStart.z;

        for(int i = 0; i < brickRows; i++)
        {
            for(int j = 0; j < brickColumns; j++)
            {
                float yPos = 0;

                bricks[index] = (Transform)Instantiate(prefabBrick, new Vector3(x, yPos, z), new Quaternion(0,180,0,0));
                bricks[index].localScale = new Vector3(brickWidth, bricks[index].localScale.y, brickHeight);
                index++;

                x +=  brickWidth + brickWidthGap;
            }
            x = bricksStart.x;// reset x bricks start to initial one

            z -= brickHeight + brickHeightGap;
        }

        _brickCounter = bricks.Length;
        _count = 0;
    }