コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            foreach (EnemyBase eb in enemyBases)
            {
                if (eb.life <= 0)
                {
                    QueueDestroy(eb);
                    explosionManager.AddExplosion(Game, eb.loc);
                }
            }
            foreach (EnemyBase eb in enemyBasesToBeDestroyed)
            {
                Destroy(eb);
            }
            enemyBasesToBeDestroyed.Clear();

            base.Update(gameTime);
        }
コード例 #2
0
        void HandleCollisions()
        {
            foreach (Bullet b in ship.gun.bulletManager.bullets)
            {
                foreach (Enemy e in enemyManager.enemies)
                {
                    if (b.Intersects(e))
                    {
                        if (b.IntersectPixels(e))
                        {
                            enemyManager.QueueDestroyEnemy(e);
                            ship.gun.bulletManager.QueueDestroyBullet(b);
                            explosionManager.AddExplosion(Game, b.loc);
                            MGLib.ScoreKeeper.addScore(100);
                        }
                    }
                }
                foreach (EnemyBase eb in this.enemyBaseManager.enemyBases)
                {
                    if (b.Intersects(eb))
                    {
                        if (b.IntersectPixels(eb))
                        {
                            ship.gun.bulletManager.QueueDestroyBullet(b);
                            explosionManager.AddExplosion(Game, b.loc);
                            eb.Damage();
                            MGLib.ScoreKeeper.addScore(100);
                        }
                    }
                }
                foreach (Asteroid a in this.asteroidManager.asteroids)
                {
                    if (b.Intersects(a))
                    {
                        if (b.IntersectPixels(a))
                        {
                            ship.gun.bulletManager.QueueDestroyBullet(b);
                            explosionManager.AddExplosion(Game, b.loc);
                            asteroidManager.QueueDestroy(a);
                            MGLib.ScoreKeeper.addScore(10);
                        }
                    }
                }
            }

            foreach (Enemy e in enemyManager.enemies)
            {
                if (e.Intersects(ship))
                {
                    if (e.IntersectPixels(ship))
                    {
                        enemyManager.QueueDestroyEnemy(e);
                        explosionManager.AddExplosion(Game, e.loc);
                        KillPlayer();
                    }
                }
                foreach (Asteroid a in asteroidManager.asteroids)
                {
                    if (a.Intersects(e))
                    {
                        enemyManager.QueueDestroyEnemy(e);
                        explosionManager.AddExplosion(Game, e.loc);
                        asteroidManager.QueueDestroy(a);
                        MGLib.ScoreKeeper.addScore(100);
                    }
                }
            }

            foreach (Asteroid a in asteroidManager.asteroids)
            {
                if (a.Intersects(ship))
                {
                    explosionManager.AddExplosion(Game, ship.loc);
                    asteroidManager.QueueDestroy(a);
                    KillPlayer();
                }
            }

            foreach (EnemyBase eb in this.enemyBaseManager.enemyBases)
            {
                if (eb.Intersects(ship))
                {
                    if (eb.IntersectPixels(ship))
                    {
                        explosionManager.AddExplosion(Game, ship.loc);
                        KillPlayer();
                    }
                }
            }

            foreach (Wall w in boundary.Walls)
            {
                if (w.Intersects(ship))
                {
                    explosionManager.AddExplosion(Game, ship.loc);
                    KillPlayer();
                }
            }
        }