26 lines
618 B
C#
26 lines
618 B
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class Spearman : FriendlyPeg
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
_stamina = 2;
|
|
_visibility = 4;
|
|
}
|
|
|
|
public override MapCell Goal()
|
|
{
|
|
Dictionary<Vector2I, MapCell> enemies = GetVisibleEnemies();
|
|
if (enemies.Count == 0)
|
|
{
|
|
return _cell;
|
|
}
|
|
Dictionary<Vector2I, MapCell> closest = enemies.OrderBy(e => (e.Value._occupant._address - _address).Length()).ToDictionary();
|
|
return closest.ElementAt(0).Value;
|
|
}
|
|
}
|