Ejemplo n.º 1
0
        public static void AddScore(Brick.BrickColor brickColor)
        {
            switch (brickColor)
            {
            case Brick.BrickColor.Yellow:
                _addScore(1);
                break;

            case Brick.BrickColor.Green:
                _addScore(3);
                break;

            case Brick.BrickColor.Orange:
                _addScore(5);
                break;

            case Brick.BrickColor.Red:
                _addScore(7);
                break;
            }
        }
Ejemplo n.º 2
0
        private void OnCollisionEnter2D(Collision2D collision)
        {
            Vector3 rot = transform.eulerAngles;

            /*
             * Vector2 inDirection = rb.velocity;
             *
             * while((Mathf.Abs(inDirection.x) + Mathf.Abs(inDirection.y)) < speed) {
             *  if(inDirection.x < 0) {
             *      inDirection.x -= .1f;
             *  } else {
             *      inDirection.x += .1f;
             *  }
             *  if(inDirection.y < 0) {
             *      inDirection.y -= .1f;
             *  } else {
             *      inDirection.y += .1f;
             *  }
             * }
             *
             * Vector2 inNormal = collision.contacts[0].normal.normalized;
             *
             * Debug.Log(inDirection);
             * Debug.Log(inNormal);
             * Debug.Log(Vector2.Reflect(inDirection, inNormal));
             *
             * rb.velocity = Vector2.Reflect(inDirection, inNormal);
             */
            //transform.eulerAngles = rot;

            if (collision.gameObject.name == "Wall-Bottom")
            {
                Death();
            }
            else
            {
                if (collision.gameObject.name == "Wall-Top")
                {
                    if (!_hitTopWall)
                    {
                        _hitTopWall = true;
                        _paddle.ShrinkPaddle();
                    }
                }
                if (collision.gameObject.GetComponent <Paddle>())
                {
                    AddBounce();
                }
                if (_brick = collision.gameObject.GetComponent <Brick>())
                {
                    AddBounce();

                    Brick.BrickColor _brickColor = _brick.Hit();

                    if (!GameStatus.HasHitOrangeRow)
                    {
                        if (_brickColor == Brick.BrickColor.Orange)
                        {
                            GameStatus.HasHitOrangeRow = true;
                        }
                    }
                    if (!GameStatus.HasHitRedRow)
                    {
                        if (_brickColor == Brick.BrickColor.Red)
                        {
                            GameStatus.HasHitRedRow = true;
                        }
                    }
                }
            }
        }