basically the whole game
This commit is contained in:
parent
949135cecb
commit
96dcfa9064
315 changed files with 34386 additions and 396 deletions
58
Assets/Scripts/Abilities/EnemyTackle.cs
Normal file
58
Assets/Scripts/Abilities/EnemyTackle.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class EnemyTackle : EnemyAbility
|
||||
{
|
||||
private Vector3 originalPosition;
|
||||
private Vector3 movePosition;
|
||||
[SerializeField] private Enemy thisEnemy;
|
||||
public float distanceToReturn;
|
||||
public float distanceToDamage;
|
||||
private bool isCloseToPlayer;
|
||||
private bool returning;
|
||||
[Header("Speeds")]
|
||||
[SerializeField] private float tackleSpeed;
|
||||
[SerializeField] private float returnSpeed;
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
returning = false;
|
||||
thisEnemy.onTakeDamage += ReturnToPosition;
|
||||
originalPosition = transform.position;
|
||||
movePosition = WaveManager.instance.GetRandomPlayerPoint();
|
||||
thisEnemy.isStalled = true;
|
||||
thisEnemy.preventWobble = true;
|
||||
StopCoroutine(thisEnemy.currentMovementRoutine);
|
||||
thisEnemy.currentMovementRoutine = StartCoroutine(thisEnemy.MoveToPosition(originalPosition, movePosition, tackleSpeed));
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (!returning)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, movePosition) < distanceToReturn && !isCloseToPlayer)
|
||||
{
|
||||
isCloseToPlayer = true;
|
||||
}
|
||||
else if (isCloseToPlayer && Vector3.Distance(transform.position, movePosition) < distanceToDamage)
|
||||
{
|
||||
WaveManager.instance.player.TakeDamage(power);
|
||||
ReturnToPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReturnToPosition()
|
||||
{
|
||||
thisEnemy.onTakeDamage -= ReturnToPosition;
|
||||
returning = true;
|
||||
if (thisEnemy.currentMovementRoutine != null)
|
||||
{
|
||||
StopCoroutine(thisEnemy.currentMovementRoutine);
|
||||
}
|
||||
thisEnemy.preventWobble = false;
|
||||
thisEnemy.isStalled = true;
|
||||
thisEnemy.currentMovementRoutine = StartCoroutine(thisEnemy.MoveToPosition(transform.position, originalPosition, returnSpeed));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue