more abilities and fixes

This commit is contained in:
Sylvia 2026-06-12 03:54:49 -07:00
parent cb4470f2d6
commit fc2329a873
31 changed files with 268 additions and 52 deletions

View file

@ -0,0 +1,39 @@
using UnityEngine;
public class Ability : MonoBehaviour
{
[Header("Identification")]
public string abilityName;
public Entity thisEntity;
[Header("Cooldown")]
protected float currentCooldown;
public float cooldown;
[Header("Stats")]
public float power;
public Vector3 targetLocation;
protected virtual void Update()
{
if (currentCooldown > 0f)
{
currentCooldown -= Time.deltaTime;
}
}
public bool TryAbility()
{
if (currentCooldown <= 0f)
{
AbilityEffects();
currentCooldown = cooldown;
Debug.Log($"Ability {abilityName} SUCCESS");
return true;
}
Debug.Log($"Ability {abilityName} ON COOLDOWN");
return false;
}
protected virtual void AbilityEffects()
{
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 977830b8cdc83e63a8cb158ab84c0d0d

View file

@ -0,0 +1,22 @@
using Core.Extensions;
using UnityEngine;
public class ShootBullet : Ability
{
[SerializeField] private Projectile projectile;
[SerializeField] private float projectileSpeed;
[SerializeField] private float projectileLifetime;
[SerializeField] private int pierceAmount;
protected override void AbilityEffects()
{
base.AbilityEffects();
Projectile newProjectile = Instantiate(projectile, thisEntity.transform.position, projectile.transform.rotation);
newProjectile.owner = thisEntity;
newProjectile.tag = thisEntity.tag;
newProjectile.speed = projectileSpeed;
newProjectile.damage = power;
newProjectile.lifetime = projectileLifetime;
newProjectile.pierceAmount = pierceAmount;
newProjectile.transform.Lookat2D(thisEntity.stats.attackOriginPoint.position); //targetLocation);
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c2e841223273eee80837e20d27430787

View file

@ -0,0 +1,24 @@
using UnityEngine;
public class SwordSlash : Ability
{
public LayerMask entityLayer;
//probably will change out entity detection. or will i?
//i'd also probably have to offset the damage origin direction
public float damageRadius;
protected override void AbilityEffects()
{
base.AbilityEffects();
Collider2D[] entitiesFound = Physics2D.OverlapCircleAll(thisEntity.stats.attackOriginPoint.position, damageRadius, entityLayer);
foreach (Collider2D entityFound in entitiesFound)
{
if (!entityFound.CompareTag(thisEntity.tag))
{
if (entityFound.TryGetComponent(out Entity isEntity))
{
isEntity.stats.TakeDamage(power);
}
}
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 68c3a1cc2e61de7f4a20126c2d48b4b5