/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(); if (Title) { // Display Title Screen spriteBatch.Draw(titleScreen, new Rectangle(0, 0, 800, 600), Color.White); } else if (Failure) { // Display Failure screen } else if (Success) { // Display Success Screen } else { TileMap.Draw(spriteBatch); Player.Draw(spriteBatch); EncounterManager.Draw(spriteBatch); } FadeMessageManager.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState keyboard = Keyboard.GetState(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Escape)) { this.Exit(); } if (FrameClear.IsClear < gameTime.TotalGameTime.TotalSeconds) { if (Title) { // Display Title Screen FadeMessageManager.Update(gameTime); if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { Title = false; RestartGame(); } } else if (Failure) { // Display Failure screen if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { Title = true; Failure = false; FrameClear.IsClear = gameTime.TotalGameTime.TotalSeconds + 0.3; } } else if (Success) { // Display Success Screen if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { Title = true; Success = false; FrameClear.IsClear = gameTime.TotalGameTime.TotalSeconds + 0.3; } } else { Player.Update(gameTime); EncounterManager.Update(gameTime); FadeMessageManager.Update(gameTime); } } base.Update(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here spriteSheet = Content.Load <Texture2D>(@"Textures\SpriteSheet"); titleScreen = Content.Load <Texture2D>(@"Textures\TitleScreen"); pericles = Content.Load <SpriteFont>(@"Fonts\Pericles"); SoundManager.Initialize(Content); TextureManager.Initialize(Content, spriteSheet); EncounterManager.Initialize(pericles); FadeMessageManager.Initialize(pericles); }
public static void Update(GameTime gameTime) { HandleInput(gameTime); BaseSprite.Update(gameTime); ClampToWorld(); // Reveal unexplored tiles (widest scan) List <SpaceTile> near = TileMap.GetSpaceTilesInView(); SpaceTile encounter = null; foreach (SpaceTile spaceTile in near) { if (spaceTile.BaseSprite.IsCircleColliding(Player.BaseSprite.WorldCenter, Player.LongRange)) { spaceTile.LongRangeScan(); } if (EncounterManager.EncounterActive) { // Do Nothing } else { if (spaceTile.BaseSprite.IsCircleColliding(BaseSprite.WorldCenter, EncounterRange)) { if (encounter == null) { encounter = spaceTile; } else { if (Vector2.Distance(spaceTile.BaseSprite.WorldCenter, Player.BaseSprite.WorldCenter) > Vector2.Distance(encounter.BaseSprite.WorldCenter, Player.BaseSprite.WorldCenter)) { encounter = spaceTile; } } } } } EncounterManager.Start(encounter); }