public void RespOfApples() { while (Apples.Count < applesCount) { Apples.Add(new Apple()); foreach (var item in Obstacles) { if (Apples.Last().Collide(item)) { Apples.RemoveAt(Apples.Count - 1); break; } } for (int i = 0; i < Apples.Count; i++) { if (Apples.Last().Collide(Apples[i]) && Apples.Last() != Apples[i]) { Apples.RemoveAt(Apples.Count - 1); break; } } } }
public void SpawnApples() { while (Apples.Count < applesCount) { Apples.Add(new Apple()); foreach (var item in Walls) { if (Apples.Last().CollidesWith(item)) { Apples.RemoveAt(Apples.Count - 1); break; } } for (int i = 0; i < Apples.Count; i++) { if (Apples.Last().CollidesWith(Apples[i]) && Apples.Last() != Apples[i]) { Apples.RemoveAt(Apples.Count - 1); break; } } } }