LunarInfantry/Assets/Scripts/OfficerAbilities.cs
2026-01-23 00:55:00 -08:00

58 lines
1.2 KiB
C#

using System;
using UnityEngine;
public class OfficerAbilities : MonoBehaviour
{
public PlayerEntity thisEntity;
[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 void ActivateAbility()
{
if (currentKills >= killQuota)
{
currentKills = 0;
roundsRemaining = abilityLength;
AbilityEffects();
}
}
protected virtual void AbilityEffects()
{
}
protected virtual void DeactivateAbility()
{
}
}