ReisenTasker/Assets/Scripts/Entity/Abilities/Ability.cs

46 lines
932 B
C#

using System;
using Core.Extensions;
using UnityEngine;
public class Ability : MonoBehaviour
{
[Header("Flags")]
public bool cooldownBlocked;
public bool blocked;
[Header("Cooldown")]
public float cooldown;
protected float currentCooldown;
[Header("Stats")]
public float power;
public bool TryAbility()
{
if (!blocked && currentCooldown <= 0)
{
currentCooldown = cooldown;
AbilityEffects();
return true;
}
return false;
}
protected virtual void AbilityEffects()
{
}
private void Update()
{
if (currentCooldown > 0 && !cooldownBlocked)
{
currentCooldown -= Time.deltaTime;
}
}
protected void ShootBullet(Projectile projectile, Vector3 direction)
{
Projectile newProjectile = Instantiate(projectile, transform.position, Quaternion.identity);
newProjectile.transform.Lookat2D(direction);
newProjectile.tag = tag; //will have to figure out stats and projectile creation
}
}