private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Laser") { if (other.transform.parent != null) { Destroy(other.transform.parent.gameObject); } Destroy(other.gameObject); } else if (other.tag == "Player") { PlayerReposition player = other.GetComponent <PlayerReposition>(); if (player != null) { player.Damage(); } } _uiManager = GameObject.Find("Canvas").GetComponent <UIManager>(); if (_uiManager != null) { _uiManager.UpdateScore(); } Instantiate(_enemyExplosion, transform.position, Quaternion.identity); AudioSource.PlayClipAtPoint(_audioClip, Camera.main.transform.position, 1f); Destroy(this.gameObject); }
private void OnTriggerEnter2D(Collider2D other) { AudioSource.PlayClipAtPoint(_audioClip, Camera.main.transform.position, 1f); if (other.tag == "Player") { PlayerReposition player = other.GetComponent <PlayerReposition>(); if (player != null) { if (powerUpId == 0) { player.TripleShotOn(); } else if (powerUpId == 1) { player.SpeedBoostOn(); } else if (powerUpId == 2) { player.ShieldOn(); } } Destroy(this.gameObject); } }