private void CheckForCollisions() { IEnumerable <EnemyShip> collisions = AllObjects .Select((m) => m as EnemyShip) .Where((m) => CollidesWith(m)); foreach (EnemyShip enemy in collisions) { enemy.Explode(); } }
private void Shoot() { IEnumerable <Cannon> cannons = AllObjects .Select((m) => m as Cannon) .Where((m) => m != null); foreach (Cannon cannon in cannons) { cannon.Shoot(); } }
private void CheckForPowerUps() { IEnumerable <PowerUp> pups = AllObjects .Select((m) => m as PowerUp) .Where((m) => CollidesWith(m)); foreach (PowerUp pup in pups) { if (pup != null) { pup.ApplyOn(this); } } }
private void CheckForPowerUps() { PowerUp[] pups = AllObjects.Select(m => m as PowerUp).ToArray(); foreach (PowerUp pup in pups) { if (pup != null) { if (CollidesWith(pup)) { pup.ApplyOn(this); } } } }
private bool CheckForCollision() { IEnumerable <EnemyShip> collisions = AllObjects .Select((m) => m as EnemyShip)//Cambie el lugar, esto estaba abajo del primer where .Where((m) => CollidesWith(m)) .Where((m) => m != null); if (collisions.Count() == 0) { return(false); } foreach (EnemyShip enemy in collisions) { enemy.Explode(); } return(true); }
private void CheckForCollision()//Aplicar la misma optimizacion que la nave { EnemyShip[] EnemyCollisions = AllObjects.Select(m => m as EnemyShip).Where(m => m != null).ToArray(); if (EnemyCollisions.Count() == 0) { return; } foreach (var enemy in EnemyCollisions) { if (CollidesWith(enemy)) { enemy.Explode(); Delete(); } } }
private bool CheckForCollision() { EnemyShip[] EnemyCollisions = AllObjects.Select(m => m as EnemyShip).Where(m => m != null).ToArray(); if (EnemyCollisions.Count() == 0) { return(false); } foreach (var enemy in EnemyCollisions) { if (CollidesWith(enemy)) { enemy.Explode(); return(true); } } return(false); }