Example #1
0
        private void CheckForCollisions()
        {
            IEnumerable <EnemyShip> collisions = AllObjects
                                                 .Select((m) => m as EnemyShip)
                                                 .Where((m) => CollidesWith(m));

            foreach (EnemyShip enemy in collisions)
            {
                enemy.Explode();
            }
        }
Example #2
0
        private void Shoot()
        {
            IEnumerable <Cannon> cannons = AllObjects
                                           .Select((m) => m as Cannon)
                                           .Where((m) => m != null);

            foreach (Cannon cannon in cannons)
            {
                cannon.Shoot();
            }
        }
Example #3
0
        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);
                }
            }
        }
Example #4
0
        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);
                    }
                }
            }
        }
Example #5
0
        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);
        }
Example #6
0
        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();
                }
            }
        }
Example #7
0
        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);
        }