Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (_playerStats.currentNumberOfBalls > 0)
        {
            lastBall = false;
        }
        if (col.gameObject.tag != "Obstacle")
        {
            Points.hitsInARow = 0;
        }
        colorSplash.SetColorOfSplat(this.gameObject.GetComponent <SpriteRenderer>().color);

        Splatter splat = (Splatter)Instantiate(colorSplash, this.transform.position, Quaternion.identity);

        this.transform.localScale = this.transform.localScale / _ballDivider;
        if (this.transform.localScale.x < 0.1)
        {
            splat.transform.localScale = splat.transform.localScale / 2;
            if (_lastbounce)
            {
                this.gameObject.GetComponent <Rigidbody2D>().simulated = false;
                _playerStats.BallStopped();

                if (_playerStats.currentNumberOfBallsLeft <= 0)
                {
                    _playerStats.GameOver();
                }
            }
            _lastbounce = true;
        }
        else
        {
            splat.transform.localScale = splat.transform.localScale / _numberOfBounces;
        }
        _numberOfBounces += (_ballDivider / 2);
        _soundManager.Play();
    }