void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("RacePlayer")) { if (!firstP1) { firstP1 = true; return; } if (firstP1) { currentLaps++; updateLaps(currentLaps, totalLaps); } if (currentLaps >= totalLaps && player1.GetComponent <CarController>().getPoints() > 75) { winRace(); } if (currentLaps >= totalLaps && player1.GetComponent <CarController>().getPoints() < 75) { Debug.Log("Pérdida por trampa"); lostRace(); } if (currentLaps != 0) { gameManager.PlaySound("Lap"); } } if (other.gameObject.CompareTag("RacePlayer2")) { if (!firstP2) { firstP2 = true; return; } if (firstP2) { currentLapsP2++; } if (currentLapsP2 >= totalLaps) { lostRace(); } } if (other.gameObject.CompareTag("RacePlayer3")) { if (!firstP3) { firstP3 = true; return; } if (firstP3) { currentLapsP3++; } if (currentLapsP3 >= totalLaps) { lostRace(); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Oil")) { if (rainTire != 1) { accelerationPower = 8f; gameManager.PlaySound("Oil"); } } /* * * if (other.gameObject.CompareTag("PeopleLeft")){ * other.gameObject.GetComponent<SpriteRenderer>().color = Color.red; * gameObject.transform.position = new Vector3(10000,0,0); * * camera.GetComponent<CameraFollow>().changeFollow(); * other.GetComponent<RacePeopleController>().dontMove(); * ambulance.GetComponent<RaceAmbulanceController>().callAmbulance(other.gameObject.GetComponent<Transform>()); * * } */ if (other.gameObject.CompareTag("Ruta1")) { other.gameObject.GetComponent <SpriteRenderer>().color = Color.red; gameObject.transform.position = new Vector3(10000, 0, 0); player2.transform.position = new Vector3(10000, 0, 0); player3.transform.position = new Vector3(10000, 0, 0); //ambulance.GetComponent<Transform>().rotation *= Quaternion.Euler(0,180f,0); camera.GetComponent <CameraFollow>().changeFollow(); other.GetComponent <RacePeopleController>().dontMove(); ambulance.GetComponent <RaceNewAmbulanceController>().callAmbulance("Ruta1"); } if (other.gameObject.CompareTag("Ruta2")) { other.gameObject.GetComponent <SpriteRenderer>().color = Color.red; gameObject.transform.position = new Vector3(10000, 0, 0); player2.transform.position = new Vector3(10000, 0, 0); player3.transform.position = new Vector3(10000, 0, 0); //ambulance.GetComponent<Transform>().rotation *= Quaternion.Euler(0,180f,0); camera.GetComponent <CameraFollow>().changeFollow(); other.GetComponent <RacePeopleController>().dontMove(); ambulance.GetComponent <RaceNewAmbulanceController>().callAmbulance("Ruta2"); } if (other.gameObject.CompareTag("Ruta3")) { other.gameObject.GetComponent <SpriteRenderer>().color = Color.red; gameObject.transform.position = new Vector3(10000, 0, 0); player2.transform.position = new Vector3(10000, 0, 0); player3.transform.position = new Vector3(10000, 0, 0); //ambulance.GetComponent<Transform>().rotation *= Quaternion.Euler(0,180f,0); camera.GetComponent <CameraFollow>().changeFollow(); other.GetComponent <RacePeopleController>().dontMove(); ambulance.GetComponent <RaceNewAmbulanceController>().callAmbulance("Ruta3"); } }