Ejemplo n.º 1
0
        public static void OnCrossRoad(Crazy_car car)
        {
            switch (car.SIDE)
            {
            case 0:
                // верхние
                if (Engine.Cars.Exists(cr => cr.SIDE == 1 && cr.X < Engine.Picture.Width / 2 + 40 && cr.X > Engine.Picture.Width / 2 - 80) ||
                    Engine.Cars.Exists(cr => cr.SIDE == 3 && cr.X < Engine.Picture.Width / 2 + 60 && cr.X > Engine.Picture.Width / 2 - 50) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 1 && cr.X < Engine.Picture.Width / 2 + 180 && cr.X > Engine.Picture.Width / 2 - 80) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 3 && cr.X < Engine.Picture.Width / 2 + 60 && cr.X > Engine.Picture.Width / 2 - 70))
                {
                    on_cros?.Invoke(1);
                }
                else
                {
                    on_cros?.Invoke(0);
                }
                break;

            case 1:
                // Правые
                if (Engine.Cars.Exists(cr => cr.SIDE == 0 && cr.Y < Engine.Picture.Height / 2 && cr.Y > Engine.Picture.Height / 2 - 100) ||
                    Engine.Cars.Exists(cr => cr.SIDE == 2 && cr.Y > Engine.Picture.Height / 2 - 90 && cr.Y < Engine.Picture.Height / 2 + 30) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 0 && cr.Y < Engine.Picture.Height / 2 && cr.Y > Engine.Picture.Height / 2 - 100) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 2 && cr.Y > Engine.Picture.Height / 2 - 90 && cr.Y < Engine.Picture.Height / 2 + 60))
                {
                    on_cros?.Invoke(1);
                }
                else
                {
                    on_cros?.Invoke(0);
                }
                break;

            case 2:
                // нижние
                if (Engine.Cars.Exists(cr => cr.SIDE == 1 && cr.X > Engine.Picture.Width / 2 - 5 && cr.X < Engine.Picture.Width / 2 + 40) ||
                    Engine.Cars.Exists(cr => cr.SIDE == 3 && cr.X > Engine.Picture.Width / 2 - 100 && cr.X < Engine.Picture.Width / 2 + 30) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 1 && cr.X > Engine.Picture.Width / 2 - 5 && cr.X < Engine.Picture.Width / 2 + 40) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 3 && cr.X > Engine.Picture.Width / 2 - 120 && cr.X < Engine.Picture.Width / 2 + 30))
                {
                    on_cros?.Invoke(1);
                }
                else
                {
                    on_cros?.Invoke(0);
                }
                break;

            case 3:
                // леваки
                if (Engine.Cars.Exists(cr => cr.SIDE == 0 && cr.Y > Engine.Picture.Height / 2 - 90 && cr.Y < Engine.Picture.Height / 2 + 20) ||
                    Engine.Cars.Exists(cr => cr.SIDE == 2 && cr.Y > Engine.Picture.Height / 2 - 40 && cr.Y < Engine.Picture.Height / 2) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 0 && cr.Y > Engine.Picture.Height / 2 - 110 && cr.Y < Engine.Picture.Height / 2 + 20) ||
                    Engine.CR_cars.Exists(cr => cr.SIDE == 2 && cr.Y > Engine.Picture.Height / 2 - 40 && cr.Y < Engine.Picture.Height / 2))
                {
                    on_cros?.Invoke(1);
                }
                else
                {
                    on_cros?.Invoke(0);
                }
                break;
            }
        }
Ejemplo n.º 2
0
 public static void ChangeSpeed(int speed, Crazy_car car)
 {
     car.SPEED = speed;
 }