//Deals with removing health, activating damage animations, and checking if dead then trigger death private void TakeDamage(Damage damage, bool triggerAnimation) { if (damage.DamageValue < 0) { damage.DamageValue = 0; } characterStats.decreaseHealth(damage.DamageValue); //Create a UI Damage Pop up DamagePopUpController.CreateDamagePopUp(damage.DamageValue.ToString(), new Vector2(transform.position.x + ThisCollider.bounds.size.x / 4.0f, transform.position.y + ThisCollider.bounds.size.y / 2.0f), damage.IsCrit, damage.damageType); if (triggerAnimation) { if (ThisAnimator != null) { ThisAnimator.SetTrigger("damage"); // play hit audio if (gameObject.tag == "Player") { gameObject.GetComponent <PlayerControllerScript> ().playHitSound(); } else if (gameObject.tag == "Enemy") { gameObject.GetComponent <Enemy> ().playHitSound(); } } } if (IsDead()) { Die(); } }
/* Damage */ //Deals with removing health, activating damage animations, and checking if dead then trigger death private void TakeDamage(Damage damage) { if (damage.DamageValue > 0) { removeHealth(damage.DamageValue); //Create a UI Damage Pop up DamagePopUpController.CreateDamagePopUp(damage.DamageValue.ToString(), new Vector3(transform.position.x, transform.position.y + ThisCollider.bounds.size.y, transform.position.z), damage.damageType); if (IsDead()) { Die(); } } }
private void InitializeVariables() { DamagePopUpController.Initialize(); }
private void InitializeControllers() { DamagePopUpController.Initialize(); ressourcesController.Initialize(); }