player movement
This commit is contained in:
parent
01a1278465
commit
46d2b7bc95
18 changed files with 1415 additions and 34 deletions
33
Assets/Scripts/Enemy.cs
Normal file
33
Assets/Scripts/Enemy.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
public int turnSpeed;
|
||||
public int minimumAttackRange;
|
||||
private PlayerEntity closestPlayer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
turnSpeed = Random.Range(0, 100);
|
||||
}
|
||||
|
||||
public void StartTurn()
|
||||
{
|
||||
//attack the nearest player?
|
||||
TurnHandler.instance.UpdateTurns();
|
||||
closestPlayer = FindClosestPlayer();
|
||||
}
|
||||
|
||||
private PlayerEntity FindClosestPlayer()
|
||||
{
|
||||
PlayerEntity currentClosestPlayer = null;
|
||||
foreach (PlayerEntity player in TurnHandler.instance.playerEntities)
|
||||
{
|
||||
if (!currentClosestPlayer || Vector3.Distance(player.transform.position, transform.position) < Vector3.Distance(currentClosestPlayer.transform.position, transform.position))
|
||||
{
|
||||
currentClosestPlayer = player;
|
||||
}
|
||||
}
|
||||
return currentClosestPlayer;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue