コード例 #1
0
 public override void OnCollision(Collider2D collision)
 {
     if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Player))
     {
         GameManager.Instance.Ship.Lives--;
         Destroy(gameObject);
     }
 }
コード例 #2
0
    //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);
        }
    }
コード例 #3
0
ファイル: ShipBullet.cs プロジェクト: hsultova/Galaga-Clone
 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);
     }
 }