public void DoTaunt() { if (_tauntSounds == null || Time.time <= _nextTauntTime) { return; } AudioClip taunt = _tauntSounds[0]; AudioManager.instance.PlayOneShotSound(_tauntSounds.audioGroup, taunt, transform.position, _tauntSounds.volume, _tauntSounds.spatialBlend, _tauntSounds.priority); if (_soundEmitter != null) { _soundEmitter.SetRadius(_tauntRadius); } _nextTauntTime = Time.time + taunt.length; }
// Set the Trigger to cause screaming public bool Scream() { if (isScreaming) { return(true); } if (_animator == null || IsLayerActive("Cinematic") || _screamPrefab == null) { return(false); } _animator.SetTrigger(_screamHash); Vector3 spawnPos = _screamPosition == AIScreamPosition.Entity ? transform.position : VisualThreat.position; AISoundEmitter screamEmitter = Instantiate(_screamPrefab, spawnPos, Quaternion.identity) as AISoundEmitter; if (screamEmitter != null) { screamEmitter.SetRadius(_screamRadius); } return(true); }
void Update() { if (Input.GetMouseButtonDown(0)) { DoDamage(); } if (_fpsController || _soundEmitter != null) { float newRadius = Mathf.Max(_walkRadius, (100.0f - _health) / _bloodRadiusScale); switch (_fpsController.movementStatus) { case PlayerMoveStatus.Landing: newRadius = Mathf.Max(newRadius, _landingRadius); break; case PlayerMoveStatus.Running: newRadius = Mathf.Max(newRadius, _runRadius); break; } _soundEmitter.SetRadius(newRadius); _fpsController.dragMultiplierLimit = Mathf.Max(_health / 100.0f, 0.25f); } }
private void Update() { if (Input.GetMouseButtonDown(0)) { DoDamage(); } if (_fpsController && _soundEmitter) { //health is brought in here for the zombie to smell the play if damaged float newRadius = Mathf.Max(_walkRadius, (100.0f - _health) / _bloodRadiusScale); switch (_fpsController.movementStatus) { //only assign if the value is bigger than the current value case PlayerMoveStatus.LANDING: newRadius = Mathf.Max(newRadius, _landingRadius); break; case PlayerMoveStatus.RUNNING: newRadius = Mathf.Max(newRadius, _runRadius); break; } _soundEmitter.SetRadius(newRadius); } }
void Update() { Ray ray; RaycastHit hit; RaycastHit[] hits; //Process interactive objects //is the crosshair over a useable item or a descriptive item? first get ray from centre of screen ray = _camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); //calculate ray length float rayLength = Mathf.Lerp(1.0f, 1.8f, Mathf.Abs(Vector3.Dot(_camera.transform.forward, Vector3.up))); //cast ray and collect all hits hits = Physics.RaycastAll(ray, rayLength, _interactiveMask); //process the hits for the one with the highest priority if (hits.Length > 0) { //used to record index of the highest priority int highestPriority = int.MinValue; InteractiveItem priorityObject = null; //Iteracte through each hit for (int i = 0; i < hits.Length; i++) { //process next hit hit = hits[i]; //fetch its interactiveitem sscript from the database InteractiveItem interactiveObject = _gameSceneManager.GetInteractiveItem(hit.collider.GetInstanceID()); //if this is the highest priority object so far then remember it if (interactiveObject != null && interactiveObject.priority > highestPriority) { priorityObject = interactiveObject; highestPriority = priorityObject.priority; } } //if we found an object then display its text and process any possible activation if (priorityObject != null) { if (_playerHUD) { _playerHUD.SetInteractionText(priorityObject.GetText()); } if (Input.GetButtonDown("Use")) { priorityObject.Activate(this); } } } else { if (_playerHUD) { _playerHUD.SetInteractionText(null); } } //are we attacking?! if (Input.GetMouseButtonDown(0) && _ammo > 0) { if (_ammo >= 0) { _ammo -= 1; _shootSound.Play(); DoDamage(); } //_shootSound.Play(); //DoDamage(); } if (Input.GetMouseButtonDown(0) && _ammo <= 0) { _emptyGun.Play(); } if (Input.GetKeyDown("r") && _ammo <= 5 && _ammo >= 0) { _reloadGun.Play(); _ammo = _maxAmmo; print("Bullets currently: " + _ammo); } if (_fpsController && _soundEmitter != null) { //Bloodradius = zombies can smell player when low health! float newRadius = Mathf.Max(_walkRadius, (100.0f - _health) / _bloodRadiusScale); switch (_fpsController.movementStatus) { case PlayerMoveStatus.Landing: newRadius = Mathf.Max(newRadius, _landingRadius); break; case PlayerMoveStatus.Running: newRadius = Mathf.Max(newRadius, _runRadius); break; } _soundEmitter.SetRadius(newRadius); _fpsController.dragMultiplierLimit = Mathf.Max(_health / 100.0f, 0.25f); } Debug.Log("" + _ammo); if (_playerHUD) { _playerHUD.Invalidate(this); } }
void Update() { Ray ray; RaycastHit hit; RaycastHit [] hits; // PROCESS INTERACTIVE OBJECTS // Is the crosshair over a usuable item or descriptive item...first get ray from centre of screen ray = _camera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); // Calculate Ray Length float rayLength = Mathf.Lerp(1.0f, 1.8f, Mathf.Abs(Vector3.Dot(_camera.transform.forward, Vector3.up))); // Cast Ray and collect ALL hits hits = Physics.RaycastAll(ray, rayLength, _interactiveMask); // Process the hits for the one with the highest priorty if (hits.Length > 0) { // Used to record the index of the highest priorty int highestPriority = int.MinValue; InteractiveItem priorityObject = null; // Iterate through each hit for (int i = 0; i < hits.Length; i++) { // Process next hit hit = hits[i]; // Fetch its InteractiveItem script from the database InteractiveItem interactiveObject = _gameSceneManager.GetInteractiveItem(hit.collider.GetInstanceID()); // If this is the highest priority object so far then remember it if (interactiveObject != null && interactiveObject.priority > highestPriority) { priorityObject = interactiveObject; highestPriority = priorityObject.priority; } } // If we found an object then display its text and process any possible activation if (priorityObject != null) { if (_playerHUD) { _playerHUD.SetInteractionText(priorityObject.GetText()); } if (Input.GetButtonDown("Use")) { priorityObject.Activate(this); } } } else { if (_playerHUD) { _playerHUD.SetInteractionText(null); } } // Are we attacking? if (Input.GetMouseButtonDown(0) && Time.time > _nextAttackTime) { DoDamage(); } // Calculate the SoundEmitter radius and the Drag Multiplier Limit if (_fpsController && _soundEmitter != null) { float newRadius = Mathf.Max(_walkRadius, (100.0f - _health) / _bloodRadiusScale); switch (_fpsController.movementStatus) { case PlayerMoveStatus.Landing: newRadius = Mathf.Max(newRadius, _landingRadius); break; case PlayerMoveStatus.Running: newRadius = Mathf.Max(newRadius, _runRadius); break; } _soundEmitter.SetRadius(newRadius); _fpsController.dragMultiplierLimit = Mathf.Max(_health / 100.0f, 0.25f); } // Do Insult if (Input.GetMouseButtonDown(1)) { DoTaunt(); } // Update the Helath and Stamina on the Player HUD if (_playerHUD) { _playerHUD.Invalidate(this); } }