player movement

This commit is contained in:
reisenlol 2026-01-04 01:44:17 -08:00
parent 01a1278465
commit 46d2b7bc95
No known key found for this signature in database
18 changed files with 1415 additions and 34 deletions

33
Assets/Scripts/Enemy.cs Normal file
View 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;
}
}