コード例 #1
0
        private void CheckCollisions(GameTime gameTime)
        {
            Vector2 terrainCollisionPoint = bg.CheckTerrainCollision(_rocket);
            Vector2 playerCollisionPoint  = Toolbox.CheckPlayersCollision(this.players, this.currentPlayer, _rocket);
            Vector2 birdCollisionPoint    = checkBirdsCollision();

            bool rocketOutOfScreen = CheckOutOfScreen();

            if (playerCollisionPoint.X > -1)
            {
                Rocket.rocketFlying = false;

                _rocket.smokeList = new List <Vector2>();
                AddExplosion(playerCollisionPoint, 10, 80.0f, 2000.0f, gameTime);

                NextPlayer();
            }

            if (terrainCollisionPoint.X > -1)
            {
                Rocket.rocketFlying = false;

                _rocket.smokeList = new List <Vector2>();
                AddExplosion(terrainCollisionPoint, 4, 30.0f, 1000.0f, gameTime);
                soundCenter.HitTerrain.Play();
                NextPlayer();
            }

            if (birdCollisionPoint.X > -1)
            {
                Rocket.rocketFlying = false;
                Console.WriteLine("bird collision");
                AddExplosion(birdCollisionPoint, 4, 30.0f, 1000.0f, gameTime);
                soundCenter.HitTerrain.Play();
                NextPlayer();
            }

            if (rocketOutOfScreen)
            {
                Rocket.rocketFlying = false;
                _rocket.smokeList   = new List <Vector2>();
                NextPlayer();
            }
        }