Beispiel #1
0
        private void Bounce(IReadOnlyCollection <IBoundary> obstacles, IBall ball, out DegreeType degreeType)
        {
            degreeType = DegreeType.None;

            if (obstacles.Count == 1)
            {
                BounceBall(obstacles.First(), ball, out degreeType);
            }
            else if (obstacles.Count > 0)
            {
                if (IsPosXEqual(obstacles))
                {
                    BallBounceFromVertEdge(ball);
                }
                else if (IsPosYEqual(obstacles))
                {
                    BallBounceFromHorizEdge(ball);
                }
                else
                {
                    // bounce with 3 Bricks e.g. set in following way:
                    //    ==
                    //    o=
                    //
                    ball.BounceBack();
                }
            }
        }
Beispiel #2
0
        public void Bounce(IBall ball)
        {
            if (bricksHit == null || bricksHit.Count == 0)
            {
                BounceBall(ball);
                return;
            }

            bool onlyOne = (bricksHit.Count == 1);

            if (onlyOne)
            {
                BounceBall(ball);
                return;
            }

            if (bricksHit.Count > 0)
            {
                if (IsPosXEqual())
                {
                    BallBounceFromVertEdge(ball);
                }
                else if (IsPosYEqual())
                {
                    BallBounceFromHorizEdge(ball);
                }
                else
                {
                    ball.BounceBack();
                }
            }
        }
Beispiel #3
0
        public void Bounce(IReadOnlyCollection <IBorder> borders, IBall ball)
        {
            var obstacles = borders.Cast <IBoundary>().ToList();

            if (obstacles.Count > 1) // the case when collision in borders corner
            {
                ball.BounceBack();
                return;
            }

            Bounce(obstacles, ball, out _);
        }
Beispiel #4
0
 public void Bounce(IReadOnlyCollection <IBrick> bricksHit, IBorder border, IBall ball)
 {
     ball.BounceBack();
 }