public void Awake() { //TODO: Make a loading scene to wait for data after we send data... finishText = GameObject.Find("Finished").GetComponent <Text> (); //crashText.text = ""; sendData = this.GetComponent <SendData>(); sensors = this.GetComponent <Sensors> (); initialPosition = transform.position; initialRotation = transform.rotation; rb = GetComponent <Rigidbody> (); rb.centerOfMass = centerOfMass; audioSource = GetComponent <AudioSource> (); if (MoveCar.isControlledByAI) { //Change to IEnumerator StartCoroutine(sendData.GetDataFromServer()); } StartAgain(); //Start sending data only when acceleration is pressed for the first time }
void StartAgain() { isFinished = false; audioSource.volume = 0f; Debug.Log("Started again"); //Reset car position transform.position = initialPosition; transform.rotation = initialRotation; finishText.text = ""; begunAccelerating = false; isAccelerating = 0; if (crashed) { Debug.Log("We had crashed"); sensors.ClearList(); } if (shouldSendData) { Debug.Log("Sending data.."); sendData.SendDataToServer(); sensors.ClearList(); shouldSendData = false; Debug.Log("Quit"); Application.LoadLevel("Start"); } else if (MoveCar.isControlledByAI) { //Debug.Log ("started coroutine for getting data"); StartCoroutine(sendData.GetDataFromServer()); } }
public void Awake() { //TODO: Make a loading scene to wait for data after we send data... finishText = GameObject.Find ("Finished").GetComponent<Text> (); //crashText.text = ""; sendData = this.GetComponent<SendData>(); sensors = this.GetComponent<Sensors>(); initialPosition = transform.position; initialRotation = transform.rotation; rb = GetComponent<Rigidbody> (); rb.centerOfMass = centerOfMass; audioSource = GetComponent<AudioSource> (); if (MoveCar.isControlledByAI) { //Change to IEnumerator StartCoroutine(sendData.GetDataFromServer()); } StartAgain (); //Start sending data only when acceleration is pressed for the first time }