void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        Instantiate(explosion, transform.position, transform.rotation);

        if (other.tag == "Player")
        {
            if (currentLives == 0)
            {
                ;
            }
            {
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                GameController.GameOver();
            }
            GameController.RemoveLife();
            currentLives -= 1;

            /*if( currentLives == 0 )
             * {
             *      //Destroy (other.gameObject);
             *      GameController.GameOver();
             * }*/
        }

        GameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
 void OnTriggerEnter(Collider other)
 {
     Destroy(other.gameObject);
     //	Debug.Log ("enter");
     gameController.AddScore(1);
     audio.Play();
 }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "enemy01")
        {
            Instantiate(explosion[0], collision.transform.position, collision.transform.rotation);
            Destroy(collision.gameObject);
            AudioSource shoot = GetComponent <AudioSource>();
            shoot.Play();

            gameController.AddScore(score);
        }

        if (collision.gameObject.tag == "enemy02")
        {
            Instantiate(explosion[1], collision.transform.position, collision.transform.rotation);
            Destroy(collision.gameObject);
            AudioSource shoot = GetComponent <AudioSource>();
            shoot.Play();
            gameController.AddScore(score);
        }
        if (collision.gameObject.tag == "enemy03")
        {
            Instantiate(explosion[2], collision.transform.position, collision.transform.rotation);
            Destroy(collision.gameObject);
            AudioSource shoot = GetComponent <AudioSource>();
            shoot.Play();
            gameController.AddScore(score);
        }
        if (collision.gameObject.tag == "enemy04")
        {
            Instantiate(explosion[3], collision.transform.position, collision.transform.rotation);
            Destroy(collision.gameObject);
            AudioSource shoot = GetComponent <AudioSource>();
            shoot.Play();
            gameController.AddScore(score);
        }
        if (collision.gameObject.tag == "enemy05")
        {
            Instantiate(explosion[4], collision.transform.position, collision.transform.rotation);
            Destroy(collision.gameObject);
            AudioSource shoot = GetComponent <AudioSource>();
            shoot.Play();
            gameController.AddScore(score);
        }
    }
Exemple #4
0
    void Update()
    {
        if (enemyDie == true)
        {
            destroyWaitCounter += Time.deltaTime;

            if (destroyWaitCounter >= 5.0f)
            {
                control.AddScore(15);
                Destroy(gameObject);
            }
        }
    }
Exemple #5
0
    /*
     * void checkIfStacked() {
     *
     *  if (scoreControll.hasBeenStacked == true)
     *  {
     *
     *      Destroy(gameObject, 3f);
     *      scoreControll.hasBeenStacked = false;
     *
     *  }
     *
     * }*/

    void OnTriggerEnter(Collider other)
    {
        if (!hasScored)
        {
            if (other.gameObject.tag == "Can" || other.gameObject.tag == "Coaster")
            {
                scoreControll.SpawnNewCan();

                scoreControll.AddScore(scoreValue);
                hasScored = true;

                gameObject.GetComponent <Rigidbody>().isKinematic = true;
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        Instantiate(explosion, transform.position, transform.rotation);

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.GameOver();
        }
        gameController.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Exemple #7
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary") //will ignore the boundary gameObject
        {
            return;
        }

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

        gameController.AddScore(scoreValue);
        Destroy(other.gameObject); //destroy any object shot by player
        Destroy(gameObject);       //destroy player if make contact with asteroid or enemy
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            return;
        }
        // In the case of a large asteroid being destroyed, it wil spawn smaller versions
        if (tag.Equals("Large Asteroid"))
        {
            StartCoroutine(cameraShake.Shake(.10f, .15f));
            // Spawn small asteroids
            Instantiate(smallAsteroid,
                        new Vector3(transform.position.x - .5f,
                                    transform.position.y - .5f, 0),
                        Quaternion.Euler(0, 0, 90));

            // Spawn small asteroids
            Instantiate(smallAsteroid,
                        new Vector3(transform.position.x + .5f,
                                    transform.position.y - .5f, 0),
                        Quaternion.Euler(0, 0, 270));

            gameController.AsteroidSplit();      // +2
        }
        if (tag.Equals("Small Asteroid"))
        {
            StartCoroutine(cameraShake.Shake(.5f, .10f));
            gameController.DecrementAsteroids();
        }


        if (other.CompareTag("Boundary"))
        {
            return; //will ignore the walls and not remove them.
        }

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


        if (other.tag == "Player")
        {
            Debug.Log("That hurts!");
            StartCoroutine(cameraShake.Shake(.15f, .5f));
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            gameController.SubLive(); //if player ship collides asteroid or enemy ship reduces 1 health -Ash
            Destroy(gameObject);
            return;
        }


        if (other.tag == "Bullet")
        {
            Debug.Log("Bullets work!!");
        }

        gameController.AddScore(pointValue);
        Object.Destroy(other.gameObject);
        Destroy(gameObject); //destroy whatever object this script is attached to.
    }