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,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = UnityEngine.Random;
public class YoumuDeflect : Ability
{
private List<Projectile> projectilesInRange = new();
public float deflectionAngleMin = -48;
public float deflectionAngleMax = 90;
[Header("Effects")]
[SerializeField] private ParticleSystem deflectionParticles;
[SerializeField] private GameObject swordSweepEffect;
private float currentDissipationTime = 0f;
[SerializeField] private float dissipationTime;
protected override void AbilityEffects()
{
base.AbilityEffects();
swordSweepEffect.gameObject.SetActive(true);
currentDissipationTime = dissipationTime;
foreach (Projectile projectile in projectilesInRange.ToList())
{
if (!projectile)
{
projectilesInRange.Remove(projectile);
continue;
}
projectile.transform.eulerAngles = new Vector3(0, 0, Random.Range(deflectionAngleMin, deflectionAngleMax));
projectile.direction = projectile.transform.right;
projectile.tag = tag;
ParticleSystem newParticles = Instantiate(deflectionParticles, projectile.transform);
projectilesInRange.Remove(projectile);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
{
projectilesInRange.Add(isProjectile);
}
}
protected override void Update()
{
base.Update();
if (currentDissipationTime > 0)
{
currentDissipationTime -= Time.deltaTime;
if (currentDissipationTime <= 0)
{
swordSweepEffect.SetActive(false);
}
}
}
}