public void Injure(int dmg, GameObject who) { RPG.InjurePlayer(dmg); RPG.FloatingTextAbove(transform, dmg.ToString(), Color.red, 2); RPGSounds.Instance.PlayHitSound(); if (who != null) { knockback.Knockback(who.transform.position, gameObject.transform.position, 10); /*Vector3 direction=(transform.position-who.transform.position); * direction.y=0; * direction.Normalize(); * direction.y=+1; * knockback.Knockback(direction*5); * Debug.Log("player kb:"+direction);*/ } }
public void Damage(int amount) { if (hp <= 0) { return; } RPG.FloatingTextAbove(transform, amount.ToString(), Color.yellow, 4); hp -= amount; //health.enabled=true; // turn on the healthbar health.Value = (float)hp / maxHP; if (hp <= 0) { GetComponent <Animation>().CrossFade("death"); //Destroy(health,3); Destroy(knock, 4); gameObject.AddComponent <FlickerThenVanish>(); // will get rid of it } }