You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Fight;
|
|
|
|
public static class FightUtils
|
|
{
|
|
public static int GetEnteredAmount(this FightWorld.EnemyGroup self)
|
|
{
|
|
return self.enemies.Count(e => e.IsAlive() && e.entered);
|
|
}
|
|
|
|
public static bool TryGetFirstUnenteredFighter(this FightWorld.EnemyGroup self, out FightWorld.Fighter fighter)
|
|
{
|
|
foreach (var f in self.enemies.Where(e=>!e.entered && e.IsAlive()))
|
|
{
|
|
fighter = f;
|
|
return true;
|
|
}
|
|
|
|
fighter = null!;
|
|
return false;
|
|
}
|
|
|
|
public static bool IsAlive(this FightWorld.Fighter self)
|
|
{
|
|
return self.GetHealth() >= 0;
|
|
}
|
|
|
|
public static bool IsDead(this FightWorld.Fighter self)
|
|
{
|
|
return !self.IsAlive();
|
|
}
|
|
|
|
public static int GetHealth(this FightWorld.Fighter self)
|
|
{
|
|
return self.health ?? self.maxHealth;
|
|
}
|
|
|
|
public static bool AreAllDead(this FightWorld.EnemyGroup self)
|
|
{
|
|
return self.enemies.All(e => e.IsDead());
|
|
}
|
|
|
|
} |