public PlayerView(GameLogic game) { this.Game = game; this.EventManager = game.EventManager; menuClock = new GameClock(); menuClock.Start(); /** * Initialize Graphics Subsystem **/ RenderForm = new Form(); RenderForm.ClientSize = new Size(Game.World.Width, Game.World.Height); RenderForm.Text = "Alien Invasion v1.0"; RenderForm.BackColor = Color.Empty; RenderForm.KeyPreview = true; RenderForm.FormBorderStyle = FormBorderStyle.FixedSingle; // Disable resizing of window RenderForm.MaximizeBox = false; // Disable maximizing RenderForm.Leave += (s, e) => { this.RenderForm.Focus(); // When RenderForm loses focus player input won't be processed correctly }; extractor = new Extractor(game); Renderer = new Graphics.Renderer(RenderForm, extractor); Renderer.StartRender(); rendererLoaders.Add(new TextureLoader(Renderer)); rendererLoaders.Add(new MeshLoader(Renderer)); rendererLoaders.Add(new EffectLoader(Renderer)); foreach (var rendererLoader in rendererLoaders) { game.ResourceManager.AddLoader(rendererLoader); } game.ResourceManager.AddLoader(new MaterialLoader(game.ResourceManager)); /** * Initialize Input Subsystem **/ gameController = new GameController(EventManager, game); RenderForm.KeyDown += new KeyEventHandler(gameController.OnKeyDown); RenderForm.KeyUp += new KeyEventHandler(gameController.OnKeyUp); /** * Initialize Audio Subsystem **/ audioPlayer = new FmodAudioPlayer(@"./data/audio/"); audioPlayer.LoadFile("audio.fev"); audioPlayer.IsPaused = false; /** * Initialize GUI **/ mainMenuControl = new GameMainMenu(EventManager); mainMenuControl.Location = new Point( (RenderForm.ClientSize.Width - mainMenuControl.Width) / 2, (RenderForm.ClientSize.Height - mainMenuControl.Height) / 2); RenderForm.Controls.Add(mainMenuControl); highscoreControl = new HighscoreScreen(EventManager); highscoreControl.Location = new Point( (RenderForm.ClientSize.Width - highscoreControl.Width) / 2, (RenderForm.ClientSize.Height - highscoreControl.Height) / 2); RenderForm.Controls.Add(highscoreControl); creditsControl = new Credits(EventManager); creditsControl.Location = new Point( (RenderForm.ClientSize.Width - creditsControl.Width) / 2, (RenderForm.ClientSize.Height - creditsControl.Height) / 2); RenderForm.Controls.Add(creditsControl); pauseControl = new PauseScreen(); pauseControl.Location = new Point( (RenderForm.ClientSize.Width - pauseControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - pauseControl.Height); RenderForm.Controls.Add(pauseControl); victoryControl = new VictoryScreen(EventManager); victoryControl.Location = new Point( (RenderForm.ClientSize.Width - victoryControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - (victoryControl.Height / 2)); RenderForm.Controls.Add(victoryControl); gameOverControl = new DefeatScreen(EventManager); gameOverControl.Location = new Point( (RenderForm.ClientSize.Width - gameOverControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - (gameOverControl.Height / 2)); RenderForm.Controls.Add(gameOverControl); hud = new Hud(EventManager); hud.Location = new Point(RenderForm.ClientSize.Width - hud.Width, 0); RenderForm.Controls.Add(hud); numOfGcCollectedObjects = new int[GC.MaxGeneration]; registerGameEventListeners(); }