private void TimeToLive() { List <EnemyPicture> listOfEnemies = EnemySpawner.GetListOfEnemies(); foreach (var enemy in listOfEnemies) { if (enemy.LifeCounter > 450) { enemy.Dispose(); } } }
private void CheckForCollision() { var listOfEnemies = EnemySpawner.GetListOfEnemies(); var listOfPlayers = PlayerSprite.GetPlayerSprites(); var player = listOfPlayers.First <PlayerSprite>(); foreach (var enemyPicture in listOfEnemies) { if (enemyPicture.Bounds.IntersectsWith(player.Bounds) && enemyPicture.Visible) { enemyPicture.Dispose(); Player.Health = Player.Health - 1; } } }