/// <summary> /// Show on screen effects /// </summary> private void ShowOnScreenEffects(AnimatedTexture explosionTexture) { // Show explosion if we just died if (Player.explosionTimeoutMs > 0) { int screenSize = Math.Max(BaseGame.Width * 2 / 3, BaseGame.Height * 2 / 3); float explosionTimePercent = 1.0f - (Player.explosionTimeoutMs / (float)Player.MaxExplosionTimeoutMs); explosionTexture.Select( (int)(explosionTexture.AnimationLength * explosionTimePercent)); explosionTexture.RenderOnScreen(new Rectangle( BaseGame.Width / 2 - screenSize / 2, BaseGame.Height / 2 - screenSize / 2, screenSize, screenSize)); // Just rumble very heavy Input.GamePadRumble(0.8f, 0.9f); } // if if (Player.explosionTimeoutMs2 > 0 && Player.explosionTimeoutMs2 < Player.MaxExplosionTimeoutMs) { int screenSize = Math.Max(BaseGame.Width * 2 / 3, BaseGame.Height * 2 / 3); float explosionTimePercent = 1.0f - (Player.explosionTimeoutMs2 / (float)Player.MaxExplosionTimeoutMs); explosionTexture.Select( (int)(explosionTexture.AnimationLength * explosionTimePercent)); explosionTexture.RenderOnScreen(new Rectangle( BaseGame.Width / 2 - screenSize / 2 + BaseGame.Width / 7, BaseGame.Height / 2 - screenSize / 2 + BaseGame.Height / 12, screenSize, screenSize)); } // if if (Player.explosionTimeoutMs3 > 0 && Player.explosionTimeoutMs3 < Player.MaxExplosionTimeoutMs) { int screenSize = Math.Max(BaseGame.Width * 2 / 3, BaseGame.Height * 2 / 3); float explosionTimePercent = 1.0f - (Player.explosionTimeoutMs3 / (float)Player.MaxExplosionTimeoutMs); explosionTexture.Select( (int)(explosionTexture.AnimationLength * explosionTimePercent)); explosionTexture.RenderOnScreen(new Rectangle( BaseGame.Width / 2 - screenSize / 2 + BaseGame.Width / 9, BaseGame.Height / 2 - screenSize / 2 - BaseGame.Height / 7, screenSize, screenSize)); } // if const float BorderColorStrength = 0.6f; // Show blue glow border in middle if speed item is active if (Player.speedItemTimeout > 0) { float alpha = BorderColorStrength; if (Player.speedItemTimeout < 1000) alpha *= Player.speedItemTimeout / 1000.0f; hudTexture.RenderOnScreen( BaseGame.ResolutionRect, ScreenBorderEffectRect, Level.SpeedItemColor, alpha); } // if else if (Player.itemMessageTimeoutMs > Player.MaxItemMessageTimeoutMs - 1000 && Player.lastCollectedItem != Level.SpeedItemType && Player.lastCollectedItem != Level.BombItemType) { float alpha = BorderColorStrength; float time = Player.itemMessageTimeoutMs - (Player.MaxItemMessageTimeoutMs - 1000); alpha *= time / 1000.0f; hudTexture.RenderOnScreen( BaseGame.ResolutionRect, ScreenBorderEffectRect, Player.lastCollectedItem == Level.FuelItemType ? Level.FuelItemColor : Player.lastCollectedItem == Level.HealthItemType ? Level.HealthItemColor : Level.ExtraLifeItemColor, alpha); } // if // Show red glow border in middle if bomb item is active else if (Player.numberOfBombItems > 0) { hudTexture.RenderOnScreen( BaseGame.ResolutionRect, ScreenBorderEffectRect, Level.BombItemColor, // Increase border strength the more bombs we have collected. Math.Min(1.0f, Player.numberOfBombItems * 0.3f)); } // if }
/// <summary> /// Initialize textures and models for the game. /// </summary> protected override void Initialize() { base.Initialize(); // Load all available levels levels = Level.LoadAllLevels(); // Initialize asteroidManager and use last avialable level. asteroidManager = new GameAsteroidManager(levels[levels.Length - 1]); rocketModel = new Model("Rocket"); // Load menu textures mainMenuTexture = new Texture("MainMenu.png"); helperTexture = new Texture("ExtraButtons.png"); helpScreenTexture = new Texture("HelpScreen.png"); mouseCursorTexture = new Texture("MouseCursor.dds"); hudTexture = new Texture("Hud.png"); inGameTexture = new Texture("InGame.png"); lightEffectTexture = new Texture("LightEffect.dds"); explosionTexture = new AnimatedTexture("Explosion"); // Create main menu screen gameScreens.Push(new MainMenu()); //tst: //gameScreens.Push(new Mission(levels[0], asteroidManager)); //inGame = gameScreens.Peek().GetType() == typeof(Mission); //camera.InGame = inGame; }