private void Update() { if (_isNearTorch && Input.GetKeyDown(KeyCode.E)) { // If torch has been lit up, remove health points to torch if (!isLit) { TorcheJoueur torche = _player.gameObject.GetComponentInChildren <TorcheJoueur>(); if (torche.torchLife <= 10) { _uiManager.AddWarningMessageToQueue("Votre torche n'est pas assez puissante"); } else { _uiManager.ChangeUIText(isLit ? notLitText : litText); // Disable or activate light and fire particles _light.gameObject.SetActive(true); _fireParticles.gameObject.SetActive(true); torche.RemoveLifeFromTorch(3); } } else { _uiManager.ChangeUIText(isLit ? notLitText : litText); _light.gameObject.SetActive(false); _fireParticles.gameObject.SetActive(false); } isLit = !isLit; } }
private void OnTriggerExit(Collider other) { if (other.tag == "Player") { _playerLeftOnce = true; _playerInBase = false; Inventory inv = other.gameObject.GetComponent <Inventory>(); if (inv._hasTorch) { TorcheJoueur torche = other.gameObject.GetComponentInChildren <TorcheJoueur>(); torche.StartTorchLosing(); } _soundManager.PlaySoundTrack(); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { _playerInBase = true; Inventory inv = other.gameObject.GetComponent <Inventory>(); if (inv._hasTorch) { TorcheJoueur torche = other.gameObject.GetComponentInChildren <TorcheJoueur>(); torche.StopTorchLosing(); } if (_playerLeftOnce) { PlayerBackToBase(); } _soundManager.PauseSoundTrack(); } }