// Kill all zombies in a wave and destroy it
    public void DestroyWave(int wave_id)
    {
        var list = GetWaveListByID(wave_id);

        // Return if the wave does not exist
        if (list == null)
        {
            return;
        }

        // Else kill all zombies in the wave
        // First obtain the zombies helth scripts
        List <ZombieHealth> zombieHealths = new List <ZombieHealth>();

        foreach (GameObject zomb in list)
        {
            ZombieHealth zhl = zomb.GetComponent <ZombieHealth>();
            zombieHealths.Add(zhl);
        }

        // Then kill all the zombies
        foreach (var zhl in zombieHealths)
        {
            zhl.Damage(zhl.health * 2);
        }

        // Then remove the whole KVP from the kvp array
        zombies_wawes.Remove(new KeyValuePair <int, List <GameObject> >(wave_id, list));
    }
示例#2
0
    private void HandleDamage(ZombieHealth zombieHealth)
    {
        if (zombieHealth == null)
        {
            return;
        }

        float health = 0;

        switch (SettingsHandler.cache.dificulty)
        {
        case Difficulty.Easy:
            health = zombieHealth.Health / 1.5f;
            break;

        case Difficulty.Hard:
            health = zombieHealth.Health / .9f;
            break;

        case Difficulty.Extreme:
            health = zombieHealth.Health / .8f;
            break;

        default:
            health = zombieHealth.Health;
            break;
        }

        armorPenetration = Mathf.Clamp(armorPenetration - (kinetic ? zombieHealth.Armor / 2f : zombieHealth.Armor), 0, Mathf.Infinity);
        zombieHealth.Damage(damage + armorPenetration);
        damage -= Mathf.Clamp(health - armorPenetration, 0f, Mathf.Infinity);
        if (damage > 0f)
        {
            if (debug)
            {
                Debug.Log("Bullet Pierced");
            }
            else
            if (debug)
            {
                Debug.Log("Bullet Bounced");
            }
        }
    }