private void OnTriggerExit2D(Collider2D collision) { AudioManager.Play(AudioClipName.LostBall); reduceBallsEvent.Invoke(); Destroy(collision.gameObject); Initialize(); }
void Update() { if (_timerDeath.Finished) { DestroyAndSpawn(); } if (gameObject.transform.position.y < ScreenUtils.ScreenBottom) { _ballsLeft.Invoke(); AudioManager.Play(AudioClipName.LossBall); DestroyAndSpawn(); } if (_timerMove.Finished) { _timerMove.Stop(); StartMoving(); } if (_timerSpeedupEffect.Finished) { _timerSpeedupEffect.Stop(); _rigidbody2D.velocity *= 1 / _speedIncrease; } }
/// <summary> /// Destroy the ball if it isn't on the screen and add new ball /// </summary> private void OnBecameInvisible() { if (transform.position.y < ScreenUtils.ScreenBottom) { AudioManager.Play(AudioName.BallLost); reduceBallsLeft.Invoke(); Destroy(gameObject); } }
void OnBecameInvisible() { ballLifetime.Stop(); reduceBallsLeftEvent.Invoke(); }