void OnTriggerEnter(Collider other) { if (other.tag != "Player") { return; } _isNear = true; if (_canBeHacked) { _currentHackButton.Show(); } }
IEnumerator _WrongAnswerCoroutine(HackButton oldButton) { _canBeHacked = false; _currentHackButton = _GenerateHackButton(); yield return(new WaitForSeconds(DisableTimeOnBackHack)); Destroy(oldButton.gameObject); _canBeHacked = true; if (_isNear) { _currentHackButton.Show(); } }
void OnTriggerStay(Collider other) { if (other.tag != "Player") { return; } if (_canBeHacked && _currentHackButton.Hidden) { _currentHackButton.Show(); } if (_HasPressedSomething() && _canBeHacked) { //Instantiate (AudioSourcePrototype).GetComponent<SoundEffectController> ().Play (HackingAudio); if (HasPressedCorrectly()) { _remainingKeysTohack--; _currentHackButton.Correct(); Destroy(_currentHackButton.gameObject, 3); _currentHackButton = _GenerateHackButton(); if (_remainingKeysTohack > 0) { _currentHackButton.Show(); } if (!_isHacking) { _isHacking = true; } if (_retractCoroutine != null) { StopCoroutine(_retractCoroutine); } _retractCoroutine = StartCoroutine(_RetractCoroutine()); } else { Instantiate(AudioSourcePrototype).GetComponent <SoundEffectController> ().Play(FailAudio); _isHacking = false; _currentHackButton.Incorrect(); StartCoroutine(_WrongAnswerCoroutine(_currentHackButton)); _remainingKeysTohack = NumberKeysToHack; } UpdateRemainingKeys(); if (_remainingKeysTohack == 0) { _isHacked = true; Hack(); _hackedMessage.Show(); Instantiate(AudioSourcePrototype).GetComponent <SoundEffectController> ().Play(SuccessAudio); StopCoroutine(_retractCoroutine); if (!CanBeHackedMultipleTimes) { //_currentHackButton.Hide (); //Destroy (this); _canBeHacked = false; } else { _canBeHacked = false; StartCoroutine(HideMessageAfterSeconds()); } } } }