37 lines
758 B
C#
37 lines
758 B
C#
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
public class VampireEntity : Entity {
|
|
[SerializeField] [field: Required]
|
|
PlayerStats playerStats = null!;
|
|
|
|
[SerializeField] [Required]
|
|
HealthBar healthBar;
|
|
[Min(10f)]
|
|
float initialHealth;
|
|
|
|
protected override void Start() {
|
|
base.Start();
|
|
base.entityName = "Vampire";
|
|
|
|
initialHealth = Health;
|
|
}
|
|
|
|
protected override void Update() {
|
|
base.Update();
|
|
|
|
if (gameFlowManager.Paused)
|
|
return;
|
|
|
|
TakeDamage(playerStats.bloodLossRate * Time.deltaTime);
|
|
}
|
|
|
|
public override bool TakeDamage(float amount) {
|
|
bool stillAlive = base.TakeDamage(amount);
|
|
healthBar.SetHealthFraction(Health / initialHealth);
|
|
|
|
return stillAlive;
|
|
}
|
|
|
|
protected override void OnDied() => gameFlowManager.GameOver();
|
|
} |