示例#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;
        }
示例#2
0
文件: Health.cs 项目: webthingee/LD42
        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);
        }
示例#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);
        }
示例#4
0
 // Use this for initialization
 void Start()
 {
     UnitDeathEvent.RegisterListener(OnUnitDied);
 }
示例#5
0
 void OnUnitDied(UnitDeathEvent unitDeath)
 {
     Debug.Log("Alerted about unit death: " + unitDeath.UnitGO.name);
 }
示例#6
0
 void OnDestroy()
 {
     UnitDeathEvent.UnregisterListener(OnUnitDied);
 }
示例#7
0
 void OnUnitDied(UnitDeathEvent unitDeathInfo)
 {
     Debug.Log("Unit: " + unitDeathInfo.UnitGameObject.name + " has died");
     Destroy(unitDeathInfo.UnitGameObject);
 }