Esempio n. 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Wall"))
        {
            GameController.Obj.PlayerDeathNoise();
            pauser.ShowGameOverMenu("You died from touching a wall.");
            isPaused = true;
            SpawnEnemy.Obj.isPaused = true;
            GameController.Obj.SaveRigidbodies();
            pauser.gameIsPaused = true;
        }

        if (collision.gameObject.CompareTag("Enemy"))
        {
            //remove from game controller rb list
            collision.gameObject.GetComponent <Rigidbody2D> ().isKinematic = true;
            collision.gameObject.GetComponent <Collider2D> ().isTrigger    = true;
            GameController.Obj.RemoveRb(collision.gameObject.GetComponent <Rigidbody2D> ());
            //destroy enemy
            collision.gameObject.GetComponent <EnemyGrowAndMove> ().canMove = false;
            StartCoroutine(CallDeathAnim(collision.gameObject));
            audio.PlayOneShot(audio.clip, 1.0f);
            spawner.ReduceSpawnCooldown();
            spawner.enemiesKilled++;
        }
    }
 private void OnTriggerEnter2D(Collider2D other)
 {
     print(other.name);
     if (other.gameObject.CompareTag("Wall"))
     {
         pauser.ShowGameOverMenu("You died of claustrophobia.");
         SpawnEnemy.Obj.isPaused = true;
         pauser.gameIsPaused     = true;
         GameController.Obj.SaveRigidbodies();
     }
 }