public void TakeDamage(float damage) { _hitPoints -= damage; if (_hitPoints <= 0) { eventChannelSO.RaiseEvent(deathSfx); _gameManager.AddScore(1); Destroy(gameObject); return; } eventChannelSO.RaiseEvent(hurtSfx); }
public void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } var body = other.GetComponent <Body>(); if (hairPrefabs.Length > 0) { var hairPrefab = hairPrefabs[Random.Range(0, hairPrefabs.Length - 1)]; body.SetBodyPart(Bodypart.Hair, hairPrefab); } if (scarfPrefabs.Length > 0) { var scarfPrefab = scarfPrefabs[Random.Range(0, scarfPrefabs.Length - 1)]; body.SetBodyPart(Bodypart.Scarf, scarfPrefab); } if (chassisPrefabs.Length > 0) { var chassisPrefab = chassisPrefabs[Random.Range(0, chassisPrefabs.Length - 1)]; body.SetBodyPart(Bodypart.Chassis, chassisPrefab); } audioEventChannel.RaiseEvent(pickupSound); gameObject.SetActive(false); }
public void OnTriggerEnter(Collider other) { if (!other.CompareTag("Player")) { return; } var body = other.GetComponent <Body>(); body.SetBodyPart(bodypart, prefab); audioEventChannel.RaiseEvent(pickupSound); gameObject.SetActive(false); }
public void Fire() { if (!CanFire()) { return; } eventChannelSO.RaiseEvent(shootSfx); _lastFireTime = Time.time; for (var i = 0; i < bulletsPerShot; i++) { var projectile = Instantiate(bulletPrefab, bulletSpawnPoint.position, bulletSpawnPoint.rotation); projectile.transform.Rotate(Vector3.up * Random.Range(-spread / 2f, spread / 2f)); Destroy(projectile, 5f); } }
public void PlayAudioCue() { _audioCueEventChannel.RaiseEvent(_audioCue, _audioConfiguration, transform.position); }
public override void OnStateEnter() { _audioCueEventChannel.RaiseEvent(_audioCue, _audioConfiguration, _stateMachineTransform.position); }
public void PlayFootstep() => _sfxEventChannel.RaiseEvent(footstep, _audioConfig, transform.position);