Пример #1
0
        void RideOwn(int inout)
        {
            int             response = 0;
            MemberOfTraffic member   = this;
            int             middle   = Crossroad.cross.AboutMiddle(ref member);

            if (middle == 0)
            {
                response = MoveSpecEvent(ref member);
            }
            else
            {
                response = 1;
            }
            //response = Crossroad.cross.SkipOrNot(this.Destination - 1, ref member);
            //response = MemberOfTraffic.MoveEvent(this.Destination - 1, ref member);
            if (response != 0)
            {
                RemoveOwn();
                if (inout == 1)
                {
                    ChangeCoordInLine();
                }
                else
                {
                    ChangeCoordOutLine();
                }
                DrawOwn();
            }
        }
Пример #2
0
        public Truck() : base(70, 100, 6)
        {
            img = new Bitmap(FormsAppCrossroad.Properties.Resources.truck1);
            MemberOfTraffic own = this;

            Rotate(ref own);
        }
Пример #3
0
        void ChangeImage()
        {
            switch (typeSpec)
            {
            case 1:
                if (lr == 0)
                {
                    lr  = 1;
                    img = FormsAppCrossroad.Properties.Resources.spec_car1r;
                }
                else
                {
                    lr  = 0;
                    img = FormsAppCrossroad.Properties.Resources.spec_car1l;
                }
                break;

            case 2:
                if (lr == 0)
                {
                    lr  = 1;
                    img = FormsAppCrossroad.Properties.Resources.spec_car2r;
                }
                else
                {
                    lr  = 0;
                    img = FormsAppCrossroad.Properties.Resources.spec_car2l;
                }
                break;

            case 3:
                if (lr == 0)
                {
                    lr  = 1;
                    img = FormsAppCrossroad.Properties.Resources.spec_car3r;
                }
                else
                {
                    lr  = 0;
                    img = FormsAppCrossroad.Properties.Resources.spec_car3r;
                }
                break;
            }
            MemberOfTraffic own = this;

            Rotate(ref own);
        }
Пример #4
0
        public Bus() : base(60, 110, 5)
        {
            switch (random.Next(1, 3))
            {
            case 1:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.bus1);
                break;

            case 2:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.bus2);
                break;
            }

            MemberOfTraffic own = this;

            Rotate(ref own);
        }
Пример #5
0
        protected void Rotate(ref MemberOfTraffic car)
        {
            switch (this.Destination)
            {
            case 1:
                img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                break;

            case 2:
                img.RotateFlip(RotateFlipType.RotateNoneFlipX);
                break;

            case 3:
                break;

            case 4:
                img.RotateFlip(RotateFlipType.Rotate90FlipY);
                break;
            }
        }
Пример #6
0
        public LightCar() : base(55, 80, 7)
        {
            //PictureBox pictureBox = new PictureBox();

            //pathFile += random.Next(1, 7).ToString();
            //pathFile += ".png";
            //img = Image.FromFile(pathFile);

            switch (random.Next(1, 7))
            {
            case 1:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car1);
                break;

            case 2:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car2);
                break;

            case 3:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car3);
                break;

            case 4:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car4);
                break;

            case 5:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car5);
                break;

            case 6:
                img = new Bitmap(FormsAppCrossroad.Properties.Resources.light_car6);
                break;
            }
            MemberOfTraffic own = this;

            Rotate(ref own);
        }
Пример #7
0
        public virtual void Ride()
        {
            int             response;
            MemberOfTraffic member = this;

            //response = Crossroad.cross.SkipOrNot(this.Destination - 1, ref member);

            response = MoveEvent(this.Destination - 1, ref member);
            SpecCar existSpecCar = null;

            if (!(this is SpecCar) && Cross.cross.CountSpecCarAtTheLine1 > 0)
            {
                existSpecCar = Crossroad.cross.CheckExistSpecCar(this);
            }

            if (this is SpecCar || !(this is SpecCar) && (existSpecCar == null || existSpecCar.ChangeLine == 0))
            {
                switch (response)
                {
                case 0:
                    this.speedNow = 0;
                    break;

                case 1:
                case 2:
                    if (this.SpeedNow == 0)
                    {
                        this.speedNow = this.MaxSpeed;
                    }
                    if (this.DistanceToNext <= 30 && this.SpeedNext <= this.SpeedNow)
                    {
                        this.speedNow = this.Next.SpeedNow;
                    }
                    if (this.SpeedNow != 0)
                    {
                        this.RemoveOwn();     //стереть
                    }
                    int speed = this.SpeedNow;
                    if (this.DistanceToNext <= 30 && this.SpeedNext <= this.SpeedNow)
                    {
                        if (this.DistanceToNext <= 20 && this.SpeedNow > 5)
                        {
                            this.speedNow = this.Next.SpeedNow - 2;
                        }
                        if (this.DistanceToNext >= 20)
                        {
                            this.speedNow = this.Next.SpeedNow;
                        }
                    }
                    if (DistanceToNext >= 30)
                    {
                        this.speedNow = this.MaxSpeed;
                    }

                    ChangeCoord();

                    if ((this.SpeedNow == 0 && speed != 0) || this.SpeedNow != 0)
                    {
                        this.DrawOwn();
                    }
                    break;
                }
            }
            else
            {
                if (!(this is SpecCar) && existSpecCar != null && existSpecCar.ChangeLine == 1)
                {
                    this.speedNow = 0;
                }
            }
        }
Пример #8
0
 protected int getspeednext(MemberOfTraffic next)
 {
     return(next.SpeedNow);
 }
Пример #9
0
 protected void setnext(MemberOfTraffic next)
 {
     this.next = next;
 }
Пример #10
0
        public SpecCar() : base(55, 80, 8)
        {
            lr = 0;
            switch (random.Next(1, 4))
            {
            case 1:
                img      = new Bitmap(FormsAppCrossroad.Properties.Resources.spec_car1l);
                typeSpec = 1;
                break;

            case 2:
                img      = new Bitmap(FormsAppCrossroad.Properties.Resources.spec_car2l);
                typeSpec = 2;
                break;

            case 3:
                img      = new Bitmap(FormsAppCrossroad.Properties.Resources.spec_car3l);
                typeSpec = 3;
                break;
            }
            MemberOfTraffic own = this;

            Rotate(ref own);
            //int color1, color2, color3;
            //switch (random.Next(0, 3))
            //{
            //	case 0:
            //		color1 = 189;
            //		color2 = 21;
            //		color3 = 21;
            //		break;
            //	case 1:
            //		color1 = 247;
            //		color2 = 240;
            //		color3 = 240;
            //		break;
            //	case 2:
            //		color1 = 35;
            //		color2 = 62;
            //		color3 = 196;
            //		break;
            //	default:
            //		color1 = 189;
            //		color2 = 21;
            //		color3 = 21;
            //		break;
            //}
            //color = Color.FromArgb(255, color1, color2, color3);

            switch (Destination)             //начальные кординаты в зависимости от направления движения
            {
            case 1:
                x        = form.Size.Width / 2 - Width / 2;
                y        = 15;
                speedMax = 5;
                speedNow = MaxSpeed;
                break;

            case 2:
                x        = form.Size.Width - 15;
                y        = form.Size.Height / 2 - Width / 2;
                speedMax = 8;
                speedNow = MaxSpeed;
                break;

            case 3:
                x        = 15;
                y        = form.Size.Height / 2 + Width / 2;
                speedMax = 8;
                speedNow = MaxSpeed;
                break;

            case 4:
                x        = form.Size.Width / 2 + Width / 2;
                y        = form.Size.Height - 15;
                speedMax = 4;
                speedNow = MaxSpeed;
                break;
            }
            //MaxSpeed += 4;
            ChangeLine   = 0;
            CheckSetLink = 1;

            Crossroad.changeLine         += new Crossroad.ChangeLine(ChangePropertyAtTheSpecCar);
            Crossroad.changeColorSpecCar += new Crossroad.ChangeColorSpecCar(ChangeImage);
        }