diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index f814d06..7dd9cf8 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -1,161 +1,186 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.GamerServices; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Media; - -namespace DepthsBelow -{ - /// - /// This is the main type for your game - /// - public class Core : Microsoft.Xna.Framework.Game - { +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using DepthsBelow.GUI; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.GamerServices; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Media; + +namespace DepthsBelow +{ + /// + /// This is the main type for your game + /// + public class Core : Microsoft.Xna.Framework.Game + { public static GraphicsDeviceManager GraphicsDeviceManager; - SpriteBatch spriteBatch; - - public Camera Camera; - + SpriteBatch spriteBatch; + + public Camera Camera; + public static MouseInput MouseInput; - public static KeyboardInput KeyboardInput; - public List Squad; - public List Swarm; + public static KeyboardInput KeyboardInput; + public List Squad; + public List Swarm; public static Map Map; - public SmallEnemy TestMonster; - - public Core() - { - GraphicsDeviceManager = new GraphicsDeviceManager(this); - Content.RootDirectory = "Content"; - - GraphicsDeviceManager.PreferredBackBufferWidth = 1280; - GraphicsDeviceManager.PreferredBackBufferHeight = 720; - GraphicsDeviceManager.IsFullScreen = false; - - //graphics.SynchronizeWithVerticalRetrace = false; - this.IsFixedTimeStep = false; - GraphicsDeviceManager.ApplyChanges(); - - this.IsMouseVisible = true; - } - - /// - /// 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. - /// - protected override void Initialize() - { - // TODO: Add your initialization logic here - Camera = new Camera(this); - Squad = new List(); + public SmallEnemy TestMonster; + + public Core() + { + GraphicsDeviceManager = new GraphicsDeviceManager(this); + Content.RootDirectory = "Content"; + + GraphicsDeviceManager.PreferredBackBufferWidth = 1280; + GraphicsDeviceManager.PreferredBackBufferHeight = 720; + GraphicsDeviceManager.IsFullScreen = false; + + //graphics.SynchronizeWithVerticalRetrace = false; + this.IsFixedTimeStep = false; + GraphicsDeviceManager.ApplyChanges(); + + this.IsMouseVisible = true; + } + + /// + /// 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. + /// + protected override void Initialize() + { + // TODO: Add your initialization logic here + Camera = new Camera(this); + Squad = new List(); Swarm = new List(); - TestMonster = new SmallEnemy(this, ref Swarm); - - base.Initialize(); - } - - /// - /// LoadContent will be called once per game and is the place to load - /// all of your content. - /// - protected override void LoadContent() - { - // Create a new SpriteBatch, which can be used to draw textures. - spriteBatch = new SpriteBatch(GraphicsDevice); - - Map = Content.Load("maps/Cave.Level1"); - // Load map objects - Map.ParseObjects(this); - - // TODO: use this.Content to load your game content here - Soldier.LoadContent(this); - SmallEnemy.LoadContent(this); - - MouseInput = new MouseInput(this); + TestMonster = new SmallEnemy(this, ref Swarm); + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(GraphicsDevice); + + Map = Content.Load("maps/Cave.Level1"); + // Load map objects + Map.ParseObjects(this); + + // TODO: use this.Content to load your game content here + Soldier.LoadContent(this); + SmallEnemy.LoadContent(this); + + MouseInput = new MouseInput(this); MouseInput.LoadContent(); - KeyboardInput = new KeyboardInput(this); - } - - /// - /// 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 - } - - /// - /// 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. - protected override void Update(GameTime gameTime) - { - // Allows the game to exit - if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - this.Exit(); - - Camera.Update(gameTime); + KeyboardInput = new KeyboardInput(this); + + // Test GUI frames + var frame = new GUI.Button() + { + X = 100, + Width = 48, + Height = 23, + Texture = Content.Load("images/Enter"), + OnClick = delegate(Point clickPos) + { + Debug.WriteLine("That ugly button was clicked at (" + clickPos.X + "," + clickPos.Y + ")"); + } + }; + var text = new GUI.Text(Content.Load("Arial")); + text.Value = "Hello world!"; + frame.Add(text); + } + + /// + /// 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 + } + + /// + /// 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. + protected override void Update(GameTime gameTime) + { + // Allows the game to exit + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) + this.Exit(); + + Camera.Update(gameTime); MouseInput.Update(gameTime); - KeyboardInput.Update(gameTime); - - // Update soldiers in squad - foreach (var soldier in Squad) - soldier.Update(gameTime); - - foreach (var body in Swarm) - body.Update(gameTime); - - base.Update(gameTime); - } - - /// - /// This is called when the game should draw itself. - /// - /// Provides a snapshot of timing values. - protected override void Draw(GameTime gameTime) - { - GraphicsDevice.Clear(Color.Black); - - // Start drawing using the Camera transform - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, - Camera.Transform); - - // Draw the level - Map.Draw(spriteBatch); - - // Draw units - foreach (var soldier in Squad) - { - var sr = soldier.GetComponent(); - if (sr != null) - sr.Draw(spriteBatch); - } - foreach (var body in Swarm) - { - var sr = body.GetComponent(); - if (sr != null) - sr.Draw(spriteBatch); - } - - // Draw mouse input visuals + KeyboardInput.Update(gameTime); + + // Update soldiers in squad + foreach (var soldier in Squad) + soldier.Update(gameTime); + + foreach (var body in Swarm) + body.Update(gameTime); + + GUIManager.Update(gameTime); + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.Black); + + // Start drawing using the Camera transform + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, + Camera.Transform); + + // Draw the level + Map.Draw(spriteBatch); + + // Draw units + foreach (var soldier in Squad) + { + var sr = soldier.GetComponent(); + if (sr != null) + sr.Draw(spriteBatch); + } + foreach (var body in Swarm) + { + var sr = body.GetComponent(); + if (sr != null) + sr.Draw(spriteBatch); + } + + // Draw mouse input visuals MouseInput.Draw(spriteBatch); - TestMonster.GetComponent().Draw(spriteBatch); - - spriteBatch.End(); - - base.Draw(gameTime); - } - } -} + TestMonster.GetComponent().Draw(spriteBatch); + + spriteBatch.End(); + + // Start drawing GUI components + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, null, null, null, Matrix.Identity); + GUIManager.Draw(spriteBatch); + spriteBatch.End(); + + base.Draw(gameTime); + } + } +} diff --git a/DepthsBelow/DepthsBelow/DepthsBelow.csproj b/DepthsBelow/DepthsBelow/DepthsBelow.csproj index 48ff742..54a7b3e 100644 --- a/DepthsBelow/DepthsBelow/DepthsBelow.csproj +++ b/DepthsBelow/DepthsBelow/DepthsBelow.csproj @@ -122,6 +122,10 @@ + + + + @@ -186,6 +190,7 @@ + + + + + + Berlin Sans FB + + + 11 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj index 82ab136..7970226 100644 --- a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj +++ b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj @@ -113,6 +113,13 @@ TextureProcessor + + + Arial + FontDescriptionImporter + FontDescriptionProcessor + +