Ejemplo n.º 1
0
    // When the enemy dies
    void OnDeath()
    {
        scoreManager.AddKill();               // add a kill to the score
        currencyManager.AddSouls(soulsValue); // add souls
        popuptext.SetPopUpText(transform.position, "+" + soulsValue, PopUpText.Types.Souls, new Color(255, 255, 255));

        waveManager.EnemyKilled();

        if (gameModeManager.gameMode == "staying-alive")
        {
            playerEntity.Heal(5, true);
        }

        Vector3    pos       = new Vector3(transform.position.x, transform.position.y + 2f, transform.position.z);
        GameObject particles = Instantiate(deathEffect, pos, Quaternion.identity) as GameObject;

        if (livingEntity.lastHitBy != null && livingEntity.lastHitBy.GetComponent <GunController>().EquippedGun != null)
        {
            particles.transform.rotation = livingEntity.lastHitBy.GetComponent <GunController> ().EquippedGun.transform.rotation;
        }
        else if (GameObject.Find("Player").GetComponent <GunController>().EquippedGun != null)
        {
            particles.transform.rotation = GameObject.Find("Player").GetComponent <GunController> ().EquippedGun.transform.rotation;
        }

        if (drops.IsHoldingItem())
        {
            GameObject weapon = Instantiate(drops.GetHeldItem(), transform.position, Quaternion.identity) as GameObject;
            weapon.GetComponent <ItemObject> ().DropItem();
        }

        unit.target = null;
        Destroy(gameObject);
    }