TheKingsRace/Assets/Scripts/KingScripts/KingAbility.cs
Katherine 0655b86352 King Abilities/Radial Menu bugfixes
>Radial Menu has been bugfixed so the players have a harder time
breaking things
>King abilities have had some repeated code moved into a seperate class
2022-02-23 13:18:54 -06:00

54 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KingAbility
{
public int CooldownTimer;
private int CooldownLength;
private int FramestoSeconds = 0;
private bool Avaliable = true;
private int EnergyCost;
public KingAbility() {
CooldownLength = 3;
CooldownTimer = CooldownLength;
EnergyCost = 20;
}
public KingAbility(int cooldown, int energy) {
CooldownLength = cooldown;
CooldownTimer = CooldownLength;
EnergyCost = energy;
}
public void Cooldown() {
if (Avaliable == false) {
FramestoSeconds++;
if (FramestoSeconds == 50) {
FramestoSeconds = 0;
CooldownTimer--;
if (CooldownTimer == 0) {
CooldownTimer = CooldownLength;
Avaliable = true;
}
}
}
}
public void UseItem() {
Avaliable = false;
}
public bool IsAvaliable() {
return Avaliable;
}
public int Energy() {
return EnergyCost;
}
}