27 lines
668 B
C#
27 lines
668 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 Vector2I Goal()
|
|
{
|
|
Map map = _pegController._playArea._map;
|
|
List<Peg> enemies = [.. _pegController._pegs.Where(p => p._disposition == -_disposition)];
|
|
if (enemies.Count == 0)
|
|
{
|
|
return _address;
|
|
}
|
|
List<Vector2I> closest = [.. enemies.OrderBy(e => (e._address - _address).Length()).Select(e => e._address)];
|
|
return closest[0];
|
|
}
|
|
}
|