using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using tAC_Engine.Graphics.Entities; using tAC_Engine.Graphics; using Util; namespace FaceOff { class EndScreen : GameScreen { SpriteBatch mSpriteBatch; EntitySprite mBackground; EntitySprite mMouse; SoundManager sound; Score score; SpriteFont Font1; Vector2 congratsPos = new Vector2(400, 250); Vector2 treatyPos = new Vector2(400, 300); Vector2 scorestringPos = new Vector2(400, 350); Vector2 exitStringPos = new Vector2(400, 450); float congratsscale = 1.0f; float treatyscale = 1.0f; float scorestringscale = 1.0f; string congrats = "Congratulations"; string treaty = "You have successfully passed your treaty!"; string scorestring = ""; string exitString = "Press the Space Bar to exit"; List mComponents; InputHandler mInputHandler; private Logger mLogger; public EndScreen(Score nScore) { score = nScore; scorestring = "Your Score: " + score.getFinalScore(); } public override void Initialize() { mLogger = GetLogger(); mLogger.Initialize(); mComponents = new List(); mInputHandler = GetInputHandler(); mInputHandler.Initialize(); mInputHandler.BindButton(Keys.Space, Trigger.Activated, (int)EventCode.FO_INPUT_KEY_SPACE); mInputHandler.BindButton(MouseButton.Left, Trigger.Activated, (int)EventCode.FO_INPUT_MOUSE_LEFT_DOWN); mInputHandler.BindButton(MouseButton.Left, Trigger.Deactivated, (int)EventCode.FO_INPUT_MOUSE_LEFT_UP); mMouse = new EntitySprite(Content, @"Texture\Cursor"); mMouse.BlendMode = SpriteBlendMode.AlphaBlend; mMouse.Position = Vector2.Zero; mMouse.Initialize(); mBackground = new EntitySprite(Content, @"Texture\Background"); mBackground.Position = Vector2.Zero; mBackground.Initialize(); sound = new SoundManager(); sound.LoadContent(Content); mComponents.Add(mBackground); base.Initialize(); } protected override void LoadContent() { mSpriteBatch = new SpriteBatch(GraphicsDevice); foreach (GameComponent gc in mComponents) { EntitySprite s = gc as EntitySprite; if (s != null) { s.SpriteBatch = mSpriteBatch; } } mMouse.SpriteBatch = mSpriteBatch; // Create a new SpriteBatch, which can be used to draw textures. Font1 = Content.Load("Face Off"); base.LoadContent(); } /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// protected override void UnloadContent() { // TODO: Unload any non ContentManager content here base.UnloadContent(); } /// /// 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); mMouse.Position = new Vector2(mInputHandler.MouseLocation.X, mInputHandler.MouseLocation.Y); mMouse.Visible = true; while (mInputHandler.HasEvent()) { InputEvent inputEvent = mInputHandler.GetNextEvent(); switch ((EventCode)inputEvent.EventCode) { case EventCode.FO_INPUT_KEY_SPACE: mLogger.Write((int)EventCode.FO_END, typeof(EventCode)); //mLogger.Dispose(); Done(); Done(); Done(); //Raise(new FaceOff()); break; } } } public override void Draw(GameTime gameTime) { base.Draw(gameTime); foreach (GameComponent gc in mComponents) { EntitySprite s = gc as EntitySprite; if (s != null) { s.Draw(gameTime); } } mSpriteBatch.Begin(); // draw the congrats string Vector2 congratsOrigin = Font1.MeasureString(congrats) / 2; Vector2 treatyOrigin = Font1.MeasureString(treaty) / 2; Vector2 scorestringOrigin = Font1.MeasureString(scorestring) / 2; Vector2 exitStringOrigin = Font1.MeasureString(exitString) / 2; mSpriteBatch.DrawString(Font1, congrats, congratsPos, Color.LightGreen, 0, congratsOrigin, congratsscale, SpriteEffects.None, 0.5f); mSpriteBatch.DrawString(Font1, treaty, treatyPos, Color.LightGreen, 0, treatyOrigin, treatyscale, SpriteEffects.None, 0.5f); mSpriteBatch.DrawString(Font1, scorestring, scorestringPos, Color.LightGreen, 0, scorestringOrigin, scorestringscale, SpriteEffects.None, 0.5f); mSpriteBatch.DrawString(Font1, exitString, exitStringPos, Color.LightGreen, 0, exitStringOrigin, 1.0f, SpriteEffects.None, 0.5f); mSpriteBatch.End(); if (mMouse.Visible) { mMouse.Draw(gameTime); } } } }