From 94f1adf45e38f4db118361dbc5516ea54264a947 Mon Sep 17 00:00:00 2001 From: timotei Date: Sat, 17 Sep 2011 19:30:33 +0300 Subject: [PATCH] Implement the win level tracking --- CREDITS | 3 +- egp_story/Assets.cs | 4 +-- egp_story/Levels/Calipuirr.cs | 4 +-- egp_story/Levels/EllyuteionLake.cs | 4 +-- egp_story/Levels/MirrosHills.cs | 4 +-- egp_story/Levels/Pandorashys.cs | 4 +-- egp_story/Levels/StoryLevel.cs | 12 ++++--- egp_story/Levels/ViridesPuirr.cs | 4 +-- egp_story/Menus/MapMenu.cs | 33 +++++++++++++----- egp_story/TheStory.cs | 8 +++-- egp_storyContent/egp_storyContent.contentproj | 14 ++++---- egp_storyContent/gfx/cross.png | Bin 0 -> 351 bytes egp_storyContent/gfx/dot.png | Bin 846 -> 0 bytes 13 files changed, 57 insertions(+), 37 deletions(-) create mode 100644 egp_storyContent/gfx/cross.png delete mode 100644 egp_storyContent/gfx/dot.png diff --git a/CREDITS b/CREDITS index 487f7f9..0a4b85c 100644 --- a/CREDITS +++ b/CREDITS @@ -16,5 +16,4 @@ Credits for the used resources: - Main menu background: http://camilkuo.deviantart.com/art/Magic-Forest-25216616 - Main menu frame: http://gearstock.deviantart.com/art/gearstock-old-photo-frame-4492918?q=boost%3Apopular%20old%20frame&qo=15 - Maps: http://www.spriters-resource.com/snes/zeldalinkpast/ , ``Backgrounds & Maps" category -- Main menu font: http://www.fontspace.com/fontgrube/trinigan-fg - \ No newline at end of file +- Main menu font: http://www.fontspace.com/fontgrube/trinigan-fg \ No newline at end of file diff --git a/egp_story/Assets.cs b/egp_story/Assets.cs index aaf5a03..47a50d6 100644 --- a/egp_story/Assets.cs +++ b/egp_story/Assets.cs @@ -27,7 +27,7 @@ public class Assets public static Texture2D HowToPlayBackground { get; private set; } public static Texture2D WorldMapTexture { get; private set; } - public static Texture2D Dot { get; private set; } + public static Texture2D Cross { get; private set; } public static Texture2D HarapAlbShootSouth { get; private set; } public static Texture2D HarapAlbShootNorth { get; private set; } @@ -80,7 +80,7 @@ public static void LoadAssets( ContentManager content ) WorldMapTexture = content.Load( "gfx/WorldMap" ); - Dot = content.Load( "gfx/dot" ); + Cross = content.Load( "gfx/cross" ); HarapAlbShootSouth = content.Load( "gfx/harapalb/shoot_s" ); HarapAlbShootNorth = content.Load( "gfx/harapalb/shoot_n" ); diff --git a/egp_story/Levels/Calipuirr.cs b/egp_story/Levels/Calipuirr.cs index 1ce5aeb..e4224e0 100644 --- a/egp_story/Levels/Calipuirr.cs +++ b/egp_story/Levels/Calipuirr.cs @@ -16,8 +16,8 @@ namespace egp_story.Levels { public class Calipuirr : StoryLevel { - public Calipuirr( Game game ) - : base( game ) + public Calipuirr( Game game, int index ) + : base( game, index ) { Player player = Player.CreateNewHarapAlb( game ); Enemy bugEnemy = Enemy.CreateBugEnemy( game ); diff --git a/egp_story/Levels/EllyuteionLake.cs b/egp_story/Levels/EllyuteionLake.cs index 7fe0415..6a95373 100644 --- a/egp_story/Levels/EllyuteionLake.cs +++ b/egp_story/Levels/EllyuteionLake.cs @@ -17,8 +17,8 @@ namespace egp_story.Levels { public class EllyuteionLake : StoryLevel { - public EllyuteionLake( Game game ) - : base( game ) + public EllyuteionLake( Game game, int index ) + : base( game, index ) { Player player = Player.CreateNewHarapAlb( game ); Enemy bugEnemy = Enemy.CreateBugEnemy( game ); diff --git a/egp_story/Levels/MirrosHills.cs b/egp_story/Levels/MirrosHills.cs index 6635399..f370920 100644 --- a/egp_story/Levels/MirrosHills.cs +++ b/egp_story/Levels/MirrosHills.cs @@ -16,8 +16,8 @@ namespace egp_story.Levels { public class MirrosHills : StoryLevel { - public MirrosHills( Game game ) - : base( game ) + public MirrosHills( Game game, int index ) + : base( game, index ) { Player player = Player.CreateNewHarapAlb( game ); Enemy bugEnemy = Enemy.CreateBugEnemy( game ); diff --git a/egp_story/Levels/Pandorashys.cs b/egp_story/Levels/Pandorashys.cs index cbbc1ab..06bbfdc 100644 --- a/egp_story/Levels/Pandorashys.cs +++ b/egp_story/Levels/Pandorashys.cs @@ -16,8 +16,8 @@ namespace egp_story.Levels { public class Pandorashys : StoryLevel { - public Pandorashys( Game game ) - : base( game ) + public Pandorashys( Game game, int index ) + : base( game, index ) { Player player = Player.CreateNewHarapAlb( game ); Enemy bugEnemy = Enemy.CreateBugEnemy( game ); diff --git a/egp_story/Levels/StoryLevel.cs b/egp_story/Levels/StoryLevel.cs index 814363f..d22211d 100644 --- a/egp_story/Levels/StoryLevel.cs +++ b/egp_story/Levels/StoryLevel.cs @@ -19,15 +19,17 @@ namespace egp_story.Levels public abstract class StoryLevel : IUpdateable, IDrawable { public bool LevelEnded { get; protected set; } + public bool Won { get; protected set; } public LevelMap LevelMap { get; protected set; } public Game Game { get; protected set; } + public int LevelIndex { get; protected set; } protected bool _gameEnded; - protected bool _won; - public StoryLevel( Game game ) + public StoryLevel( Game game, int index ) { Game = game; + LevelIndex = index; } #region IUpdateable Members @@ -45,8 +47,8 @@ public virtual void Update( GameTime gameTime ) LevelMap.ThePlayer.IsDead ) { _gameEnded = true; - _won = !LevelMap.ThePlayer.IsDead; - if ( _won ) { + Won = !LevelMap.ThePlayer.IsDead; + if ( Won ) { LevelMap.Tint = Color.Yellow; } else { @@ -80,7 +82,7 @@ public virtual void Draw( SpriteBatch spriteBatch, GameTime gameTime ) LevelMap.Draw( spriteBatch, gameTime ); if ( _gameEnded ) { - spriteBatch.Draw( _won ? Assets.WinMessage : Assets.LoseMessage, new Vector2( 0, 100 ) ); + spriteBatch.Draw( Won ? Assets.WinMessage : Assets.LoseMessage, new Vector2( 0, 100 ) ); } } diff --git a/egp_story/Levels/ViridesPuirr.cs b/egp_story/Levels/ViridesPuirr.cs index 952155f..37e0de4 100644 --- a/egp_story/Levels/ViridesPuirr.cs +++ b/egp_story/Levels/ViridesPuirr.cs @@ -17,8 +17,8 @@ namespace egp_story.Levels { public class ViridesPuirr : StoryLevel { - public ViridesPuirr( Game game ) - : base( game ) + public ViridesPuirr( Game game, int index ) + : base( game, index ) { Player player = Player.CreateNewHarapAlb( game ); Enemy bugEnemy = Enemy.CreateBugEnemy( game ); diff --git a/egp_story/Menus/MapMenu.cs b/egp_story/Menus/MapMenu.cs index 292d5a2..e39d18e 100644 --- a/egp_story/Menus/MapMenu.cs +++ b/egp_story/Menus/MapMenu.cs @@ -29,6 +29,7 @@ public class MapMenu : Menu new Vector2( 226, 200 ) }; private const float VIEW_OFFSET = 50f; + public static bool[] WON_STATUSES = new bool[LOCATIONS.Length]; private int _currentLocation; private Rectangle _targetRectangle; @@ -38,6 +39,11 @@ public MapMenu( Game game ) { _targetRectangle = new Rectangle( 0, 0, TheStory.GAME_WIDTH, Assets.WorldMapTexture.Height ); _currentLocation = 0; + foreach ( bool status in WON_STATUSES ) { + if ( status == true ) { + _currentLocation = ( _currentLocation + 1 ) % LOCATIONS.Length; + } + } } #region Menu Members @@ -54,12 +60,13 @@ public override void Update( GameTime gameTime ) _targetRectangle.Y = ( int ) MathHelper.Clamp( _targetRectangle.Y, TheStory.GAME_HEIGHT - Assets.WorldMapTexture.Height, 0 ); + int prevLocation = _currentLocation; // select location if ( Keyboard.GetState( ).IsKeyDown2( Keys.Left ) ) { - _currentLocation = ( _currentLocation - 1 ) % LOCATIONS.Length; + --_currentLocation; } else if ( Keyboard.GetState( ).IsKeyDown2( Keys.Right ) ) { - _currentLocation = ( _currentLocation + 1 ) % LOCATIONS.Length; + ++_currentLocation; } _currentLocation = ( int ) MathHelper.Clamp( _currentLocation, 0, LOCATIONS.Length - 1 ); @@ -86,11 +93,11 @@ public override void Update( GameTime gameTime ) if ( Keyboard.GetState( ).IsKeyDown2( Keys.Enter ) ) { switch ( _currentLocation ) { - case 0: SelectedLevel = new ViridesPuirr( Game ); break; - case 1: SelectedLevel = new Calipuirr( Game ); break; - case 2: SelectedLevel = new EllyuteionLake( Game ); break; - case 3: SelectedLevel = new MirrosHills( Game ); break; - case 4: SelectedLevel = new Pandorashys( Game ); break; + case 0: SelectedLevel = new ViridesPuirr( Game, 0 ); break; + case 1: SelectedLevel = new Calipuirr( Game, 1 ); break; + case 2: SelectedLevel = new EllyuteionLake( Game, 2 ); break; + case 3: SelectedLevel = new MirrosHills( Game, 3 ); break; + case 4: SelectedLevel = new Pandorashys( Game, 4 ); break; default: break; } } @@ -101,9 +108,17 @@ public override void Draw( SpriteBatch spriteBatch, GameTime gameTime ) { spriteBatch.Draw( Assets.WorldMapTexture, _targetRectangle, Color.White ); + // draw completed levels + for ( int i = 0; i < LOCATIONS.Length; ++i ) { + if ( WON_STATUSES[i] == true ) { + spriteBatch.Draw( Assets.Cross, LOCATIONS[i] + new Vector2( 0, _targetRectangle.Y ), + Assets.Cross.Bounds.Center.ToVector2( ), Color.Yellow ); + } + } + // draw the location - spriteBatch.Draw( Assets.Dot, LOCATIONS[_currentLocation] + new Vector2( 0, _targetRectangle.Y ), - Assets.Dot.Bounds.Center.ToVector2( ) ); + spriteBatch.Draw( Assets.Cross, LOCATIONS[_currentLocation] + new Vector2( 0, _targetRectangle.Y ), + Assets.Cross.Bounds.Center.ToVector2( ), Color.Red ); } #endregion } diff --git a/egp_story/TheStory.cs b/egp_story/TheStory.cs index e834611..04bf930 100644 --- a/egp_story/TheStory.cs +++ b/egp_story/TheStory.cs @@ -67,6 +67,10 @@ protected override void Update( GameTime gameTime ) _currentLevel.Update( gameTime ); if ( _currentLevel.LevelEnded ) { + if ( _currentLevel.Won ) { + MapMenu.WON_STATUSES[_currentLevel.LevelIndex] = true; + } + _currentMenu = new MapMenu( this ); _currentLevel = null; } } @@ -76,9 +80,9 @@ protected override void Update( GameTime gameTime ) if ( _currentMenu.SelectedLevel != null ) { _currentLevel = _currentMenu.SelectedLevel; _currentMenu.SelectedLevel = null; + _currentMenu = null; } - - if ( _currentMenu.SelectedMenu != null ) { + else if ( _currentMenu.SelectedMenu != null ) { _currentMenu = _currentMenu.SelectedMenu; _currentMenu.SelectedMenu = null; } diff --git a/egp_storyContent/egp_storyContent.contentproj b/egp_storyContent/egp_storyContent.contentproj index ec94941..74b3268 100644 --- a/egp_storyContent/egp_storyContent.contentproj +++ b/egp_storyContent/egp_storyContent.contentproj @@ -56,13 +56,6 @@ TextureProcessor - - - dot - TextureImporter - TextureProcessor - - bug_walk_e @@ -231,6 +224,13 @@ TextureProcessor + + + cross + TextureImporter + TextureProcessor + +