Example #1
0
        public void GivePlayerFlipToken()
        {
            UnitDeathEvent deathEvent = new UnitDeathEvent
            {
                UnitGameObject   = gameObject,
                EventDescription = "Unit " + gameObject.name + " has died."
            };

            SoundEvent soundEvent = new SoundEvent
            {
                EventDescription = "Noise " + deathNoise + " is playing.",
                UnitGameObject   = this.gameObject,
                audioSource      = audioSource,
                sound            = deathNoise
            };

            ParticleEvent particleEvent = new ParticleEvent
            {
                EventDescription = "Particles " + deathParticles + " is playing.",
                UnitGameObject   = this.gameObject,
                particles        = deathParticles
            };

            events.Add(soundEvent);
            events.Add(particleEvent);
            events.Add(deathEvent);

            canGiveToken = true;
        }
        private void OnTriggerEnter(Collider other)
        {
            if (other.CompareTag("Player"))
            {
                SoundEvent soundevent = new SoundEvent();
                soundevent.sound = pickupSound;
                soundevent.FireEvent();

                Debug.Log("collision");
                //add to counter
                CanvasController.Instance.addPickup();
                ParticleSystem particleInstance = Instantiate(onPickUpParticles, transform.position, Quaternion.identity);
                Destroy(particleInstance.gameObject, 2.5f);
                Destroy(gameObject);
            }
        }
Example #3
0
        void OnUnitDied(SoundEvent soundEvent)
        {
            Debug.Log("Sound playing: " + soundEvent.sound);

            if (soundEvent.sound != null)
            {
                if (soundEvent.audioSource != null)
                {
                    tempAudioSource = Instantiate(soundEvent.audioSource,
                                                  soundEvent.UnitGameObject.transform.position,
                                                  soundEvent.UnitGameObject.transform.rotation);

                    tempAudioSource.PlayOneShot(soundEvent.sound);

                    tempAudioSource.GetComponent <ObjectDestroyer>().SetLifeTime(soundEvent.sound.length);
                }
            }
        }
Example #4
0
 void Start()
 {
     SoundEvent.RegisterListener(OnSound);
     audiosource = GetComponent <AudioSource>();
 }
Example #5
0
 void OnSound(SoundEvent soundPlay)
 {
     Debug.Log("SoundisPlaying");
     audiosource.PlayOneShot(soundPlay.sound);
 }
Example #6
0
 void OnDestroy()
 {
     SoundEvent.UnregisterListener(OnSound);
 }