void Start() { stats = GetComponent <Stats>(); anim = GetComponent <Animator>(); body = GetComponent <Rigidbody2D>(); weapon_sheath = GetComponent <weaponSheath>(); }
public void modHp(float deltaHp) { if (_glitchValue != null) { _glitchValue.modGlitch(deltaHp); } currentHealth += deltaHp; if (deltaHp < 0) //if the entity is losing health, play damage particles { hit_particle.Play(); } if (currentHealth <= 0) { //drop weapon if any weaponSheath sheath = gameObject.GetComponent <weaponSheath>(); if (sheath != null) //dont assume all entities will have a weapon sheath { weaponController old_weapon = sheath.equiped_weapon.GetComponent <weaponController>(); if (old_weapon != null) { old_weapon.set_drop_mode(); } } for (int i = 0; i < Random.Range(2, 6); i++) //drop some coins //ALSO RANDOMIZE POSITION { Instantiate(Resources.Load("gold_coin"), transform.position, transform.rotation); } Destroy(this.gameObject); //THIS IS VERY BAD, especially for players, fix later } else if (currentHealth > baseHealth) { currentHealth = baseHealth; } //cant go over max hp }