Пример #1
0
        public void UpdateVelocity(DotPosition dotPosition, Velocity velocity)
        {
            if ((dotPosition.X == X || dotPosition.X == _x1) && (dotPosition.Y == Y || dotPosition.Y == _y1))
            {
                velocity.InvertBoth();
                return;
            }

            if (dotPosition.X == X || dotPosition.X == _x1)
            {
                velocity.InvertX();
                return;
            }

            if (dotPosition.Y == Y || dotPosition.Y == _y1)
            {
                velocity.InvertY();
                return;
            }

            throw new InvalidOperationException("This shouldn't happen");
        }
Пример #2
0
 public static bool AnyHitBy(DotPosition dotPosition) => obstacles.Any(o => o.Hits(dotPosition));
Пример #3
0
 public bool Hits(DotPosition dotPosition) => dotPosition.X >= X && dotPosition.X <= _x1 && dotPosition.Y >= Y && dotPosition.Y <= _y1;