Example #1
0
    private void OnCollisionEnter(Collision collision)
    {
        GameOverComponent gameOverComponent = collision.gameObject.GetComponent <GameOverComponent>();

        if (gameOverComponent != null)
        {
            SetDamage(gameOverComponent.Contact());
        }
    }
Example #2
0
        /// <summary>
        /// Initializes all the gameScenes.
        /// Sets the menuScene as the active scene.
        /// </summary>
        private void Initialize()
        {
            // creating background components
            PlanetBackgroundComponent        planetBackground        = new PlanetBackgroundComponent(game);
            PlanetExplodeBackgroundComponent planetExplodeBackground = new PlanetExplodeBackgroundComponent(game);
            PlanetRingsBackgroundCompnent    planetRingsBackground   = new PlanetRingsBackgroundCompnent(game);

            // creating window components
            TopTenComponent         topTen         = new TopTenComponent(game);
            GameWonComponent        gameWon        = new GameWonComponent(game);
            GameOverComponent       gameOver       = new GameOverComponent(game);
            PlayerSettingsComponent playerSettings = new PlayerSettingsComponent(game);
            MenuItemsComponent      menuItems      = new MenuItemsComponent(game, new Vector2(700, 250), Color.Red, Color.Yellow);

            // Listing menu options. Room to grow if we want more options.
            menuItems.AddItem("Play");
            menuItems.AddItem("Top Scores");
            menuItems.AddItem("Player Settings");
            menuItems.AddItem("Quit");
            MenuComponent menu = new MenuComponent(game, menuItems);

            // Assigns music
            soundManager.SetDeepSpaceMusic(game.Content.Load <Song>(@"Sounds\DeepSpace"));
            soundManager.SetMegalovaniaMusic(game.Content.Load <Song>(@"Sounds\Megalovania"));
            soundManager.SetSolarSystemMusic(game.Content.Load <Song>(@"Sounds\Solar System"));
            soundManager.SetMenuBGMusic(game.Content.Load <Song>(@"Sounds\MenuBG"));

            // Assigns sound effects
            soundManager.SetGunShotSound(game.Content.Load <SoundEffect>(@"Sounds\gunShot"));
            soundManager.SetExplosionSound(game.Content.Load <SoundEffect>(@"Sounds\explosion"));
            soundManager.SetExplosion1Sound(game.Content.Load <SoundEffect>(@"Sounds\explosion1"));
            soundManager.SetExplosion2Sound(game.Content.Load <SoundEffect>(@"Sounds\explosion2"));
            soundManager.SetExplosionAggressiveSound(game.Content.Load <SoundEffect>(@"Sounds\explosion_aggresive"));
            soundManager.SetExplosionTinySound(game.Content.Load <SoundEffect>(@"Sounds\explosion_tiny"));
            soundManager.SetExplosionUnderwaterSound(game.Content.Load <SoundEffect>(@"Sounds\explosion_underwater"));
            soundManager.SetLaserShotSound(game.Content.Load <SoundEffect>(@"Sounds\laserShot"));
            soundManager.SetLaserShot1Sound(game.Content.Load <SoundEffect>(@"Sounds\laserShot1"));
            soundManager.SetLosingSound(game.Content.Load <SoundEffect>(@"Sounds\losing1"));
            soundManager.SetWinningSound(game.Content.Load <SoundEffect>(@"Sounds\medievalWin"));
            soundManager.SetPickUpItemSound(game.Content.Load <SoundEffect>(@"Sounds\pickUpItem"));
            soundManager.SetStartUpSound(game.Content.Load <SoundEffect>(@"Sounds\startUpSound"));

            // Assigns fancy font.
            FontOriginTech      = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech");
            FontOriginTechSmall = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech_small");
            FontOriginTechTiny  = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech_tiny");

            // Putting together the GameScenes, each using a background component and a window component.
            MenuScene           = new GameScene(game, planetBackground, menu);
            TopTenScene         = new GameScene(game, planetBackground, topTen);
            GameWonScene        = new GameScene(game, planetRingsBackground, gameWon);
            GameOverScene       = new GameScene(game, planetExplodeBackground, gameOver);
            PlayerSettingsScene = new GameScene(game, planetRingsBackground, playerSettings);
            MenuScene           = new GameScene(game, planetBackground, menu, menuItems);

            // disabling components
            foreach (GameComponent component in game.Components)
            {
                ChangeComponentState(component, false);
            }

            ChangeMusic(this.sound.MenuBG);
        }