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 Die() { // I am dying for some reason. UnitDeathEvent udei = new UnitDeathEvent(); udei.description = "Unit " + gameObject.name + " has died."; udei.unitGO = gameObject; udei.FireEvent(); Destroy(gameObject); }
void Die() { // I am dying for some reason. UnitDeathEvent ude = new UnitDeathEvent(); ude.EventDescription = "Unit " + gameObject.name + " has died."; ude.UnitGO = gameObject; // fire the event like so: EventSystem <UnitDeathEvent> .FireEvent(ude); Destroy(gameObject); }
// Use this for initialization void Start() { UnitDeathEvent.RegisterListener(OnUnitDied); }
void OnUnitDied(UnitDeathEvent unitDeath) { Debug.Log("Alerted about unit death: " + unitDeath.UnitGO.name); }
void OnDestroy() { UnitDeathEvent.UnregisterListener(OnUnitDied); }
void OnUnitDied(UnitDeathEvent unitDeathInfo) { Debug.Log("Unit: " + unitDeathInfo.UnitGameObject.name + " has died"); Destroy(unitDeathInfo.UnitGameObject); }