Пример #1
0
        private void OnCheckpointEnter(Checkpoint checkpoint, ICarController carController)
        {
            if (checkpoint != NextCheckpoint)
            {
                return;
            }

#if UNITY_EDITOR
            Debug.Log(carController.Name + " has visited the checkpoint " + checkpoint.gameObject.name + ", in " +
                      _timer);
#endif

            _availableCheckpoints.Remove(checkpoint);

            checkpoint.PassByPlayer();

            if (_availableCheckpoints.Count <= 0)
            {
                Debug.Log("Game over");

                var starsCount = CalculateStarsCount(_timer);
                _onCheckpointGameFinished?.Invoke(starsCount);

                Debug.Log("Stars: " + starsCount);

                return;
            }

            SetNextCheckpoint();
            _onCheckpointPassed?.Invoke(checkpoint);
        }
        private void NextTrack(bool shouldDestroyCarGameObject)
        {
            _tracks[_trackIndex].SetActive(false);
            _trackIndex = (_trackIndex + 1) % _tracks.Count;
            _tracks[_trackIndex].SetActive(true);

            if (shouldDestroyCarGameObject)
            {
                Destroy(_carGameObject);
            }

            Transform  trackStartPoint = _tracks[_trackIndex].transform.Find(Tags.TrackStartPoint);
            GameObject gameObject      = _carGameObject = Instantiate(CarPrefab, trackStartPoint.position, trackStartPoint.rotation);

            Car   car     = gameObject.GetComponent <Car>();
            var   network = (NeuralNetwork)Scenes.Data[DataTags.DemoAgentNetwork];
            Probe probe   = gameObject.GetComponentInChildren <Probe>();

            probe.Reset(network.NetworkParameters.InputCount - 1);
            _carController = new NeuralNetworkCarController(car, probe, network);

            CarFollowCamera camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CarFollowCamera>();

            camera.Target = gameObject;

            _fitnessAccumulator = ((IFitnessAccumulatorFactory)Scenes.Data[DataTags.FitnessAccumulatorFactory]).Create(gameObject);
        }
Пример #3
0
        public Car(ICarController controller)
        {
            this.Id = Guid.NewGuid();

            // Set the configuration
            this.Configuration = controller.Configuration;

            // Set the controller for the car
            this.Controller = controller;

            this.fitnessMetrics = new List <Func <Car, float> >();
            this.cullMetrics    = new List <Func <Car, bool> >();

            // Create the containers to hold the raycast visuals that will be updated each frame
            Raycasts = new List <LineSegment>();
            for (int i = 0; i < this.Configuration.NumberOfRays; i++)
            {
                Raycasts.Add(new LineSegment(0, 0, 0, 0));
            }

            this.checkpointManager = new CheckpointManager();

            this.body = new RectangleShape(this.Configuration.CarSize)
            {
                Origin = this.Configuration.CarSize / 2,
            };
        }
Пример #4
0
 public FormController(SqlConnection con)
 {
     connection            = con;
     carController         = new CarController(connection);
     customerController    = new CustomerController(connection);
     reservationController = new ReservationController(connection);
 }
Пример #5
0
    // Init rigidbody, center of mass, wheels and more
    void Start()
    {
#if MULTIOSCONTROLS
        Debug.Log("[ACP] Using MultiOSControls");
#endif


        if (boostClip != null)
        {
            boostSource.clip = boostClip;
        }

        boost = maxBoost;

        _carController = GetComponent <ICarController>();
        _rb            = GetComponent <Rigidbody>();
        spawnPosition  = transform.position;
        spawnRotation  = transform.rotation;

        if (_rb != null && centerOfMass != null)
        {
            _rb.centerOfMass = centerOfMass.localPosition;
        }

        wheels = GetComponentsInChildren <WheelCollider>();

        // Set the motor torque to a non null value because 0 means the wheels won't turn no matter what
        foreach (WheelCollider wheel in wheels)
        {
            wheel.motorTorque = 0.0001f;
        }
    }
Пример #6
0
        public void Init(IGroundSettings settings, ICarController car)
        {
            if (isInitialized)
            {
                return;
            }

            builder = GetComponent <GroundBuilder>();
            builder.Init(settings);

            this.car = car;

            isInitialized = true;
        }
Пример #7
0
    void Awake()
    {
        controller = GetComponent <ICarController>();

        RegisterInputFunctions();
    }
Пример #8
0
 public void RegisterController(ICarController c)
 {
     _controller = c;
 }
Пример #9
0
 public CarCompany()
 {
     InitializeComponent();
     carController     = new CarController();
     companyController = new CompanyController();
 }