コード例 #1
0
ファイル: Controller.cs プロジェクト: Samin-Asnaashari/PROCP
 public void AddNewCar()
 {
     int s = CarSize();
     for (int i = 0; i < Design.EnterancesLanes.Count; i++)
     {
         Car c = new Car(id,Design.EnterancesLanes[i].Entrance, Design.EnterancesLanes[i].DirectionIsTo, s);
         //Console.WriteLine(id);
         id++;
         if (Design.EnterancesLanes[i].Cars.Count < 1 && c.CheckMove(Design.EnterancesLanes[i],c.Position))  //
         {
             Design.EnterancesLanes[i].Cars.Add(c);
             Design.EnterancesLanes[i].CountCars++;
         }
     }
 }
コード例 #2
0
ファイル: Controller.cs プロジェクト: Samin-Asnaashari/PROCP
        public void countDownLights(object sender, ElapsedEventArgs e)
        {
            if (counter % 2 == 0)
            {
                for (int i = 0; i < Design.allcreatedcrossings.Count; i++)
                {
                    Crossing C = Design.allcreatedcrossings[i];
                    C.countDown();
                }

                int s = CarSize();
                for (int i = 0; i < Design.EnterancesLanes.Count; i++)
                {
                    Car c = new Car(id, Design.EnterancesLanes[i].Entrance, Design.EnterancesLanes[i].DirectionIsTo, s);
                    //Console.WriteLine(id);
                    id++;
                    if (Design.EnterancesLanes[i].Cars.Count < 5 && c.CheckMove(Design.EnterancesLanes[i], c.Position))  //
                    {
                        Design.EnterancesLanes[i].Cars.Add(c);
                        Design.EnterancesLanes[i].CountCars++;
                    }
                }
            }

            counter++;
        }