Example #1
0
        private static void StartCrossWalk(PictureBox car_pictureBox, PictureBox frontPedestrian_pb, PictureBox trafficLight_pb, PictureBox ambulance_pb, Panel panel)
        {
            panel.Invoke(new MethodInvoker(() =>
                                           panel.Visible = true));
            //panel.Visible = true;
            TrafficLight trafficLight = new TrafficLight();
            Pedestrian   pedestrian   = new Pedestrian();
            Car          car          = new Car();
            //переключение светофора
            Thread SwitchTrafficThread = new Thread(new ParameterizedThreadStart(trafficLight.CheckTrafficLight));

            trafficLight_pb.Invoke(new MethodInvoker(() =>
                                                     trafficLight_pb.Visible = true));
            //trafficLight_pb.Visible = true;
            SwitchTrafficThread.Start(trafficLight_pb);
            ////движение машины
            Thread       moveCarThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectCar));
            ClassForMove myObject1Car  = new ClassForMove(car, car_pictureBox, trafficLight, frontPedestrian_pb, pedestrian);

            moveCarThread.Start(myObject1Car);
            ////движение пешехода переднего
            Thread       frontPedestrianThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectFrontPedestrian));
            ClassForMove myObject2Pedestrian   = new ClassForMove(pedestrian, frontPedestrian_pb, trafficLight, car_pictureBox, car);

            frontPedestrianThread.Start(myObject2Pedestrian);
            //аварийный случай
            Thread       ambulanceThread    = new Thread(new ParameterizedThreadStart(Utils.CheckEmergencyCase));
            ClassForMove myObject3Ambulance = new ClassForMove(ambulance_pb, pedestrian, car);

            ambulanceThread.Start(myObject3Ambulance);
        }
Example #2
0
        private void Start_btn_Click(object sender, EventArgs e)
        {
            Rocket rocket = new Rocket();
            //движение ракеты
            Thread       moveRocketThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectRocket));
            ClassForMove objRocket        = new ClassForMove(rocket, Rocket_pb, Backhround_pb);

            moveRocketThread.Start(objRocket);
            //выход космонавтов
            Thread       moveCosmonautThread = new Thread(new ParameterizedThreadStart(Utils.CheckSuccesfullStart));
            ClassForMove objCosmonaut        = new ClassForMove(rocket, Cosmonaut_pb, Backhround_pb);

            moveCosmonautThread.Start(objCosmonaut);
            //выплата страховки
            Insurance    insurance       = new InsuranceRocket();
            Thread       insuranceThread = new Thread(new ParameterizedThreadStart(Utils.CheckCrashStatus));
            ClassForMove objInsurance    = new ClassForMove(rocket, Money_pb, Backhround_pb);

            insuranceThread.Start(objInsurance);
        }
Example #3
0
        private static void StartMoving(PictureBox rocket_pb, PictureBox cosmonaut_pb, PictureBox insurance_pb, PictureBox bg_pb, Panel panel)
        {
            panel.Invoke(new MethodInvoker(() =>
                                           panel.Visible = true));
            Rocket rocket = new Rocket();
            //движение ракеты
            Thread       moveRocketThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectRocket));
            ClassForMove objRocket        = new ClassForMove(rocket, rocket_pb, bg_pb, NearestCount1, NearestCount2);

            moveRocketThread.Start(objRocket);
            //выход космонавтов
            Thread       moveCosmonautThread = new Thread(new ParameterizedThreadStart(Utils.CheckSuccesfullStart));
            ClassForMove objCosmonaut        = new ClassForMove(rocket, cosmonaut_pb, bg_pb, NearestCount1, NearestCount2);

            moveCosmonautThread.Start(objCosmonaut);
            //выплата страховки
            Insurance    insurance       = new InsuranceRocket();
            Thread       insuranceThread = new Thread(new ParameterizedThreadStart(Utils.CheckCrashStatus));
            ClassForMove objInsurance    = new ClassForMove(rocket, insurance_pb, bg_pb, NearestCount1, NearestCount2);

            insuranceThread.Start(objInsurance);
        }
Example #4
0
        private void StartFilm_btn_Click(object sender, EventArgs e)
        {
            TrafficLight trafficLight = new TrafficLight();
            Pedestrian   pedestrian   = new Pedestrian();
            Car          car          = new Car();
            //переключение светофора
            Thread SwitchTrafficThread = new Thread(new ParameterizedThreadStart(trafficLight.CheckTrafficLight));

            trafficLight_pb.Visible = true;
            SwitchTrafficThread.Start(trafficLight_pb);
            ////движение машины
            Thread       moveCarThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectCar));
            ClassForMove myObject1Car  = new ClassForMove(car, car_pictureBox, trafficLight);

            moveCarThread.Start(myObject1Car);
            ////движение пешехода переднего
            Thread       frontPedestrianThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectFrontPedestrian));
            ClassForMove myObject2Pedestrian   = new ClassForMove(pedestrian, frontPedestrian_pb);

            frontPedestrianThread.Start(myObject2Pedestrian);
            //аварийный случай
            //if (car.BumpStatus == true || pedestrian.BumpStatus == true)
            //{
            //    ambulance_pb.Visible = true;
            //    fireman_pb.Visible = true;
            //    police_pb.Visible = true;
            //    Thread ambulanceThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectAmbulancy));
            //    ClassForMove myObject3Ambulance = new ClassForMove(ambulance_pb);
            //    ambulanceThread.Start(myObject3Ambulance);
            //    Thread policeThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectPoliceAndFireGuys));
            //    ClassForMove myObject4Police = new ClassForMove(police_pb);
            //    policeThread.Start(myObject4Police);
            //    Thread FireThread = new Thread(new ParameterizedThreadStart(Utils.MoveObjectPoliceAndFireGuys));
            //    ClassForMove myObject5FireGuys = new ClassForMove(fireman_pb);
            //    FireThread.Start(myObject5FireGuys);
            //}
        }