コード例 #1
0
ファイル: MainForm.cs プロジェクト: ERASERASERAS/ARDS
        private void generateCarTimer_Tick(object sender, EventArgs e)
        {
            Car        newCar        = new Car((int)GeneratorsHolder.getGeneratorsHolder().SPEEDSGENERATOR.getSpeed());
            CarDrawing newCarDrawing = new CarDrawing("..\\..\\images\\cars\\car" + rnd.Next(1, 5).ToString() + ".png", newCar);

            newCarDrawing.car = newCar;
            Stripe randomStripe = new Stripe();;
            Way    randomWay    = new Way();
            //int i = 0;
            //while (i < Road.getRoad().COUNTOFSTRIPES)
            //{
            int randowWayNumber = rnd.Next(0, Road.getRoad().COUNTOFWAYS);

            randomWay = Road.getRoad().WAYS.ElementAt(randowWayNumber);
            int randomStripeNumber = rnd.Next(0, randomWay.stripes.Count);

            randomStripe = randomWay.stripes.ElementAt(randomStripeNumber);
            foreach (StripeDrawing sd in RoadDrawing.getRoadDrawing().STRIPEDRAWINGS)
            {
                if (randomStripe.Equals(sd.stripe))
                {
                    if (sd.canGenerateNewCar(randomWay.way.Equals("LEFT") ? mainPictureBox.Width : 0, randomWay.way.Equals("LEFT") ? -1 : 1))
                    {
                        sd.carsDrawings.AddLast(newCarDrawing);
                        if (randomWay.way.Equals("RIGHT"))
                        {
                            newCar.speed       *= -1;
                            newCar.initialSpeed = newCar.speed;
                            newCarDrawing.carImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
                            newCarDrawing.X = sd.X;
                            newCarDrawing.Y = sd.Y + mainPictureBox.Height / 14;
                        }
                        else
                        {
                            newCarDrawing.X = sd.X + mainPictureBox.Width;
                            newCarDrawing.Y = sd.Y + mainPictureBox.Height / 14;
                        }
                        mainPictureBox.Invalidate();
                    }
                }
            }
            //++i;
            //}

            randomStripe.addCar(newCar);
            generateCarTimer.Interval       = (int)(GeneratorsHolder.getGeneratorsHolder().TIMESGENERATOR.getTime() * 1000);
            labelForCarAppereanceValue.Text = (generateCarTimer.Interval / 1000).ToString();
        }
コード例 #2
0
ファイル: Road.cs プロジェクト: ERASERASERAS/ARDS
        public Stripe getStripeForOvertaking(Stripe stripe, string nameOfWay)
        {
            Stripe returnedStripe   = null;
            Way    wayForOvertaking = getWayForOvertaking(nameOfWay);

            if (wayForOvertaking != null)
            {
                LinkedListNode <Stripe> currentStripeNode = wayForOvertaking.stripes.Find(stripe);
                if (currentStripeNode.Next != null)
                {
                    returnedStripe = currentStripeNode.Next.Value;
                }
                else if (currentStripeNode.Previous != null)
                {
                    returnedStripe = currentStripeNode.Previous.Value;
                }
            }

            return(returnedStripe);
        }
コード例 #3
0
ファイル: Way.cs プロジェクト: ERASERASERAS/ARDS
 public void addStripe(Stripe newStripe)
 {
     stripes.AddLast(newStripe);
 }