예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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);
                }
            }
        }
예제 #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);
                    }
                }
            }
        }
예제 #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);
        }
예제 #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();
                }
            }
        }
예제 #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);
        }