Prechádzať zdrojové kódy

RPG Fixes to Stores, Fighting and more.

CartBlanche 1 mesiac pred
rodič
commit
b3b69664c4

+ 11 - 11
RolePlayingGame/Core/Combat/CombatEngine.cs

@@ -1049,14 +1049,7 @@ namespace RolePlaying
         {
             SpriteBatch spriteBatch = Session.ScreenManager.SpriteBatch;
             Viewport viewport = Session.ScreenManager.GraphicsDevice.Viewport;
-            
-            // update the animations
-            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;
-            highlightForegroundSprite.UpdateAnimation(elapsedSeconds);
-            highlightBackgroundSprite.UpdateAnimation(elapsedSeconds);
-            primaryTargetSprite.UpdateAnimation(elapsedSeconds);
-            secondaryTargetSprite.UpdateAnimation(elapsedSeconds);
-            
+
             // draw the highlighted-player sprite, if any
             if (highlightedCombatant != null)
             {
@@ -1068,6 +1061,13 @@ namespace RolePlaying
                     1f - (highlightedCombatant.Position.Y + 1) / viewport.Height);
             }
 
+            // update the animations
+            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;
+            highlightForegroundSprite.UpdateAnimation(elapsedSeconds);
+            highlightBackgroundSprite.UpdateAnimation(elapsedSeconds);
+            primaryTargetSprite.UpdateAnimation(elapsedSeconds);
+            secondaryTargetSprite.UpdateAnimation(elapsedSeconds);
+
             // draw the primary target sprite and name, if any
             if (primaryTargetedCombatant != null)
             {
@@ -1929,6 +1929,9 @@ namespace RolePlaying
         /// </summary>
         private void DrawCombatEngine(GameTime gameTime)
         {
+            // draw the selection animations
+            DrawSelectionSprites(gameTime);
+            
             // draw the players
             foreach (CombatantPlayer player in players)
             {
@@ -1941,9 +1944,6 @@ namespace RolePlaying
                 monster.Draw(gameTime);
             }
 
-            // draw the selection animations
-            DrawSelectionSprites(gameTime);
-
             // draw the combat effects
             DrawCombatEffects(gameTime);
         }

+ 11 - 8
RolePlayingGame/Core/Combat/Combatant.cs

@@ -288,16 +288,19 @@ namespace RolePlaying
             CombatSprite.Draw(Session.ScreenManager.SpriteBatch,
                 Position, 1f - Position.Y / RolePlayingGame.BUFFER_WIDTH);
 
-            Session.ScreenManager.SpriteBatch.Draw(Character.ShadowTexture, Position, 
-                null, Color.White, 0f, new Vector2(Character.ShadowTexture.Width / 2, 
-                Character.ShadowTexture.Height / 2), 1f, SpriteEffects.None, 1f);
-
-            // draw the combat action
-            if (combatAction != null)
+            if (Character.ShadowTexture != null)
             {
-                // update the combat action
-                combatAction.Draw(gameTime, Session.ScreenManager.SpriteBatch);
+                Session.ScreenManager.SpriteBatch.Draw(Character.ShadowTexture, Position,
+                    null, Color.White, 0f, new Vector2(Character.ShadowTexture.Width / 2,
+                    Character.ShadowTexture.Height / 2), 1f, SpriteEffects.None, 1f);
             }
+
+            // draw the combat action
+                if (combatAction != null)
+                {
+                    // update the combat action
+                    combatAction.Draw(gameTime, Session.ScreenManager.SpriteBatch);
+                }
         }
 
 

+ 1 - 0
RolePlayingGame/Core/Content/Characters/QuestNPCs/Ekin.xml

@@ -2,6 +2,7 @@
 <XnaContent>
   <Asset Type="RolePlaying.Data.QuestNpc">
       <Name>Ekin</Name>
+      <Direction>NorthWest</Direction>
       <MapSprite>
           <TextureName>Characters\Villager1IdleRight</TextureName>
           <FrameDimensions>92 120</FrameDimensions>

+ 2 - 1
RolePlayingGame/Core/Content/Characters/QuestNPCs/JangElder.xml

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <XnaContent>
   <Asset Type="RolePlaying.Data.QuestNpc">
-      <Name>Manny</Name>
+      <Name>Jang Elder</Name>
+      <Direction>SouthEast</Direction>
       <MapSprite>
           <TextureName>Characters\VillagerIdleRight</TextureName>
           <FrameDimensions>92 120</FrameDimensions>

+ 1 - 1
RolePlayingGame/Core/Content/Characters/QuestNPCs/Manny.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <XnaContent>
   <Asset Type="RolePlaying.Data.QuestNpc">
-      <Name>Ayttas</Name>
+      <Name>Manny</Name>
       <MapSprite>
           <TextureName>Characters\Villager2IdleRight</TextureName>
           <FrameDimensions>92 120</FrameDimensions>

+ 2 - 1
RolePlayingGame/Core/Content/Characters/QuestNPCs/Ujar.xml

@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <XnaContent>
   <Asset Type="RolePlaying.Data.QuestNpc">
-      <Name>Ayttas</Name>
+      <Name>Ujar</Name>
+      <Direction>SouthWest</Direction>
       <MapSprite>
           <TextureName>Characters\Villager1IdleRight</TextureName>
           <FrameDimensions>92 120</FrameDimensions>

+ 1 - 0
RolePlayingGame/Core/Content/Characters/QuestNPCs/Vejnas.xml

@@ -2,6 +2,7 @@
 <XnaContent>
   <Asset Type="RolePlaying.Data.QuestNpc">
       <Name>Vejnas</Name>
+      <Direction>East</Direction>
       <MapSprite>
           <TextureName>Characters\Villager1IdleRight</TextureName>
           <FrameDimensions>92 120</FrameDimensions>

+ 1 - 1
RolePlayingGame/Core/GameScreens/InnScreen.cs

@@ -156,7 +156,7 @@ namespace RolePlaying
                 (viewport.Height - backgroundTexture.Height) / 2);
 
             namePosition = new Vector2(
-                (viewport.Width - Fonts.HeaderFont.MeasureString(inn.Name).X) / 2, 90f);
+                (viewport.Width - Fonts.HeaderFont.MeasureString(inn.Name).X) / 2, 95f);
 
             selectTextPosition = selectIconPosition;
             selectTextPosition.X -= 

+ 1 - 7
RolePlayingGame/Core/GameScreens/StoreBuyScreen.cs

@@ -303,11 +303,6 @@ namespace RolePlaying
             rightTriggerText = store.StoreCategories[index].Name;
         }
 
-
-
-
-
-
         /// <summary>
         /// Draw the entry at the given position in the list.
         /// </summary>
@@ -394,8 +389,7 @@ namespace RolePlaying
                 priceText = ((int)Math.Floor(entry.GoldValue * 
                     store.BuyMultiplier)).ToString();
             }
-            spriteBatch.DrawString(Fonts.GearInfoFont, priceText,
-                drawPosition, color);
+            spriteBatch.DrawString(Fonts.GearInfoFont, priceText, drawPosition, color);
         }
 
 

+ 4 - 13
RolePlayingGame/Core/GameScreens/StoreScreen.cs

@@ -21,9 +21,6 @@ namespace RolePlaying
     {
         private Store store = null;
 
-
-
-
         private Texture2D shopDrawScreen;
         private Texture2D selectButton;
         private Texture2D backButton;
@@ -112,14 +109,9 @@ namespace RolePlaying
                 (viewport.Width - plankTexture.Width) / 2, 66f);
             shopNamePosition = new Vector2(
                 (viewport.Width - Fonts.HeaderFont.MeasureString(store.Name).X) / 2, 
-                90f);
+                95f);
         }
 
-
-
-
-
-
         /// <summary>
         /// Handles user input.
         /// </summary>
@@ -200,11 +192,10 @@ namespace RolePlaying
             spriteBatch.Draw(plankTexture, plankPosition, Color.White);
 
             // Draw the Title of the Screen
-            spriteBatch.DrawString(Fonts.HeaderFont, store.Name,
-                shopNamePosition, Fonts.TitleColor);
+			spriteBatch.DrawString(Fonts.HeaderFont, store.Name, shopNamePosition, Fonts.TitleColor, MathHelper.ToRadians(-3.0f), Vector2.Zero, 1.0f, SpriteEffects.None, 0f);
 
-            // Draw Conversation Strip
-            spriteBatch.Draw(conversationStrip, conversationStripPosition,
+			// Draw Conversation Strip
+			spriteBatch.Draw(conversationStrip, conversationStripPosition,
                 Color.White);
 
             // Draw Shop Keeper

+ 1 - 4
RolePlayingGame/Core/MenuScreens/HelpScreen.cs

@@ -20,8 +20,6 @@ namespace RolePlaying
     /// </summary>
     class HelpScreen : GameScreen
     {
-
-
         private Texture2D backgroundTexture;
 
         private Texture2D plankTexture;
@@ -153,8 +151,7 @@ namespace RolePlaying
             spriteBatch.Draw(scrollUpTexture, scrollUpPosition, Color.White);
             spriteBatch.Draw(scrollDownTexture, scrollDownPosition, Color.White);
 
-            spriteBatch.DrawString(Fonts.HeaderFont, "Help", titlePosition,
-                Fonts.TitleColor);
+            spriteBatch.DrawString(Fonts.HeaderFont, "Help", titlePosition, Fonts.TitleColor, MathHelper.ToRadians(-3.0f), Vector2.Zero, 1.0f, SpriteEffects.None, 0f);
 
             for (int i = 0; i < maxLineDisplay; i++)
             {

+ 0 - 5
RolePlayingGame/Core/MenuScreens/LoadingScreen.cs

@@ -38,11 +38,6 @@ namespace RolePlaying
 
         GameScreen[] screensToLoad;
 
-
-
-
-
-
         private Texture2D loadingTexture;
         private Vector2 loadingPosition;
 

+ 1 - 3
RolePlayingGame/Core/MenuScreens/SaveLoadScreen.cs

@@ -333,9 +333,7 @@ namespace RolePlaying
             spriteBatch.DrawString(Fonts.ButtonNamesFont, "Back", 
                 backTextPosition, Color.White);
 
-            spriteBatch.DrawString(Fonts.HeaderFont, 
-                (mode == SaveLoadScreenMode.Load ? "Load" : "Save"), 
-                titleTextPosition, Fonts.TitleColor);
+            spriteBatch.DrawString(Fonts.HeaderFont, (mode == SaveLoadScreenMode.Load ? "Load" : "Save"), titleTextPosition, Fonts.TitleColor, MathHelper.ToRadians(-3.0f), Vector2.Zero, 1.0f, SpriteEffects.None, 0f);
 
             if ((Session.SaveGameDescriptions != null))
             {

+ 21 - 0
RolePlayingGame/RolePlayingGameData/Animation/AnimatingSprite.cs

@@ -7,6 +7,9 @@
 
 using System;
 using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
@@ -470,6 +473,24 @@ namespace RolePlaying.Data
             return animatingSprite;
         }
 
+        internal static AnimatingSprite Load(XElement xElement, ContentManager contentManager)
+        {
+            var animatingSprite = new AnimatingSprite
+            {
+                TextureName = (string)xElement.Element("TextureName"),
+                Texture = contentManager.Load<Texture2D>(
+                    Path.Combine(@"Textures\", (string)xElement.Element("TextureName"))),
+                FrameDimensions = new Point(
+                    int.Parse(xElement.Element("FrameDimensions").Value.Split(' ')[0]),
+                    int.Parse(xElement.Element("FrameDimensions").Value.Split(' ')[1])),
+                FramesPerRow = (int)xElement.Element("FramesPerRow"),
+                SourceOffset = new Vector2(
+                    int.Parse(xElement.Element("SourceOffset").Value.Split(' ')[0]),
+                    int.Parse(xElement.Element("SourceOffset").Value.Split(' ')[1])),
+                // Handle Animations if needed
+            };
 
+            return animatingSprite;
+        }
     }
 }

+ 6 - 38
RolePlayingGame/RolePlayingGameData/Characters/Monster.cs

@@ -99,39 +99,14 @@ namespace RolePlaying.Data
             var monster = new Monster
             {
                 AssetName = monsterContentName,
-                Name = (string)asset.Element("Name"),
+                Name = asset.Element("Name").Value,
+                Direction = Enum.TryParse<Direction>((string)asset.Element("Direction"), out var dir) ? dir : default,
                 CharacterClassContentName = (string)asset.Element("CharacterClassContentName"),
                 CharacterLevel = (int)asset.Element("CharacterLevel"),
                 InitialEquipmentContentNames = asset.Element("InitialEquipmentContentNames")
                     .Elements("Item").Select(x => (string)x).ToList(),
-                CombatSprite = new AnimatingSprite
-                {
-                    TextureName = (string)asset.Element("CombatSprite").Element("TextureName"),
-                    Texture = contentManager.Load<Texture2D>(
-                        Path.Combine(@"Textures\", (string)asset.Element("CombatSprite").Element("TextureName"))),
-                    FrameDimensions = new Point(
-                        int.Parse(asset.Element("CombatSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("CombatSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                    FramesPerRow = (int)asset.Element("CombatSprite").Element("FramesPerRow"),
-                    SourceOffset = new Vector2(
-                        int.Parse(asset.Element("CombatSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("CombatSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                    // Handle Animations if needed
-                },
-                MapSprite = new AnimatingSprite
-                {
-                    TextureName = (string)asset.Element("MapSprite").Element("TextureName"),
-                    Texture = contentManager.Load<Texture2D>(
-                        Path.Combine(@"Textures\", (string)asset.Element("MapSprite").Element("TextureName"))),
-                    FrameDimensions = new Point(
-                        int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                    FramesPerRow = (int)asset.Element("MapSprite").Element("FramesPerRow"),
-                    SourceOffset = new Vector2(
-                        int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                    // Handle Animations if needed
-                },
+                CombatSprite = AnimatingSprite.Load(asset.Element("CombatSprite"), contentManager),
+                MapSprite = AnimatingSprite.Load(asset.Element("MapSprite"), contentManager),
                 GearDrops = asset.Element("GearDrops")?.Elements("Item")
                     .Select(item => new GearDrop
                     {
@@ -151,17 +126,12 @@ namespace RolePlaying.Data
             return monster;
         }
 
-
-
-
-
-
         /// <summary>
         /// Reads a Monster object from the content pipeline.
         /// </summary>
         public class MonsterReader : ContentTypeReader<Monster>
         {
-            protected override Monster Read(ContentReader input, 
+            protected override Monster Read(ContentReader input,
                 Monster existingInstance)
             {
                 Monster monster = existingInstance;
@@ -178,7 +148,5 @@ namespace RolePlaying.Data
                 return monster;
             }
         }
-
-
     }
-}
+}

+ 8 - 46
RolePlayingGame/RolePlayingGameData/Characters/Player.cs

@@ -307,59 +307,21 @@ namespace RolePlaying.Data
         public static Player Load(string contentName, ContentManager contentManager)
         {
             var asset = XmlHelper.GetAssetElementFromXML(contentName);
-            
-			// Create a new Player instance and populate it with data from the XML asset
-			var player = new Player
+
+            // Create a new Player instance and populate it with data from the XML asset
+            var player = new Player
             {
                 AssetName = contentName,
                 Name = (string)asset.Element("Name"),
-                MapSprite = new AnimatingSprite
-                {
-                    TextureName = (string)asset.Element("MapSprite").Element("TextureName"),
-                    Texture = contentManager.Load<Texture2D>(
-                        Path.Combine(@"Textures\", (string)asset.Element("MapSprite").Element("TextureName"))),
-                    FrameDimensions = new Point(
-                        int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                    FramesPerRow = (int)asset.Element("MapSprite").Element("FramesPerRow"),
-                    SourceOffset = new Vector2(
-                        int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                    // Handle Animations if needed
-                },
-                WalkingSprite = new AnimatingSprite
-                {
-                    TextureName = (string)asset.Element("WalkingSprite").Element("TextureName"),
-                    Texture = contentManager.Load<Texture2D>(
-                        Path.Combine(@"Textures\", (string)asset.Element("WalkingSprite").Element("TextureName"))),
-                    FrameDimensions = new Point(
-                        int.Parse(asset.Element("WalkingSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("WalkingSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                    FramesPerRow = (int)asset.Element("WalkingSprite").Element("FramesPerRow"),
-                    SourceOffset = new Vector2(
-                        int.Parse(asset.Element("WalkingSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("WalkingSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                    // Handle Animations if needed
-                },
+                Direction = Enum.TryParse<Direction>((string)asset.Element("Direction"), out var dir) ? dir : default,
+                MapSprite = AnimatingSprite.Load(asset.Element("MapSprite"), contentManager),
+                WalkingSprite = AnimatingSprite.Load(asset.Element("WalkingSprite"), contentManager),
                 MapIdleAnimationInterval = (int)asset.Element("MapIdleAnimationInterval"),
                 CharacterClassContentName = (string)asset.Element("CharacterClassContentName"),
                 CharacterLevel = (int)asset.Element("CharacterLevel"),
                 InitialEquipmentContentNames = asset.Element("InitialEquipmentContentNames")
                     .Elements("Item").Select(x => (string)x).ToList(),
-                CombatSprite = new AnimatingSprite
-                {
-                    TextureName = (string)asset.Element("CombatSprite").Element("TextureName"),
-                    Texture = contentManager.Load<Texture2D>(
-                        Path.Combine(@"Textures\", (string)asset.Element("CombatSprite").Element("TextureName"))),
-                    FrameDimensions = new Point(
-                        int.Parse(asset.Element("CombatSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("CombatSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                    FramesPerRow = (int)asset.Element("CombatSprite").Element("FramesPerRow"),
-                    SourceOffset = new Vector2(
-                        int.Parse(asset.Element("CombatSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                        int.Parse(asset.Element("CombatSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                    // Handle Animations if needed
-                },
+                CombatSprite = AnimatingSprite.Load(asset.Element("CombatSprite"), contentManager),
                 Gold = (int)asset.Element("Gold"),
                 IntroductionDialogue = (string)asset.Element("IntroductionDialogue"),
                 JoinAcceptedDialogue = (string)asset.Element("JoinAcceptedDialogue"),
@@ -388,7 +350,7 @@ namespace RolePlaying.Data
             player.AddStandardCharacterCombatAnimations();
             player.AddStandardCharacterIdleAnimations();
             player.AddStandardCharacterWalkingAnimations();
-            
+
             player.ResetAnimation(false);
 
             // TODO Looks like player is floating. Offset issue.player.ShadowTexture = contentManager.Load<Texture2D>(@"Textures\Characters\CharacterShadow");

+ 3 - 15
RolePlayingGame/RolePlayingGameData/Characters/QuestNpc.cs

@@ -37,30 +37,18 @@ namespace RolePlaying.Data
         public static QuestNpc Load(string npcPath, ContentManager contentManager)
         {
             var asset = XmlHelper.GetAssetElementFromXML(npcPath);
-            
+
             var questNpc = new QuestNpc
             {
                 AssetName = npcPath,
                 Name = (string)asset.Element("Name"),
+                Direction = Enum.TryParse<Direction>((string)asset.Element("Direction"), out var dir) ? dir : default,
                 IntroductionDialogue = (string)asset.Element("IntroductionDialogue"),
                 MapIdleAnimationInterval = asset.Element("MapIdleAnimationInterval") != null
                     ? int.TryParse((string)asset.Element("MapIdleAnimationInterval"), out var interval) ? interval : default
                     : default,
                 MapSprite = asset.Element("MapSprite") != null
-                    ? new AnimatingSprite
-                        {
-                            TextureName = (string)asset.Element("MapSprite").Element("TextureName"),
-                            Texture = contentManager.Load<Texture2D>(
-                                Path.Combine(@"Textures\", (string)asset.Element("MapSprite").Element("TextureName"))),
-                            FrameDimensions = new Point(
-                                int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[0]),
-                                int.Parse(asset.Element("MapSprite").Element("FrameDimensions").Value.Split(' ')[1])),
-                            FramesPerRow = (int)asset.Element("MapSprite").Element("FramesPerRow"),
-                            SourceOffset = new Vector2(
-                                int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[0]),
-                                int.Parse(asset.Element("MapSprite").Element("SourceOffset").Value.Split(' ')[1])),
-                            // Handle Animations if needed
-                        }
+                    ? AnimatingSprite.Load(asset.Element("MapSprite"), contentManager)
                     : null,
             };
 

+ 0 - 15
RolePlayingGame/RolePlayingGameData/Gear/Item.cs

@@ -47,11 +47,6 @@ namespace RolePlaying.Data
             set { usage = value; }
         }
 
-
-
-
-
-
         /// <summary>
         /// Builds and returns a string describing the power of this item.
         /// </summary>
@@ -60,11 +55,6 @@ namespace RolePlaying.Data
             return TargetEffectRange.GetModifierString();
         }
 
-
-
-
-
-
         /// <summary>
         /// If true, the statistics change are used as a debuff (subtracted).
         /// Otherwise, the statistics change is used as a buff (added).
@@ -138,11 +128,6 @@ namespace RolePlaying.Data
             set { adjacentTargets = value; }
         }
 
-
-
-
-
-
         /// <summary>
         /// The name of the sound effect cue played when the item is used.
         /// </summary>

+ 9 - 1
RolePlayingGame/RolePlayingGameData/Map/Map.cs

@@ -810,12 +810,20 @@ namespace RolePlaying.Data
 						// Load the fixed combat asset XML using contentName
                         var fixedCombat = FixedCombat.Load(Path.Combine(@"Maps/FixedCombats", contentName), contentManager);
 
+                        AnimatingSprite animatingSprite = null;
+
+                        if (fixedCombat.Entries.Count > 0)
+                        {
+                            animatingSprite = fixedCombat.Entries[0].Content.MapSprite.Clone() as AnimatingSprite;
+                        }
+
 						return new MapEntry<FixedCombat>
                         {
                             ContentName = contentName,
                             Content = fixedCombat,
                             Direction = direction,
-                            MapPosition = mapPosition
+                            MapPosition = mapPosition,
+                            MapSprite = animatingSprite,
                         };
 					}).ToList(),
                 PlayerNpcEntries = asset.Element("PlayerNpcEntries")?.Elements("Item")

+ 2 - 9
RolePlayingGame/RolePlayingGameData/Map/Store.cs

@@ -133,15 +133,8 @@ namespace RolePlaying.Data
                     System.IO.Path.Combine(@"Textures\Characters\Portraits",
                     asset.Element("ShopkeeperTextureName").Value)),
                 StoreCategories = asset.Element("StoreCategories")
-                    .Elements("StoreCategory")
-                    .Select(storeCategory => new StoreCategory
-                    {
-                        Name = storeCategory.Element("Name").Value,
-                        AvailableContentNames = storeCategory.Element("AvailableContentNames")
-                            .Elements("ContentName")
-                            .Select(contentNameElement => contentNameElement.Value)
-                            .ToList(),
-                    }).ToList(),
+                    .Elements("Item")
+                    .Select(storeCategory => StoreCategory.Load(storeCategory, contentManager)).ToList(),
             };
 
             return store;

+ 47 - 5
RolePlayingGame/RolePlayingGameData/Map/StoreCategory.cs

@@ -5,9 +5,12 @@
 // Copyright (C) Microsoft Corporation. All rights reserved.
 //-----------------------------------------------------------------------------
 
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.Graphics;
 using System;
 using System.Collections.Generic;
-using Microsoft.Xna.Framework.Content;
+using System.Linq;
+using System.Xml.Linq;
 
 namespace RolePlaying.Data
 {
@@ -72,7 +75,7 @@ namespace RolePlaying.Data
             /// <summary>
             /// Reads a StoreCategory object from the content pipeline.
             /// </summary>
-            protected override StoreCategory Read(ContentReader input, 
+            protected override StoreCategory Read(ContentReader input,
                 StoreCategory existingInstance)
             {
                 StoreCategory storeCategory = existingInstance;
@@ -96,6 +99,45 @@ namespace RolePlaying.Data
             }
         }
 
-
-    }
-}
+		internal static StoreCategory Load(XElement storeCategoryElement, ContentManager contentManager)
+		{
+            var storeCategory = new StoreCategory
+            {
+                Name = storeCategoryElement.Element("Name").Value,
+                AvailableContentNames = storeCategoryElement.Element("AvailableContentNames")
+                            .Elements("Item")
+                            .Select(contentNameElement => contentNameElement.Value)
+                            .ToList(),
+			};
+
+			foreach (string gearName in storeCategory.AvailableContentNames)
+			{
+				var gearAsset = XmlHelper.GetAssetElementFromXML(System.IO.Path.Combine("Gear", gearName));
+				
+                var gear = new Item
+                {
+                    AssetName = gearName,
+                    Name = gearAsset.Element("Name").Value,
+                    Description = gearAsset.Element("Description").Value,
+					GoldValue = int.Parse(gearAsset.Element("GoldValue").Value),
+					IsDroppable = bool.Parse(gearAsset.Element("IsDroppable").Value),
+					IsOffensive = bool.Parse(gearAsset.Element("IsOffensive").Value),
+					MinimumCharacterLevel = int.Parse(gearAsset.Element("MinimumCharacterLevel").Value),
+					IconTextureName = gearAsset.Element("IconTextureName").Value,
+					IconTexture = contentManager.Load<Texture2D>(
+                        System.IO.Path.Combine("Textures", "Gear", gearAsset.Element("IconTextureName").Value)),
+					TargetDuration = int.Parse(gearAsset.Element("TargetDuration").Value),
+					AdjacentTargets = int.Parse(gearAsset.Element("AdjacentTargets").Value),
+					UsingCueName = gearAsset.Element("UsingCueName").Value,
+					ImpactCueName = gearAsset.Element("ImpactCueName").Value,
+					BlockCueName = gearAsset.Element("BlockCueName").Value,
+				};
+
+				// Load other properties of Gear as needed
+				storeCategory.AvailableGear.Add(gear);
+			}
+
+			return storeCategory;
+		}
+	}
+}