Пример #1
0
 /// <summary>
 /// Removes the car as a line follower.
 /// </summary>
 public void CheckAndRemoveChild(DynamicCar car)
 {
     RemoveChild(car);
     if (car == _lastCar)
     {
         _lastCar = null;
     }
 }
 /// <summary>
 /// Sets the car to the start position and enables the collision detection
 /// </summary>
 public void StartDriving(DynamicCar precursoryCar, TrafficControlSystem trafficLight)
 {
     _precursoryCar = precursoryCar;
     if (_precursoryCar != null)
     {
         precursoryCar._followingCar = this;
     }
     _trafficLight = trafficLight;
     Offset        = 0.001f; // 0 is not possible because godot only sets the position with a delta.
 }
 private void CollectCompletedEntities()
 {
     for (int i = 0; i < _carsToCollect.Count; i++)
     {
         DynamicCar car = _carsToCollect[i];
         _reports.Add(car.Report);
         _activeCars.Remove(car);
         car.RemoveCar();
         car.QueueFree();
     }
     _carsToCollect.Clear();
 }
 private int CheckNextSpawnTime(PathController referencePath, int time)
 {
     if (time <= 0)
     {
         time = SpawnTimeGenerator.GetNextSpawnTime();
         if (referencePath.SpawnPossible())
         {
             DynamicCar car = (DynamicCar)((PackedScene)GD.Load(CarReference)).Instance();
             car.Initialise();
             referencePath.AddChildAndStart(car);
             _activeCars.Add(car);
         }
     }
     return time;
 }
Пример #5
0
 /// <summary>
 /// Adds the car to the path controller and sets references.
 /// </summary>
 public void AddChildAndStart(DynamicCar car)
 {
     AddChild(car);
     car.StartDriving(_lastCar, _trafficLight);
     _lastCar = car;
 }