35 lines
853 B
C#
35 lines
853 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class YoumuDeflect : Ability
|
|
{
|
|
private List<Projectile> projectilesInRange = new();
|
|
|
|
protected override void AbilityEffects()
|
|
{
|
|
base.AbilityEffects();
|
|
foreach (Projectile projectile in projectilesInRange)
|
|
{
|
|
projectile.transform.eulerAngles = new Vector3(0, 0, 180);
|
|
projectile.direction = -transform.right;
|
|
projectile.tag = tag;
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|