private void Restart() { CameraTarget tractor = character.GetComponentInChildren <CameraTarget>(); //Находим грузовик BlowController blowController = character.GetComponentInChildren <BlowController>(); blowController.DestroyBoxes(); blowController.HasMoney = 0; if (tractor != null) { foreach (var button in buttonsAddTrailer) { button.ExitRace(); } if (PlayerPrefs.HasKey("StartCarPos")) { if (first) { tractor.transform.position = carLevelPos[PlayerPrefs.GetInt("StartCarPos")].position; tractor.transform.rotation = carLevelPos[PlayerPrefs.GetInt("StartCarPos")].rotation; } else//Из гаража { tractor.transform.position = beforeGaragePosition; tractor.transform.rotation = beforeGarageRotation; } } else//Первый запуск { tractor.transform.position = carLevelPos[0].position; tractor.transform.rotation = carLevelPos[0].rotation; } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.name.Substring(0, 2) == "TE") { if (activ) //finish { bool first = true; //Чтобы один и тот же грузовик не въехал 2 раза на финиш foreach (var nam in enemyNames) { if (other.gameObject.name == nam) { first = false; } } if (first) { enemyNames[prize - 1] = other.gameObject.name; prize += 1; } } } if (other.gameObject.name == "Traktor")//+ при переходе из гаража { PlayerPrefs.SetInt("StartCarPos", id); Debug.LogWarning("Tractor collider Enter"); if (other.GetComponent <CharacterJoint>() == null) { selectCarController.raceStart = this; truckPos.position = other.transform.position; MapCamera.SetActive(false); SetPanelState(true); axisCarController = other.gameObject.GetComponent <AxisCarController>(); axisCarController.InStation = true; gamePanel.alpha = 0; gamePanel.enabled = false; StartCoroutine(ShowStationMenu(finishPanel.animation.clip.length)); UIButton[] enableButtons = stationPanel.GetComponentsInChildren <UIButton>(); foreach (var eb in enableButtons) { eb.isEnabled = true; } } else { if (activ)//finish { if (other.gameObject.GetComponent <CharacterJoint>() != null) { selectCarController.raceStart = this; truckPos.position = other.transform.position; MapCamera.SetActive(false); SetPanelState(true); axisCarController = other.gameObject.GetComponent <AxisCarController>(); axisCarController.InStation = true; finishPanel.transform.position = Vector3.zero; finishPanel.enabled = true; gamePanel.alpha = 0; gamePanel.enabled = false; price = (int)(price * other.gameObject.GetComponent <BlowController>().Condition / 100); if (prize == 1) { resultLabel.text = "1-st"; buttonAddTrailer.Medal = 0; } if (prize == 2) { resultLabel.text = "2-nd"; price = (int)(price * 0.7f); buttonAddTrailer.Medal = Mathf.Min(1, buttonAddTrailer.Medal); } if (prize == 3) { resultLabel.text = "3-rd"; price = (int)(price * 0.6f); buttonAddTrailer.Medal = Mathf.Min(2, buttonAddTrailer.Medal); } if (prize == 4) { resultLabel.text = "4-th"; price = (int)(price * 0.5f); } if (prize == 5) { resultLabel.text = "5-th"; price = (int)(price * 0.4f); } addGoldLabel.text = price.ToString("f0"); buttonOk.GetComponent <UIButton>().isEnabled = true; StartCoroutine(AddGold(1)); prize = 1; for (int i = 0; i < enemyNames.Length; i++) { enemyNames[i] = ""; } baggageLabel.bonusPosCtrl.DeleteBonuses(); BlowController blowController = other.gameObject.GetComponent <BlowController>(); blowController.DestroyBoxes(); hasMoneyLabel.text = blowController.HasMoney.ToString("f0"); StartCoroutine(AddGoldForMoney(blowController.HasMoney, 2.5f)); blowController.HasMoney = 0; } } } } }