Esempio n. 1
0
        public static void VerticalRightCar()
        {
            int polosa = Engine.R.Next(0, Engine.CurrentRoad.VerticalRoadRight);
            int sprite = Engine.R.Next(0, 42);

            if (
                !Engine.Cars.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.Cars.Add(new Car(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)));
            }
        }
Esempio n. 2
0
        public static void HorizontalDownCar()
        {
            int polosa = Engine.R.Next(0, Engine.CurrentRoad.HorizontRoadDown);
            int sprite = Engine.R.Next(0, 42);

            if (!Engine.Cars.Exists(
                    c =>
                    c.Y >= Engine.UserPanel.Height / 2 + 50 * (polosa - 1) && c.Y <= Engine.UserPanel.Height / 2 + 50 * polosa &&
                    c.X - 70 <= 0))
            {
                Engine.Cars.Add(new Car(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)));
            }
        }
Esempio n. 3
0
        public static void VerticalLeftCar()
        {
            int polosa = Engine.R.Next(0, Engine.CurrentRoad.VerticalRoadLeft);
            int sprite = Engine.R.Next(0, 42);

            if (
                !Engine.Cars.Exists(
                    c =>
                    c.X >= Engine.UserPanel.Width / 2 - 50 * (polosa + 1) && c.X <= Engine.UserPanel.Width / 2 - 50 * polosa &&
                    c.Y - 70 <= 0))
            {
                Engine.Cars.Add(new Car(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)));
            }
        }
Esempio n. 4
0
        public static void HorizontalUpCar()
        {
            int polosa = Engine.R.Next(0, Engine.CurrentRoad.HorizontRoadUp);
            int sprite = Engine.R.Next(0, 42);

            if (
                !Engine.Cars.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.Cars.Add(new Car(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)));
            }
        }
Esempio n. 5
0
        public static bool Check(Car c)
        {
            switch (c.CurrRoad)
            {
            case Side.Down:
                if (!RoadPass.CenterFive(c) && Engine.Cars.Exists(
                        sc =>
                        sc.Y == c.Y &&
                        c.X + 60 >= sc.X && c.X + 10 <= sc.X) ||
                    (Engine.Peoples.Exists(
                         p => c.Y < p.Y + 40 && c.Y > p.Y - 40 && c.X + 60 >= p.X && c.X + 40 <= p.X) &&
                     c.X < Engine.UserPanel.Width / 2 + Engine.CurrentRoad.VerticalRoadRight * 40 + 100))
                {
                    return(true);
                }
                if (c.Turn == CTurn.Left && Engine.TrafficLights[1].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.Cars.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.Cars.Exists(
                        sc =>
                        sc.Y == c.Y &&
                        c.X - 60 <= sc.X && c.X - 10 >= sc.X) ||
                    (Engine.Peoples.Exists(
                         p => c.Y < p.Y + 40 && c.Y > p.Y - 40 && c.X - 60 <= p.X && c.X - 40 >= p.X) && c.X > Engine.UserPanel.Width / 2 - Engine.CurrentRoad.VerticalRoadLeft * 40 - 100))
                {
                    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.Cars.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.Cars.Exists(
                        sc =>
                        sc.X == c.X &&
                        c.Y - 60 <= sc.Y && c.Y - 10 >= sc.Y) ||
                    (Engine.Peoples.Exists(
                         p => c.X < p.X + 40 && c.X > p.X - 40 && c.Y - 60 <= p.Y && c.Y - 40 >= p.Y) && c.Y > Engine.UserPanel.Height / 2 - Engine.CurrentRoad.HorizontRoadUp * 40 - 100))
                {
                    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.Cars.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.Cars.Exists(
                        sc =>
                        sc.X == c.X &&
                        c.Y + 60 >= sc.Y && c.Y + 10 <= sc.Y) ||
                    (Engine.Peoples.Exists(
                         p => c.X < p.X + 40 && c.X > p.X - 40 && c.Y + 60 >= p.Y && c.Y + 40 <= p.Y) && c.Y < Engine.UserPanel.Height / 2 + Engine.CurrentRoad.HorizontRoadUp * 40 + 100))
                {
                    return(true);
                }
                if (c.Turn == CTurn.Left && Engine.TrafficLights[3].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.Cars.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);
        }