Esempio n. 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag.Equals("HawkBall"))
     {
         HawkBall ball = collision.GetComponent <HawkBall>();
         ballManager.balls.Remove(ball);
         ball.Die();
     }
 }
Esempio n. 2
0
        internal void spawnBalls(Vector3 position, int count)
        {
            for (int i = 0; i < count; i++)
            {
                HawkBall spawnedBall = Instantiate(ballPrefab, position, Quaternion.identity) as HawkBall;

                Rigidbody2D spawnedBallRb = spawnedBall.GetComponent <Rigidbody2D>();
                spawnedBallRb.velocity = new Vector2(0, initialBallSpeed);

                balls.Add(spawnedBall);
            }
        }
Esempio n. 3
0
        private void InitBall()
        {
            // reset list here to avoid null errors
            balls = new List <HawkBall>();

            Vector3 paddlePosition = paddle.gameObject.transform.position;

            Vector3 startingPosition = new Vector3(paddlePosition.x, paddlePosition.y + .27f, 0);

            initialBall   = Instantiate(ballPrefab, startingPosition, Quaternion.identity);
            initialBallRB = initialBall.GetComponent <Rigidbody2D>();

            balls.Add(initialBall);
        }
Esempio n. 4
0
        void ApplyBallCollision(HawkBall ball)
        {
            hitPoints--;

            if (hitPoints <= 0)
            {
                brickManager.remainingBricks.Remove(this);

                onBrickDestruction?.Invoke(this);
                DestroyEffect();
                Destroy(gameObject);
            }
            else
            {
                sr.sprite = brickManager.sprites[hitPoints - 1];
            }
        }
Esempio n. 5
0
        // All lives lost. Clear everything then show death screen
        void onDeath(HawkBall ball)
        {
            if (ballManager.balls.Count <= 0)
            {
                lives--;
                collectableManager.resetCollectables();
                // reset balls
                // stop game
                // reload level
                ballManager.resetBalls();

                onLifeLost?.Invoke(lives);

                isgameStarted = false;
                brickManager.reloadBricks();

                if (lives < 1)
                {
                    gameOverScreen.SetActive(true);
                }
            }
        }
Esempio n. 6
0
        void OnCollisionEnter2D(Collision2D collision)
        {
            HawkBall ball = collision.gameObject.GetComponent <HawkBall>();

            ApplyBallCollision(ball);
        }