Ejemplo n.º 1
0
        private void OnBulletHitCharacter(BulletComponent bullet, CharacterComponent character)
        {
            character.Hit();
            if (character.CurrentHealth <= 0 && bullet.Source != null)
            {
                bullet.Source.Player.IncrementScore((bullet.Source == character) ? -1 : 1);

                //GameObject go = PrefabFactory.Pop("bulletexplode");
                //go.transform.position = bullet.transform.position;
                //this.DelayAction(8, () => PrefabFactory.Push("bulletexplode", go));

                GameObject explode = PrefabFactory.Pop("vfxexplode");
                explode.transform.position = bullet.transform.position + (UnityEngine.Camera.main.transform.position - bullet.transform.position).normalized;
                this.DelayAction(5, () => PrefabFactory.Push("vfxexplode", explode));

                GameObject shock = PrefabFactory.Pop("shockwave");
                shock.transform.position = bullet.transform.position;
                shock.transform.LookAt(UnityEngine.Camera.main.transform);
                this.DelayAction(2.2f, () => PrefabFactory.Push("shockwave", shock));

                string     sfxName = Random.Range(0f, 1f) > 0.5 ? "sfxdeath1" : "sfxdeath2";
                GameObject sfx     = PrefabFactory.Pop(sfxName);
                sfx.transform.position = bullet.transform.position;
                this.DelayAction(4f, () => PrefabFactory.Push(sfxName, sfx));
            }

            PrefabFactory.Push("bullet", bullet.gameObject);
        }