LunarInfantry/Assets/Scripts/OfficerAbilities.cs
2026-01-26 01:06:40 -08:00

52 lines
1.1 KiB
C#

using System;
using UnityEngine;
public class OfficerAbilities : ClassAbility
{
[Header("Kills")]
[SerializeField] private int killQuota;
private int currentKills;
[Header("Length")]
[SerializeField] private int abilityLength;
[SerializeField] private int roundsRemaining;
private void Start()
{
Enemy.OnKill += UpdateKillQuota;
TurnHandler.waveUpdate += UpdateRounds;
}
private void UpdateKillQuota(Entity entity)
{
if (entity == thisEntity)
{
currentKills++;
currentKills = Mathf.Clamp(currentKills, 0, killQuota);
}
}
private void UpdateRounds()
{
if (roundsRemaining > 0)
{
roundsRemaining--;
if (roundsRemaining <= 0)
{
DeactivateAbility();
}
}
}
public override void TryAbility()
{
if (currentKills >= killQuota)
{
currentKills = 0;
roundsRemaining = abilityLength;
AbilityEffects();
}
}
protected virtual void DeactivateAbility()
{
}
}