// 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); }
public void Heal(float amount, bool startingHealthIsMax) { health += amount; // Prevents the player from over-healing by capping the health if (startingHealthIsMax) { if (health >= startingHealth) { health = startingHealth; } else { popUpText.SetPopUpText(transform.position, "+" + amount, PopUpText.Types.Default, new Color(0, 255, 0), 4); } } }