/* * EndScreen.cs * Authors: Biran Chesborough * Copyright (c) 2007-2008 Cornell University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using tAC_Engine.Graphics.Entities; using Util; namespace StarJack { class EndScreen : GameScreen { public static String TextureDirectory = @"Texture\\"; List mMenuItems = new List(); SpriteBatch mSpriteBatch; SpriteFont mSpriteFont; Entity mMenuBackground; private bool missionCompleted; InputHandler inputHandler; private Logger mLogger; //The list of the components that this screen will own List mComponents; public EndScreen(bool msnComp) : base() { missionCompleted = msnComp; } /// /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// public override void Initialize() { mLogger = GetLogger(); mLogger.Initialize(); Entity.RootDirectory = RootDirectory; mComponents = new List(); inputHandler = GetInputHandler(); inputHandler.Initialize(); inputHandler.BindButton(Keys.Space, Trigger.Activated, (int)EventCode.MenuSelect); if (missionCompleted) { mMenuBackground = new Entity("Background"); mMenuBackground.TextureName = "MissionComplete"; mMenuBackground.X = 0; mMenuBackground.Y = 0; mMenuBackground.Width = 800; mMenuBackground.Height = 600; } else { mMenuBackground = new Entity("Background"); mMenuBackground.TextureName = "MissionFailed"; mMenuBackground.X = 0; mMenuBackground.Y = 0; mMenuBackground.Width = 800; mMenuBackground.Height = 600; } base.Initialize(); } /// /// LoadContent will be called once per game and is the place to load /// all of your content. /// protected override void LoadContent() { mSpriteBatch = new SpriteBatch(GraphicsDevice); foreach (GameComponent gc in mComponents) { EntitySprite s = gc as EntitySprite; if (s != null) { s.SpriteBatch = mSpriteBatch; } } mSpriteFont = Content.Load(@"Fonts\menufont"); mMenuBackground.LoadContent(Content); base.LoadContent(); } /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// protected override void UnloadContent() { } public override void Reinitialize() { inputHandler.Enable(); this.Enabled = true; this.Visible = true; } protected override void Dispose(bool disposing) { //Console.WriteLine("Example menu screen disposing"); if (disposing) { mSpriteBatch.Dispose(); } base.Dispose(disposing); } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. public override void Update(GameTime gameTime) { base.Update(gameTime); while (inputHandler.HasEvent()) { InputEvent e = inputHandler.GetNextEvent(); switch ((EventCode)e.EventCode) { case EventCode.MenuSelect: //close all starjack screens e.WriteToLog(mLogger, "SJ_ENDSCREEN_CONTINUE"); Done(); Done(); Done(); break; } } } /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. public override void Draw(GameTime gameTime) { base.Draw(gameTime); mSpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.FrontToBack, SaveStateMode.None); mMenuBackground.Draw(mSpriteBatch); mSpriteBatch.End(); } } }