/// <summary> /// Обновление позиции на экране для каждого из элементов массива объектов фона /// </summary> public static void Update() { Message mess = new Message(PrintLog); foreach (BaseObject obj in objectInSpace) { obj.Update(); } foreach (Bullet b in bullets) { b.Update(); } for (int i = 0; i < objectInSpace.Count; i++) { objectInSpace[i].Update(); if (ship.Collision(objectInSpace[i])) { ship?.LowEnergy(rnd.Next(1, 10)); if (ship.Energy <= 0) { ship?.Die(); } if (objectInSpace[i] as FirstAidKit != null) { ship?.UpEnergy(rnd.Next(5, 10)); } } for (int j = 0; j < bullets.Count && objectInSpace.Count > 0; j++) { try { if (bullets[j].Collision(objectInSpace[i])) { mess?.Invoke(objectInSpace[i].GetType().ToString()); crash.Play(); if (objectInSpace[i] as FirstAidKit != null) { ship.DownScore(200); } else { ship.UpScore(100); } objectInSpace.RemoveAt(i); bullets.RemoveAt(j); } } catch { j = bullets.Count; } } if (objectInSpace.Count == 0) { Load(++countGoals); ship.ResetScore(); ship.ResetEnergy(); } } }