Example #1
0
        /// <inheritdoc />
        public override void EventTriggered(FootStepSoundEvent eventData)
        {
            var audioSource = eventData.Entity.GetUnityComponent <AudioSource>();

            audioSource.PlayOneShot(_footStepSounds.TakeRandom());
        }
Example #2
0
        /// <inheritdoc />
        public void Setup(IEntity entity)
        {
            var audioSource = entity.GetUnityComponent <AudioSource>();

            _eventSystem.Receive <FootStepSoundEvent>().Subscribe(x => audioSource.PlayOneShot(_footStepSounds.TakeRandom())).AddTo(_disposables);
            _eventSystem.Receive <AttackEvent>().Subscribe(x => audioSource.PlayOneShot(_playerAttackSounds.TakeRandom())).AddTo(_disposables);

            _eventSystem.Receive <PickupEvent>().Subscribe(x =>
            {
                AudioClip pickupSound;

                switch (x.PickupableEntity.GetComponent <FoodComponent>().Type)
                {
                case FoodTypeEnum.Apple:
                    pickupSound = _applePickupSounds.TakeRandom();

                    break;

                case FoodTypeEnum.Soda:
                    pickupSound = _sodaPickupSounds.TakeRandom();

                    break;

                case FoodTypeEnum.Unknown:
                default:

                    throw new ArgumentOutOfRangeException();
                }

                audioSource.PlayOneShot(pickupSound);
            }).AddTo(_disposables);
        }