Esempio n. 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;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     UnitDeathEvent.RegisterListener(OnUnitDied);
 }
Esempio n. 5
0
 void OnUnitDied(UnitDeathEvent unitDeath)
 {
     Debug.Log("Alerted about unit death: " + unitDeath.UnitGO.name);
 }
Esempio n. 6
0
 void OnDestroy()
 {
     UnitDeathEvent.UnregisterListener(OnUnitDied);
 }
Esempio n. 7
0
 void OnUnitDied(UnitDeathEvent unitDeathInfo)
 {
     Debug.Log("Unit: " + unitDeathInfo.UnitGameObject.name + " has died");
     Destroy(unitDeathInfo.UnitGameObject);
 }