entity changes, classes
This commit is contained in:
parent
bda2b88796
commit
8bd4aedcf9
20 changed files with 1917 additions and 27 deletions
|
|
@ -1,7 +1,11 @@
|
|||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
public static event Action<Entity> OnKill;
|
||||
[Header("Enemy Stats")]
|
||||
public int turnSpeed;
|
||||
public float minimumAttackRange;
|
||||
|
|
@ -19,7 +23,7 @@ public class Enemy : Entity
|
|||
closestPlayer = FindClosestPlayer();
|
||||
if (Vector3.Distance(transform.position, closestPlayer.transform.position) > minimumAttackRange)
|
||||
{
|
||||
EnemyMovement.instance.PathfindToTarget(closestPlayer.currentTile.neighbors[Random.Range(0, closestPlayer.currentTile.neighbors.Count)], this);
|
||||
EnemyMovement.instance.PathfindToTarget(GridManager.instance.FindClosestEmptyTile(closestPlayer.currentTile.neighbors[Random.Range(0, closestPlayer.currentTile.neighbors.Count)]), this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -46,13 +50,14 @@ public class Enemy : Entity
|
|||
}
|
||||
return currentClosestPlayer;
|
||||
}
|
||||
protected override void OnKillEffects()
|
||||
protected override void OnKillEffects(Entity attacker)
|
||||
{
|
||||
TurnHandler.instance.enemyEntities.Remove(this);
|
||||
OnKill?.Invoke(attacker);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
public void Attack(PlayerEntity target)
|
||||
{
|
||||
target.TakeDamage(damage);
|
||||
target.TakeDamage(damage, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue