1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Entities/Mob.cs

37 lines
682 B
C#
Raw Normal View History

2018-04-21 16:55:39 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2018-04-21 17:27:28 +02:00
public abstract class Mob : Entity {
readonly int maxHP;
int currentHP;
bool isDead;
2018-04-21 16:55:39 +02:00
2018-04-21 17:27:28 +02:00
// Constructor
public Mob(EntityObjective referringObjective, int maxHP) : base(referringObjective)
{
this.maxHP = maxHP;
currentHP = maxHP;
isDead = false;
}
// inflicts damage to this mob
public void InflictDamage(int damage)
{
currentHP -= damage;
if (!isDead && currentHP <= 0)
{
base.Kill ();
isDead = true;
}
2018-04-21 16:55:39 +02:00
}
2018-04-21 17:27:28 +02:00
// Heals the mob
public void Heal(int healAmount)
{
if (!isDead)
currentHP = (currentHP + healAmount > currentHP) ? maxHP : currentHP + healAmount;
2018-04-21 16:55:39 +02:00
}
}