Ejemplo n.º 1
0
    // Function called on-collision
    void OnCollisionEnter(Collision col)
    {
        int normal_Block_Points = 1;

        if (Game_Controller.Whiteness)
        {
            //destroys the object during a collision
            if (col.gameObject.tag == "Normal_Block" || col.gameObject.tag == "Out_of_Bounds" || col.gameObject.tag == "Bad_Block" || col.gameObject.tag == "Extra_Ball_Block")
            {
                Destroy(this.gameObject);
            }
            if (col.gameObject.tag == "Normal_Block")
            {
                //rewards points if it hits the correct color of block
                gameController.AddScore(normal_Block_Points);
            }
            if (col.gameObject.tag == "Out_of_Bounds" || col.gameObject.tag == "Bad_Block")
            {
                //lowers the ball count if it hits the wrong color of block
                gameController.DecrementBall();
            }
            if (col.gameObject.tag == "Bad_Block")
            {
                //reduces score if it hits wrong color of block
                gameController.SubtractScore(normal_Block_Points);
            }
        }

        if (!(Game_Controller.Whiteness))
        {
            //destroys the object during a collision
            if (col.gameObject.tag == "Normal_Block" || col.gameObject.tag == "Out_of_Bounds" || col.gameObject.tag == "Bad_Block" || col.gameObject.tag == "Extra_Ball_Block")
            {
                Destroy(this.gameObject);
            }
            if (col.gameObject.tag == "Bad_Block")
            {
                //rewards points if it hits the correct color of block
                gameController.AddScore(normal_Block_Points);
            }
            if (col.gameObject.tag == "Out_of_Bounds" || col.gameObject.tag == "Normal_Block")
            {
                //lowers the ball count if it hits the wrong color of block
                gameController.DecrementBall();
            }
            if (col.gameObject.tag == "Normal_Block")
            {
                //reduces score if it hits wrong color of block
                gameController.SubtractScore(normal_Block_Points);
            }
        }

        if (col.gameObject.tag == "Extra_Ball_Block")
        {
            //adds points and increases ball count if it hits a flashing block
            gameController.IncrementBall();
            gameController.AddScore(normal_Block_Points);
        }
    }