private void Start() { _vehicleInput = GetComponent <VehicleInput>(); //InvokeRepeating("healthCooldown", 0, healFreq); healthCurrent = healthMax; gradient = new Gradient(); // Populate the color keys at the relative time 0 and 1 (0 and 100%) colorKey = new GradientColorKey[1]; colorKey[0].color = vignetteColor; colorKey[0].time = 0.0f; // Populate the alpha keys at relative time 0 and 1 (0 and 100%) alphaKey = new GradientAlphaKey[2]; alphaKey[0].alpha = 1.0f; alphaKey[0].time = 0.0f; alphaKey[1].alpha = 0.0f; alphaKey[1].time = 1.0f; gradient.SetKeys(colorKey, alphaKey); _carBodyHolder = GetComponent <Rigidbody>(); raycastCarHolder = GetComponent <RaycastCar>(); _carCollider = raycastCarHolder.GetComponent <Collider>(); _objectPooler = ObjectPooler.instance; }
private void OnTriggerEnter(Collider other) { RaycastCar temp = other.GetComponent <RaycastCar>(); if (isSecondTrigger == false) { if (temp != null) { if ((DataManager.instance.playerInfo[temp.playerID - 1].placeRace1 > previousPlace)) { DataManager.instance.playerInfo[temp.playerID - 1].placeRace1 = place; previousPlace++; place++; } if (DataManager.instance.playerInfo[temp.playerID - 1].isActive) { humansFinish++; } if (humansFinish >= numHumans) { // give all AI that havent finshed yet a time float previousTime = rm.time; for (int i = 0; i < DataManager.instance.playerInfo.Length; i++) { //If they haven't finished the race yet if (DataManager.instance.playerInfo[i].placeRace1 == 3 && DataManager.instance.playerInfo[i].timerRace1 == 0f) { previousTime = supplyTime(i, previousTime, true); place++; } } } } } else if (isSecondTrigger == true) { if (temp != null) { temp.finished = true; if (place == 0) { if (temp.GetComponent <VehicleInput>()) { if (numHumans > 1) { hm.setNumNodes(temp.GetComponent <RaycastCar>().closestIndex); StartCoroutine(hm.EndGameCountDown(hm.countdownLength)); } } else { StartCoroutine(hm.EndGameCountDown(hm.countdownLength)); } } if ((DataManager.instance.playerInfo[temp.playerID - 1].placeRace2 > previousPlace)) { DataManager.instance.playerInfo[temp.playerID - 1].placeRace2 = place; DataManager.instance.playerInfo[temp.playerID - 1].timerRace2 = rm.time; previousPlace++; place++; if (DataManager.instance.playerInfo[temp.playerID - 1].isActive) { humansFinish++; hm.incrementHumansFinished(); } if (humansFinish >= numHumans) { // give all AI that havent finshed yet a time float previousTime = rm.time; for (int i = 0; i < DataManager.instance.playerInfo.Length; i++) { //If they haven't finished the race yet if (DataManager.instance.playerInfo[i].placeRace2 == 3 && DataManager.instance.playerInfo[i].timerRace2 == 0f) { previousTime = supplyTime(i, previousTime, false); place++; } } hm.EndGame(); } } } } }