Beispiel #1
0
        //------------------------------------------------------------------
        public Block(Driver driver, Car target)
        {
            this.driver = driver;
            this.target = target;

            Initial = new Generic (Start);
        }
Beispiel #2
0
        //------------------------------------------------------------------
        public Player(Car car)
            : base(car)
        {
            Velocity = 400;
            ChangeLaneSpeed = 2;

            AddInLoop (new Input (this));
            //            AddInLoop (new Shrink (this));
        }
Beispiel #3
0
        //------------------------------------------------------------------
        protected Driver(Car car)
            : base(car)
        {
            Loop = new Loop();
            Sequence = new Sequence();
            AddInLoop (Sequence);

            Car = car;

            Velocity = Car.Lane.Velocity;
            ChangeLaneSpeed = 1;
            SafeZone = new SafeZone (this, 1);
            Primary = Direction.Left;
        }
Beispiel #4
0
 //------------------------------------------------------------------
 public Common(Car car)
     : base(car)
 {
     AddInLoop (new Shrink (this));
     AddInLoop (new SpeedControl(this));
 }
Beispiel #5
0
        //------------------------------------------------------------------
        private void Slave(Car car)
        {
            if (car == null) return;

            Car police = car.Lane.Road.FindClosestPolice (car);
            if (police == null) return;

            car.Driver.AddInLoop (new Overtake (car.Driver, police));
            car.Driver.AddInLoop (new Block (car.Driver, police));

            car.Acceleration = car.Acceleration * 2;
            car.Deceleration = car.Deceleration * 2;
            car.Driver.Velocity = car.Driver.Velocity * 2;

            Engine.Tools.Timers.Loop.Create (1, 0, car.Turn);
        }
Beispiel #6
0
 //------------------------------------------------------------------
 private void FindClosestCar()
 {
     closest = driver.FindClosestCar (driver.Car.Lane.Cars.Where (driver.IsCarAhead));
 }
Beispiel #7
0
 //------------------------------------------------------------------
 private bool IsCarAhead(Car target)
 {
     return driver.Car.Position.Y > target.Position.Y;
 }
Beispiel #8
0
        //-----------------------------------------------------------------
        private bool CheckCar(Car car)
        {
            if (car == null) return true;

            float distance = Distance (car);

            // If Car is too close
            if (distance < SafeZone.HighDanger)
                return false;
            // If Car is far enough it's Ok
            if (distance > SafeZone.LowDanger)
                return true;

            // Analyze Velocity
            if (IsCarAhead (car) && car.Velocity < Car.Velocity)
                return false;
            if (!IsCarAhead (car) && car.Velocity > Car.Velocity)
                return false;

            // Ok. The Car isn't dangerous
            return true;
        }
Beispiel #9
0
 //------------------------------------------------------------------
 public bool IsCarAhead(Car car)
 {
     return car.Position.Y < Car.Position.Y;
 }
Beispiel #10
0
        //------------------------------------------------------------------
        public float Distance(Car car)
        {
            if (car == null) return float.MaxValue;
            if (car == Car) return float.MaxValue;
            if (!car.IsIntersectActive()) return float.MaxValue;

            var distance = Car.Position - car.Position;

            return Math.Abs (distance.Y);
        }
Beispiel #11
0
 //------------------------------------------------------------------
 public Blinker(Car car, string textureName)
     : base(car, textureName)
 {
 }
Beispiel #12
0
 //------------------------------------------------------------------
 public Lights(Car car, string textureName)
     : base(car)
 {
     this.textureName = textureName;
     this.car = car;
 }
Beispiel #13
0
        //------------------------------------------------------------------
        protected void Explose(Car killer)
        {
            // Drawable.Explose ();

            Destroy ();
        }
Beispiel #14
0
        //------------------------------------------------------------------
        public virtual bool Intersect(Car car)
        {
            if (car == this) return false;
            if (!IsIntersectActive()) return false;
            if (!car.IsIntersectActive()) return false;

            return Bounds.Intersects (car.Bounds);
        }