Ejemplo n.º 1
0
 private void ApplyItem(Item item)
 {
     if (item.RestoreHealth.HasValue)
     {
         Health = Mathf.Min(Health + item.RestoreHealth.Value, MaxHealth);
         AudioUtils.Play("HealUp", 7.0f);
     }
     if (item.ExplosionForce.HasValue)
     {
         ExplosionFactory.Create(item.Position, item.ExplosionForce.Value);
     }
     if (item.ApplyBuff != null)
     {
         buffs.Add(item.ApplyBuff);
     }
     if (item.ApplyEffect != null)
     {
         effects.Add(item.ApplyEffect);
     }
 }
Ejemplo n.º 2
0
        protected void Die(DamageInfo dmgInfo)
        {
            float oldLife = currentLife;

            currentLife -= dmgInfo.Damage;
            lifeBar.transform.localScale = new Vector3(currentLife / life * 0.5f / transform.localScale.x,
                                                       lifeBar.transform.localScale.y,
                                                       lifeBar.transform.localScale.z);

            if (currentLife < 0.1f)
            {
                ExplosionFactory.Create(transform.position, 1.0f);
                AudioUtils.Play("ZombieDeath", transform.position);

                BloodFactory.SplatFromDamageInfo(dmgInfo);
                GameStatistics.AddKill(dmgInfo.PlayerNumber, this);

                Destroy(this.gameObject);
                switch (enemyType)
                {
                case EnemyType.Regular:
                    Item.CreateRandom(transform.position);
                    break;

                case EnemyType.Boss:
                    var        tileset = (GameObject.Find("Map")).GetComponent <Assets.Scripts.Map.Map>().tilesets;
                    GameObject stairs  = (GameObject)Instantiate(tileset[Assets.Scripts.Map.Tile.Type.Exit][0],
                                                                 transform.position,
                                                                 Quaternion.identity);
                    stairs.transform.SetParent(map.transform);
                    break;
                }
            }
            else
            {
                AudioUtils.Play(damageSound, transform.position, 10.0f);
            }
        }
Ejemplo n.º 3
0
        void Die(float damage)
        {
            if (IsImmune)
            {
                return;
            }

            Health -= damage;

            const float IMMUNITY_TIME_S = 1.0f;

            IsImmune = true;
            Invoke("StopImmunity", IMMUNITY_TIME_S);

            if (Health <= 0.0f)
            {
                AudioUtils.BackgroundMusic.Stop();
                ExplosionFactory.Create(transform.position, 3.0f);

                DetachCamera();
                AudioUtils.Play("GameOver", 15.0f);
                Destroy(this.gameObject);
            }
        }