Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        Transform objectTransform = other.gameObject.transform;

        if (objectTransform.parent && objectTransform.parent.name == "Boundaries")
        {
            _direction = _direction * -1;
            bool isFlipped = _direction < 0;

            gameObject.GetComponent <SpriteRenderer>().flipX = isFlipped;
        }

        if (other.gameObject.name == "House")
        {
            AudioSource.PlayClipAtPoint(_snatchSound, Camera.main.transform.position);
            _gameController.DecreaseVegetableCount(_damageDealer.GetDamageValue());
            Destroy(gameObject);
        }
    }