//------------------------------------------------------------------ public Block(Driver driver, Car target) { this.driver = driver; this.target = target; Initial = new Generic (Start); }
//------------------------------------------------------------------ public Player(Car car) : base(car) { Velocity = 400; ChangeLaneSpeed = 2; AddInLoop (new Input (this)); // AddInLoop (new Shrink (this)); }
//------------------------------------------------------------------ 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; }
//------------------------------------------------------------------ public Common(Car car) : base(car) { AddInLoop (new Shrink (this)); AddInLoop (new SpeedControl(this)); }
//------------------------------------------------------------------ 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); }
//------------------------------------------------------------------ private void FindClosestCar() { closest = driver.FindClosestCar (driver.Car.Lane.Cars.Where (driver.IsCarAhead)); }
//------------------------------------------------------------------ private bool IsCarAhead(Car target) { return driver.Car.Position.Y > target.Position.Y; }
//----------------------------------------------------------------- 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; }
//------------------------------------------------------------------ public bool IsCarAhead(Car car) { return car.Position.Y < Car.Position.Y; }
//------------------------------------------------------------------ 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); }
//------------------------------------------------------------------ public Blinker(Car car, string textureName) : base(car, textureName) { }
//------------------------------------------------------------------ public Lights(Car car, string textureName) : base(car) { this.textureName = textureName; this.car = car; }
//------------------------------------------------------------------ protected void Explose(Car killer) { // Drawable.Explose (); Destroy (); }
//------------------------------------------------------------------ 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); }