full turns
This commit is contained in:
parent
7bd61df481
commit
6ff1531662
15 changed files with 879 additions and 100 deletions
|
|
@ -3,9 +3,10 @@ using UnityEngine;
|
|||
public class Enemy : Entity
|
||||
{
|
||||
public int turnSpeed;
|
||||
public int minimumAttackRange;
|
||||
public float minimumAttackRange;
|
||||
private PlayerEntity closestPlayer;
|
||||
|
||||
//no weapons yet for enemies so...
|
||||
public float damage;
|
||||
void Start()
|
||||
{
|
||||
turnSpeed = Random.Range(0, 100);
|
||||
|
|
@ -14,10 +15,22 @@ public class Enemy : Entity
|
|||
[ContextMenu("ForceTurn")]
|
||||
public void StartTurn()
|
||||
{
|
||||
TurnHandler.instance.UpdateTurns();
|
||||
closestPlayer = FindClosestPlayer();
|
||||
Debug.Log(closestPlayer);
|
||||
EnemyMovement.instance.PathfindToTarget(closestPlayer.currentTile.neighbors[Random.Range(0, closestPlayer.currentTile.neighbors.Count)], this);
|
||||
if (Vector3.Distance(transform.position, closestPlayer.transform.position) > minimumAttackRange)
|
||||
{
|
||||
EnemyMovement.instance.PathfindToTarget(closestPlayer.currentTile.neighbors[Random.Range(0, closestPlayer.currentTile.neighbors.Count)], this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Attack(closestPlayer);
|
||||
TurnHandler.instance.UpdateTurns();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FinishedMovement()
|
||||
{
|
||||
base.FinishedMovement();
|
||||
TurnHandler.instance.UpdateTurns();
|
||||
}
|
||||
|
||||
private PlayerEntity FindClosestPlayer()
|
||||
|
|
@ -32,4 +45,13 @@ public class Enemy : Entity
|
|||
}
|
||||
return currentClosestPlayer;
|
||||
}
|
||||
protected override void OnKillEffects()
|
||||
{
|
||||
TurnHandler.instance.enemyEntities.Remove(this);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
public void Attack(PlayerEntity target)
|
||||
{
|
||||
target.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue