// 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);
        }
    }
Example #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }
        else
        {
            Destroy(other.gameObject);
            Destroy(gameObject);
            GameObject temp = Instantiate(explosion, transform.position, transform.rotation) as GameObject;
            Destroy(temp, 1);

            if (other.tag == "Player")
            {
                temp = Instantiate(playerexplosion, other.transform.position, other.transform.rotation) as GameObject;
                Destroy(temp, 1);
                controller.EndGame();
            }

            if (other.tag != "Player")
            {
                controller.AddScore(10);
            }
        }
    }
Example #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary")
     {
         Vector3    spawnPosition = transform.position + new Vector3(0.0f, 0.0f, 27.5f);
         Quaternion spawnRotation = Quaternion.identity;
         Instantiate(hazardOrigin, spawnPosition, spawnRotation);
         Destroy(gameObject);
     }
     if (other.tag == "Asteroid")
     {
         Instantiate(explosion, transform.position, transform.rotation);
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
     if (other.tag == "Bolt")
     {
         gameController.AddScore(scoreValue);
         Instantiate(explosion, transform.position, transform.rotation);
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
     if (other.tag == "Player")
     {
         Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
         gameController.GameOver();
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Boundary") || other.CompareTag("Enemy"))
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
            Destroy(other.gameObject);
            Destroy(gameObject);
        }

        if (other.tag == "Bolt")
        {
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
            Destroy(other.gameObject);
        }
        gameController.AddScore(scoreValue);
    }
Example #5
0
    //----------------------------------------------------------------------
    //		PaintPlanet()
    // Paints the planets dependants
    //
    // Param:
    //          None
    // Return:
    //
    //----------------------------------------------------------------------


    public void PaintPlanet(Color playerColor)
    {
        //debugColor = rend.material.color;
        if (rend.material.color == currentColor)
        {
            rend.material.color = playerColor;
            if (playerColor == Color.red)
            {
                isRed  = true;
                isBlue = false;
                controller.AddScore(1, Color.red);
            }
            if (playerColor == Color.blue)
            {
                isRed  = false;
                isBlue = true;

                controller.AddScore(1, Color.blue);
            }
        }

        if (rend.material.color == Color.blue)
        {
            rend.material.color = playerColor;
            if (playerColor == Color.red)
            {
                controller.AddScore(1, Color.red);
                controller.RemoveScore(1, Color.blue);

                isRed  = true;
                isBlue = false;
            }
        }

        if (rend.material.color == Color.red)
        {
            rend.material.color = playerColor;
            if (playerColor == Color.blue)
            {
                controller.AddScore(1, Color.blue);
                controller.RemoveScore(1, Color.red);
                isRed  = false;
                isBlue = true;
            }
        }
    }
Example #6
0
    // add particles and so on

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Player>() != null && !taken)
        {
            taken = true;
            gc.AddScore();
            Destroy(gameObject, 3);
        }
    }
Example #7
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "enemy")
        {
            Destroy(coll.gameObject);
            scoreValue = 10;
            gameControler.AddScore(scoreValue);
        }

        if (coll.gameObject.tag == "ship")
        {
            gameControler.GameOver();
            Destroy(coll.gameObject);
        }
    }
Example #8
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }
        Instantiate(explosion, transform.position, transform.rotation);
        if (other.tag == "Player")

        {
            Instantiate(explosion, transform.position, transform.rotation);
            gameController.Gameover();
        }
        Destroy(other.gameObject);
        Destroy(gameObject);
        gameController.AddScore(scoreValue);
    }
Example #9
0
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("hej");

        gc.AddScore();
    }