alot of stuff i forgot to commit
This commit is contained in:
parent
fc2329a873
commit
b8d516e734
60 changed files with 7397 additions and 64 deletions
46
Assets/Scripts/Abilities/Parry.cs
Normal file
46
Assets/Scripts/Abilities/Parry.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Parry : Ability
|
||||
{
|
||||
public List<Projectile> projectilesInRange = new();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
transform.Lookat2D(thisEntity.attackOriginPoint.position);
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
foreach (Projectile projectile in projectilesInRange.ToList())
|
||||
{
|
||||
if (!projectile)
|
||||
{
|
||||
projectilesInRange.Remove(projectile);
|
||||
continue;
|
||||
}
|
||||
projectile.transform.eulerAngles = new Vector3(0, 0, 180);
|
||||
projectile.direction = -projectile.transform.right * projectile.speed;
|
||||
projectile.tag = thisEntity.tag;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Projectile isProjectile))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
|
||||
{
|
||||
projectilesInRange.Remove(isProjectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue