Пример #1
0
    public IEnumerable <float> IntermediateDistances()
    {
        float sum = 0f;

        foreach (VillageCtrl neighbor in home.neighbors)
        {
            sum += Vector2.Distance(home.GetPosition(), neighbor.GetPosition());
            yield return(sum);
        }
    }
Пример #2
0
    /// <summary>
    /// We're just checking to make sure that a given village doesn't
    /// sit right on top of another one.
    /// </summary>
    public bool NoOverlaps(VillageCtrl village)
    {
        List <VillageCtrl> neighbors = worldMap.GetNeighbors(village.GetPosition());

        foreach (VillageCtrl neighbor in neighbors)
        {
            if (village.GetRect().Overlaps(neighbor.GetRect()))
            {
                return(false);
            }
        }

        return(true);
    }