示例#1
0
        public void TakeDamage(float damage)
        {
            _hitPoints -= damage;

            if (_hitPoints <= 0)
            {
                eventChannelSO.RaiseEvent(deathSfx);
                _gameManager.AddScore(1);
                Destroy(gameObject);

                return;
            }

            eventChannelSO.RaiseEvent(hurtSfx);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
            }
        }
示例#5
0
 public void PlayAudioCue()
 {
     _audioCueEventChannel.RaiseEvent(_audioCue, _audioConfiguration, transform.position);
 }
 public override void OnStateEnter()
 {
     _audioCueEventChannel.RaiseEvent(_audioCue, _audioConfiguration, _stateMachineTransform.position);
 }
示例#7
0
 public void PlayFootstep() => _sfxEventChannel.RaiseEvent(footstep, _audioConfig, transform.position);