random stuff i forgot to commit

This commit is contained in:
Sylvia 2026-06-26 14:37:33 -07:00
parent 274af1e5a1
commit b0625ae834
59 changed files with 7806 additions and 664 deletions

View file

@ -0,0 +1,69 @@
using System;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
public class Enemy : Entity
{
public SpriteRenderer sprite;
private float currentState = 1;
public float colorChangeSpeed;
[Header("Movement")]
private float currentMovement;
public float moveSpeed;
public float moveSpeedDelta;
private void Start()
{
moveSpeed += Random.Range(-moveSpeedDelta, moveSpeedDelta);
}
private void Update()
{
if (!isStalled)
{
foreach (Ability ability in abilities)
{
ability.direction = WaveManager.instance.GetRandomPlayerPoint();
bool success = ability.TryAbility();
if (!success && ability.currentCooldown <= 0.5f && currentState >= 1f)
{
currentState = 0f;
StartCoroutine(ImminentAttackAnim());
}
}
}
}
protected override void OnDeath()
{
base.OnDeath();
Destroy(gameObject);
WaveManager.instance.enemiesInPlay.Remove(this);
WaveManager.instance.UpdateKills();
}
private IEnumerator ImminentAttackAnim()
{
while (currentState < 1)
{
currentState += Time.deltaTime * colorChangeSpeed;
sprite.color = Color.Lerp(Color.red, Color.white, currentState);
yield return null;
}
}
public IEnumerator MoveToPosition(Vector3 moveDirection)
{
while (currentMovement < 1)
{
currentMovement += Time.deltaTime * moveSpeed;
if (currentMovement >= 1)
{
isStalled = false;
}
transform.position = Vector3.Lerp(WaveManager.instance.enemySpawnPoint.position, moveDirection, currentMovement);
yield return null;
}
}
}