Example #1
0
    public void LoseHealth(int lossAmount)
    {
        currentHealth -= lossAmount;

        currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth);

        if (currentHealth <= 0)
        {
            OnEntityDeath?.Invoke();
        }
        else
        {
            OnHealthLoss?.Invoke();
        }
    }
Example #2
0
 void SpawnEnemy(string name, Vector3Int Position, Quaternion Rotation)
 {
     try {
         if (FindEntityInPosition(Position) != null)
         {
             return;
         }
         var dt  = GetEntityDataFromName(name);
         var mob = Instantiate(dt.Prefab);
         mob.Initialize(Position, Rotation, dt);
         EntitiesInScene.Add(mob);
         OnNewEntitySpawn?.Invoke(mob);
         var d = mob.GetComponent <EntityDeath>();
         if (d != null)
         {
             d.OnEntityDeath += (e) => { EntitiesInScene.Remove(e); OnEntityDeath?.Invoke(e); }
         }
         ;
     }
     catch (ArgumentOutOfRangeException e) {
     }
 }
Example #3
0
 void Death()
 {
     OnEntityDeath?.Invoke(GetComponent <Entity>());
     GetComponent <Entity>().IsActive = false;
     GetComponent <EntityAnimator>().InvokeAnimation("Death", true);
 }
Example #4
0
 public static void EntityDeath(Entity ent)
 {
     //DebugManager.LogToFile("[OnEntityDeath] " + ent.name + " has died");
     OnEntityDeath?.Invoke(ent);
 }