Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Ride()
        {
            int checkCoord;

            SetSpeed();

            switch (ChangeLine)
            {
            case 0:
                //if (DistanceToNext > 30)
                //{
                //	speedNow = MaxSpeed;
                //}
                checkCoord = CheckCoord();
                if (AtTheLine == 2 && checkCoord == 1)
                {
                    //ChangeLine = 1;
                    ChangePropertyAtTheSpecCar();
                }
                base.Ride();
                break;

            case 1:
                if (AtTheLine != 1)
                {
                    int answer = 0;
                    answer     = Crossroad.cross.CanChangeLine(this);
                    checkCoord = CheckCoord();
                    if (answer == 1)
                    {
                        if (CheckSetLink == 1)
                        {
                            SpecCar car = this;

                            int res = Crossroad.cross.SetLinkIfSpecCarChangeLines(ref car, 1);
                            CheckSetLink = 0;
                            if (res == 0)
                            {
                                this.Next = Crossroad.cross.CheckLast(ref car);
                            }
                        }
                        SetSpeed();

                        RideOwn(1);
                    }
                    else
                    {
                        base.Ride();
                    }
                }
                if (AtTheLine == 1)
                {
                    if (trigger == 1)
                    {
                        trigger = 0;
                        Cross.cross.CountSpecCarAtTheLine1--;
                    }

                    speedNow = MaxSpeed;
                    var answer = Crossroad.cross.DistanceToSpecCar(this);
                    checkCoord = CheckCoord();
                    if (answer == 2000 && checkCoord != 1)
                    {
                        ChangeLine = 2;
                    }
                    else
                    {
                        ChangeLine = 0;
                    }
                }
                break;

            case 2:
                if (AtTheLine != 2)
                {
                    var answer = Crossroad.cross.DistanceToSpecCar(this);
                    checkCoord = CheckCoord();
                    if (answer > 600 && answer < 2000 || checkCoord == 1)
                    {
                        ChangeLine = 1;
                    }
                    //if (DistanceToNext < 30)
                    //{
                    //	speedNow = Next.SpeedNow;
                    //	if (DistanceToNext < 15)
                    //	{
                    //		speedNow = Next.SpeedNow;
                    //	}
                    //}
                    SetSpeed();

                    RideOwn(0);
                }
                else
                {
                    base.Ride();
                }
                checkCoord = CheckCoord();
                if (AtTheLine == 2)
                {
                    SpecCar car = this;
                    Crossroad.cross.SetLinkIfSpecCarChangeLines(ref car, 0);
                    CheckSetLink = 1;
                    speedNow     = MaxSpeed;
                    ChangeLine   = 0;
                }
                break;
            }
        }