public static bool Check(Cars c) { switch (c.CurrRoad) { case Side.Down: if (!RoadPass.CenterFive(c) && Engine.Car.Exists( sc => sc.Y == c.Y && c.X + 60 >= sc.X && c.X + 10 <= sc.X)) { return(true); } if (c.Turn == CTurn.Left && Engine.TrafficLights[2].CurrLight == TrafficLight.Lights.Green && c.X <= Engine.UserPanel.Width / 2 - 60 && c.X >= Engine.UserPanel.Width / 2 - 65) { return(true); } if (c.Turn == CTurn.Right && c.X >= Engine.UserPanel.Width / 2 - 50 * (Engine.CurrentRoad.VerticalRoadLeft + 1) + 20 && c.X <= Engine.UserPanel.Width / 2 - 50 * Engine.CurrentRoad.VerticalRoadLeft - 25 && Engine.Car.Exists( sc => sc.X >= Engine.UserPanel.Width / 2 - 50 * Engine.CurrentRoad.VerticalRoadLeft && sc.X <= Engine.UserPanel.Width / 2 - 50 * (Engine.CurrentRoad.VerticalRoadLeft - 1) && sc.Y <= Engine.UserPanel.Height / 2 + Engine.CurrentRoad.HorizontRoadDown * 40 + 45 && sc.Y >= Engine.UserPanel.Height / 2 + Engine.CurrentRoad.HorizontRoadDown * 40 - 45 && sc != c)) { return(true); } break; case Side.Up: if (!RoadPass.CenterFive(c) && Engine.Car.Exists( sc => sc.Y == c.Y && c.X - 60 <= sc.X && c.X - 10 >= sc.X)) { return(true); } if (c.Turn == CTurn.Left && Engine.TrafficLights[1].CurrLight == TrafficLight.Lights.Green && c.X >= Engine.UserPanel.Width / 2 + 5 && c.X <= Engine.UserPanel.Width / 2 + 10) { return(true); } if (c.Turn == CTurn.Right && c.X >= Engine.UserPanel.Width / 2 + 50 * (Engine.CurrentRoad.VerticalRoadRight - 1) && c.X <= Engine.UserPanel.Width / 2 + 50 * Engine.CurrentRoad.VerticalRoadRight - 45 && Engine.Car.Exists( sc => sc.X >= Engine.UserPanel.Width / 2 + 50 * (Engine.CurrentRoad.VerticalRoadRight - 2) && sc.X <= Engine.UserPanel.Width / 2 + 50 * (Engine.CurrentRoad.VerticalRoadRight - 1) && sc.Y <= Engine.UserPanel.Height / 2 - Engine.CurrentRoad.HorizontRoadUp * 40 + 65 && sc.Y >= Engine.UserPanel.Height / 2 - Engine.CurrentRoad.HorizontRoadUp * 40 - 65 && sc != c)) { return(true); } break; case Side.Right: if (!RoadPass.CenterFive(c) && Engine.Car.Exists( sc => sc.X == c.X && c.Y - 60 <= sc.Y && c.Y - 10 >= sc.Y)) { return(true); } if (c.Turn == CTurn.Left && Engine.TrafficLights[3].CurrLight == TrafficLight.Lights.Green && c.Y <= Engine.UserPanel.Height / 2 + 15 && c.Y >= Engine.UserPanel.Height / 2 + 10) { return(true); } if (c.Turn == CTurn.Right && c.Y >= Engine.UserPanel.Height / 2 + 50 * (Engine.CurrentRoad.HorizontRoadDown - 1) && c.Y <= Engine.UserPanel.Height / 2 + 50 * Engine.CurrentRoad.HorizontRoadDown - 45 && Engine.Car.Exists( sc => sc.Y >= Engine.UserPanel.Height / 2 + 50 * (Engine.CurrentRoad.HorizontRoadDown - 2) && sc.Y <= Engine.UserPanel.Height / 2 + 50 * (Engine.CurrentRoad.HorizontRoadDown - 1) && sc.X <= Engine.UserPanel.Width / 2 + Engine.CurrentRoad.VerticalRoadRight * 40 + 45 && sc.X >= Engine.UserPanel.Width / 2 + Engine.CurrentRoad.VerticalRoadRight * 40 - 45 && sc != c)) { return(true); } break; case Side.Left: if (!RoadPass.CenterFive(c) && Engine.Car.Exists( sc => sc.X == c.X && c.Y + 60 >= sc.Y && c.Y + 10 <= sc.Y)) { return(true); } if (c.Turn == CTurn.Left && Engine.TrafficLights[0].CurrLight == TrafficLight.Lights.Green && c.Y <= Engine.UserPanel.Height / 2 - 55 && c.Y >= Engine.UserPanel.Height / 2 - 60) { return(true); } if (c.Turn == CTurn.Right && c.Y >= Engine.UserPanel.Height / 2 - 50 * (Engine.CurrentRoad.HorizontRoadDown + 1) + 20 && c.Y <= Engine.UserPanel.Height / 2 - 50 * Engine.CurrentRoad.HorizontRoadDown - 25 && Engine.Car.Exists( sc => sc.Y >= Engine.UserPanel.Height / 2 - 50 * (Engine.CurrentRoad.HorizontRoadUp) && sc.Y <= Engine.UserPanel.Height / 2 - 50 * (Engine.CurrentRoad.HorizontRoadUp - 1) && sc.X <= Engine.UserPanel.Width / 2 - Engine.CurrentRoad.VerticalRoadLeft * 40 + 45 && sc.X >= Engine.UserPanel.Width / 2 - Engine.CurrentRoad.VerticalRoadLeft * 40 - 80 && sc != c)) { return(true); } break; } return(false); }
public static void HorizontalDownCar() { int polosa = Engine.R.Next(0, Engine.CurrentRoad.HorizontRoadDown); int sprite = Engine.R.Next(0, 42); if (!Engine.Car.Exists( c => c.Y >= Engine.UserPanel.Height / 2 + 50 * (polosa - 1) && c.Y <= Engine.UserPanel.Height / 2 + 50 * polosa && c.X - 70 <= 0)) { Engine.Car.Add(new Cars(0, Engine.UserPanel.Height / 2 - 8 + polosa * 40, 3, Sprite.SpriteLibRight[sprite], sprite, new Vector(1, 0), polosa + 1, Engine.CurrentRoad.HorizontRoadDown, Engine.CurrentRoad.VerticalRoadRight, Side.Down, RoadPass.WhatIsTurn(polosa + 1, Engine.CurrentRoad.HorizontRoadDown))); } }
public static void VerticalLeftCar() { int polosa = Engine.R.Next(0, Engine.CurrentRoad.VerticalRoadLeft); int sprite = Engine.R.Next(0, 42); if ( !Engine.Car.Exists( c => c.X >= Engine.UserPanel.Width / 2 - 50 * (polosa + 1) && c.X <= Engine.UserPanel.Width / 2 - 50 * polosa && c.Y - 70 <= 0)) { Engine.Car.Add(new Cars(Engine.UserPanel.Width / 2 - 50 - polosa * 40, 0, 3, Sprite.SpriteLibDown[sprite], sprite, new Vector(0, 1), polosa + 1, Engine.CurrentRoad.VerticalRoadLeft, Engine.CurrentRoad.HorizontRoadDown, Side.Left, RoadPass.WhatIsTurn(polosa + 1, Engine.CurrentRoad.VerticalRoadLeft))); } }
public static void HorizontalUpCar() { int polosa = Engine.R.Next(0, Engine.CurrentRoad.HorizontRoadUp); int sprite = Engine.R.Next(0, 42); if ( !Engine.Car.Exists( c => c.Y >= Engine.UserPanel.Height / 2 - 50 * (polosa + 1) && c.Y <= Engine.UserPanel.Height / 2 - 50 * polosa && c.X + 70 >= Engine.UserPanel.Width)) { Engine.Car.Add(new Cars(Engine.UserPanel.Width, Engine.UserPanel.Height / 2 - 50 - polosa * 40, 3, Sprite.SpriteLibLeft[sprite], sprite, new Vector(-1, 0), polosa + 1, Engine.CurrentRoad.HorizontRoadUp, Engine.CurrentRoad.VerticalRoadLeft, Side.Up, RoadPass.WhatIsTurn(polosa + 1, Engine.CurrentRoad.HorizontRoadUp))); } }
public static void VerticalRightCar() { int polosa = Engine.R.Next(0, Engine.CurrentRoad.VerticalRoadRight); int sprite = Engine.R.Next(0, 42); if ( !Engine.Car.Exists( c => c.X >= Engine.UserPanel.Width / 2 + 50 * (polosa - 1) && c.X <= Engine.UserPanel.Width / 2 + 50 * polosa && c.Y + 70 >= Engine.UserPanel.Height)) { Engine.Car.Add(new Cars(Engine.UserPanel.Width / 2 - 8 + polosa * 40, Engine.UserPanel.Height, 3, Sprite.SpriteLibUp[sprite], sprite, new Vector(0, -1), polosa + 1, Engine.CurrentRoad.VerticalRoadRight, Engine.CurrentRoad.HorizontRoadUp, Side.Right, RoadPass.WhatIsTurn(polosa + 1, Engine.CurrentRoad.VerticalRoadRight))); } }