public void UpdateEnergy() { if (gameObject.tag == "Player") { return; } if (m_energy.GetValue() == 0) { Destroy(gameObject); } }
public void UpdateHealth() { if (m_health.GetValue() > 0) { return; } if (gameObject.tag == "Player") { if (!m_is_base_player) { m_controller.ChangePlayer(Game.reserve_player); Game.player.transform.position = transform.position; Game.player.gameObject.SetActive(true); Game.player.m_controller = m_controller; Destroy(gameObject); } return; } //Enemies do this. Instantiate(m_death_effect_prefab, transform.position, Quaternion.identity); Vector3 drop_pos; foreach (ItemDrop d in m_drop_table) { if (Random.value * 100 < d.chance) { drop_pos = transform.position + new Vector3(Random.Range(-1, 2), 0, Random.Range(-1, 2)); Instantiate(d.item, drop_pos, Quaternion.identity); } } foreach (GEntity e in GameObject.FindObjectsOfType <GEntity>()) { e.NotifyOfDeath(this); } Destroy(gameObject); }