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