public override void OnCollision(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Player)) { GameManager.Instance.Ship.Lives--; Destroy(gameObject); } }
//private void Move() //{ // transform.position = new Vector2(transform.position.x, transform.position.y - Speed * Time.deltaTime); // Vector3 down = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, Camera.main.nearClipPlane)); // Vector3 up = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, Camera.main.nearClipPlane)); // if (transform.position.y > up.y || transform.position.y < down.y) // { // transform.position = new Vector2(transform.position.x, -transform.position.y); // } //} private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Player)) { GameManager.Instance.Ship.Lives--; Destroy(collision.gameObject); Destroy(gameObject); } }
public override void OnCollision(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Enemy)) { var enemy = collision.gameObject.GetComponent <Enemy>(); GameManager.Instance.Score += enemy.Score; Destroy(collision.gameObject); Destroy(gameObject); } }