this idiot forgot to commit an entire month's worth of code

This commit is contained in:
Sylvia 2026-04-22 18:23:31 -07:00
parent c67146ea1a
commit a3321d361c
51 changed files with 3644 additions and 84 deletions

View file

@ -13,6 +13,7 @@ public class Enemy : Entity
public float currentCooldown;
}
public static event Action OnDamaged;
public static event Action OnKill;
[Header("Targetting")]
public Entity closestTarget;
public float engagementRange;
@ -22,8 +23,8 @@ public class Enemy : Entity
public Transform[] possibleDirections;
public float forwardPercent;
public float strafePercent;
private float xSign = -1f;
private float ySign = 1f;
protected float xSign = -1f;
protected float ySign = 1f;
[System.Serializable]
public class UpgradeDrop
@ -37,6 +38,11 @@ public class Enemy : Entity
[Header("Abilities")]
[SerializeField] private Ability[] allAbilities;
[Header("Levels")]
[SerializeField] private float levelHealthBuff;
[SerializeField] private float levelPowerBuff;
public float powerBuffAmount;
private void Start()
{
if (Random.Range(0f, 2f) > 1f)
@ -44,16 +50,21 @@ public class Enemy : Entity
xSign = -xSign;
ySign = -ySign;
}
//set hp and dmg values
maxHealth = baseMaxHealth * (EnemySpawner.instance.enemyLevel * levelHealthBuff);
health = maxHealth;
powerBuffAmount = EnemySpawner.instance.enemyLevel * levelPowerBuff;
}
private void Update()
protected virtual void Update()
{
if (detectedPlayer)
{
Ability foundAbility = null;
foreach (Ability availableAbility in allAbilities)
{
if (foundAbility == null && availableAbility.currentCooldown <= 0 && availableAbility.ability.range < Vector3.Distance(closestTarget.transform.position, transform.position))
float targetDistance = Vector3.Distance(closestTarget.transform.position, transform.position);
if (foundAbility == null && availableAbility.currentCooldown <= 0 && availableAbility.ability.maxRange > targetDistance && availableAbility.ability.minRange < targetDistance)
{
foundAbility = availableAbility;
}
@ -100,7 +111,7 @@ public class Enemy : Entity
directionToMove = directionToPoint;
}
}
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed), acceleration);
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed * speedMultiplier), acceleration);
FlipSprite(directionToMove);
}
}

View file

@ -28,7 +28,7 @@ public class EnemyFireBullet : EnemyAbility
newProjectile.owner = owner;
newProjectile.pierceAmount = pierceAmount;
newProjectile.damage = power;
newProjectile.damage = power * owner.powerBuffAmount;
newProjectile.speed = projectileSpeed;
newProjectile.lifetime = bulletLifetime;
newProjectile.transform.Rotate(0, 0, Random.Range(-accuracy, accuracy));

View file

@ -0,0 +1,17 @@
using UnityEngine;
[CreateAssetMenu(fileName = "New Enemy Rush Ability", menuName = "EnemyAbilities/Rush")]
public class EnemyRushAbility : EnemyAbility
{
[SerializeField] private Effect speedEffect;
public override void UseAbility(Entity target, Enemy owner)
{
Debug.Log("ability activated");
if (owner.speedMultiplier < 1.10f)
{
Debug.Log("affect applied");
speedEffect.ApplyEffect(owner);
}
//owner.closestTarget =
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 489701e947dc0bf818f370f0fa7734aa

View file

@ -36,9 +36,12 @@ public class EnemySpawner : MonoBehaviour
[SerializeField] private Transform bossHealthBar;
[SerializeField] private TextMeshProUGUI bossHealthText;
[SerializeField] private TextMeshProUGUI bossNameText;
[Header("Difficulty Scaling")]
public float levelUpIntervals;
public int enemyLevel;
[Header("Cache")]
[SerializeField] private Transform enemyFolder;
[SerializeField] private Marisa player;
public Marisa player;
private void Update()
{
@ -51,13 +54,14 @@ public class EnemySpawner : MonoBehaviour
SpawnEnemy(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], spawnPoints[Random.Range(0, spawnPoints.Count)].position);
}
}
else if (!canSpawn && bossEnemy)
else if (!canSpawn && bossEnemy.health < 0)
{
if (Input.GetKey(KeyCode.E))
{
LevelSwitcher.instance.LoadShop();
}
}
enemyLevel = (int)(Time.time / levelUpIntervals); //figure out the time.time thing because that's not gonna work here
}
public Enemy SpawnEnemy(Enemy enemy, Vector3 location)

View file

@ -0,0 +1,58 @@
using Core.Extensions;
using UnityEngine;
public class RusherEnemy : Enemy
{
private bool isRushing;
public Vector2 lastTargetLocation;
public Vector2 lastTargetDirection;
protected override void Update()
{
base.Update();
if (speedMultiplier <= 1.10f && closestTarget)
{
lastTargetLocation = closestTarget.transform.position;
lastTargetDirection = (lastTargetLocation - (Vector2)transform.position).normalized;
}
}
protected override void FixedUpdate() //this is really bad.
{
if (!detectedPlayer && Vector3.Distance(transform.position, lastTargetLocation) < engagementRange)
{
detectedPlayer = true;
}
if (stalled || !closestTarget || !detectedPlayer)
{
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
}
else if (speed > 1.10f && closestTarget)
{
rb.VelocityTowards(lastTargetDirection.ScaleToMagnitude(speed * speedMultiplier), acceleration);
}
else
{
Vector2 directionToTarget = (lastTargetLocation - (Vector2)transform.position).normalized;
Vector2 directionToMove = directionToTarget;
float currentHighestScore = float.NegativeInfinity;
Vector2 strafeDirection = new Vector3(directionToTarget.y * ySign, directionToTarget.x * xSign);
foreach (Transform direction in possibleDirections)
{
Vector3 directionToPoint = (direction.position - transform.position).normalized;
float forwardScore = Vector3.Dot(directionToPoint, directionToTarget);
float strafeScore = Vector3.Dot(directionToPoint, strafeDirection);
float finalScore = (forwardScore * forwardPercent) + (strafeScore * strafePercent);
//Debug.Log($"Forward: {forwardScore} Strafe: {strafeScore} Final: {finalScore}");
if (finalScore > currentHighestScore)
{
//Debug.Log($"{finalScore} is higher than current score: {currentHighestScore}");
currentHighestScore = finalScore;
directionToMove = directionToPoint;
}
}
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed * speedMultiplier), acceleration);
FlipSprite(directionToMove);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8f7666f7f9e3cad958069b3b00bd6879