public GridElement[] GetNeighboursOfElement(GridElement findNeighboursOf, NeighboutAccessType neighboutAccess = NeighboutAccessType.LiveAndDeadBoth) { List <GridElement> neigbours = new List <GridElement>(); foreach (GridIndexPath neighbourIndexPath in findNeighboursOf.neighbours) { GridElement element = GetGridElementAtIndex(neighbourIndexPath); switch (neighboutAccess) { case NeighboutAccessType.OnlyDead: if (!element.IsLive()) { neigbours.Add(element); } break; case NeighboutAccessType.OnlyLive: if (element.IsLive()) { neigbours.Add(element); } break; case NeighboutAccessType.LiveAndDeadBoth: neigbours.Add(element); break; } } return(neigbours.ToArray()); }