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,8 @@
fileFormatVersion: 2
guid: fba3e9535515c7e87b339b01929aef98
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e041f619639af6b64af518d30f666342
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -25,15 +26,35 @@ public class EntityStats : MonoBehaviour
public Rigidbody2D rb;
public SpriteRenderer sprite;
public bool isFacingRight;
public Color originalColor; //remove later
public float damageColorChangeSpeed;
private void Start()
{
originalColor = sprite.color;
}
public void TakeDamage(float damage)
{
health -= damage;
StartCoroutine(DamageVisual());
if (health <= 0)
{
thisEntity.OnDeath();
}
}
private IEnumerator DamageVisual()
{
float currentState = 0;
while (currentState < 1)
{
currentState += Time.deltaTime * damageColorChangeSpeed;
sprite.color = Color.Lerp(Color.gray, originalColor, currentState);
yield return null;
}
}
public void Heal(float healing)
{
health += healing;

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f2193c612c955cc5bb4fbbe2593ccb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -20,14 +20,7 @@ public class PlayerSwitcher : MonoBehaviour
{
if (Input.GetKeyDown(KeyCode.E) && currentSwitchCooldown <= 0f)
{
if (player1.isActiveAndEnabled)
{
SwitchPlayers(player1, player1AI, player2, player2AI);
}
else
{
SwitchPlayers(player2, player2AI, player1, player1AI);
}
SwitchPlayers(player1, player1AI, player2, player2AI);
currentSwitchCooldown = switchCooldown;
}
@ -45,5 +38,17 @@ public class PlayerSwitcher : MonoBehaviour
playerB.enabled = true;
playerBAI.enabled = false;
(playerB.transform.position, playerAAI.transform.position) = (playerAAI.transform.position, playerB.transform.position);
player1 = playerB;
player1AI = playerBAI;
player2 = playerA;
player2AI = playerAAI;
foreach (Ability ability in playerA.stats.abilities)
{
ability.thisEntity = playerAAI;
}
foreach (Ability ability in playerBAI.stats.abilities)
{
ability.thisEntity = playerB;
}
}
}