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); } }
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); } } }
void Start() { SoundEvent.RegisterListener(OnSound); audiosource = GetComponent <AudioSource>(); }
void OnSound(SoundEvent soundPlay) { Debug.Log("SoundisPlaying"); audiosource.PlayOneShot(soundPlay.sound); }
void OnDestroy() { SoundEvent.UnregisterListener(OnSound); }