Exemplo n.º 1
0
    public FoodSourceBehaviour GetClosestFoodSource(Vector3 position)
    {
        var min_distance           = double.PositiveInfinity;
        FoodSourceBehaviour answer = null;

        foreach (var source in foodSources)
        {
            var cur_distance = Vector3.Distance(position, source.transform.position);
            if (cur_distance < min_distance)
            {
                answer       = source;
                min_distance = cur_distance;
            }
        }

        return(answer);
    }
Exemplo n.º 2
0
 public void Unregister(FoodSourceBehaviour source)
 {
     foodSources.Remove(source);
 }
Exemplo n.º 3
0
 public void Register(FoodSourceBehaviour source)
 {
     foodSources.Add(source);
 }