Ver código fonte

RPG: Only show quest after meeting Shed-darr. More xml processing to stop crash.

CartBlanche 1 mês atrás
pai
commit
0d05a5b4ca

+ 8 - 1
RolePlayingGame/Core/GameScreens/QuestNpcScreen.cs

@@ -28,7 +28,7 @@ namespace RolePlaying
             }
 
             // check to see if this is NPC is the current quest destination
-            if ((Session.Quest != null) && 
+            if ((Session.Quest != null) &&
                 (Session.Quest.Stage == Quest.QuestStage.RequirementsMet) &&
                 TileEngine.Map.AssetName.EndsWith(
                     Session.Quest.DestinationMapContentName) &&
@@ -44,6 +44,13 @@ namespace RolePlaying
             {
                 // this NPC is not the destination, so use the npc's welcome text
                 this.DialogueText = questNpc.IntroductionDialogue;
+
+                // Bit of a hack to only start the main quests after meeting Shed-darr the Wise
+                // This is to ensure that the player has met the NPC before starting the main quest line
+                if (questNpc.Name == "Shed-darr the Wise")
+                {
+                    Session.Singleton.StartMainQuestLine();
+                }
             }
         }
     }

+ 20 - 8
RolePlayingGame/Core/Session/Session.cs

@@ -24,6 +24,7 @@ namespace RolePlaying
         /// The single Session instance that can be active at a time.
         /// </summary>
         private static Session singleton;
+        internal static Session Singleton => singleton;
 
         /// <summary>
         /// The party that is playing the game right now.
@@ -38,6 +39,8 @@ namespace RolePlaying
             get { return (singleton == null ? null : singleton.party); }
         }
 
+        static GameStartDescription gameStartDesc;
+
         /// <summary>
         /// Change the current map, arriving at the given portal if any.
         /// </summary>
@@ -1485,6 +1488,8 @@ namespace RolePlaying
                 throw new ArgumentNullException("gameplayScreen");
             }
 
+            gameStartDesc = gameStartDescription;
+
             // end any existing session
             EndSession();
 
@@ -1497,14 +1502,6 @@ namespace RolePlaying
             // set up the initial party
             ContentManager contentManager = singleton.screenManager.Game.Content;
             singleton.party = new Party(gameStartDescription, contentManager);
-
-            /* var loadedQuestLine = content.Load<QuestLine>(
-                Path.Combine("Quests", "QuestLines", gameStartDescription.QuestLineContentName)).Clone() as QuestLine;*/
-
-            var questLine = QuestLine.Load(Path.Combine("Quests", "QuestLines", gameStartDescription.QuestLineContentName), contentManager);
-
-            // load the quest line
-            singleton.questLine = questLine;
         }
 
         /// <summary>
@@ -1693,6 +1690,21 @@ namespace RolePlaying
             */
         }
 
+        internal void StartMainQuestLine()
+        {
+            // load the quest line
+            /* var loadedQuestLine = content.Load<QuestLine>(
+                Path.Combine("Quests", "QuestLines", gameStartDescription.QuestLineContentName)).Clone() as QuestLine;*/
+
+            var questLine = QuestLine.Load(Path.Combine("Quests", "QuestLines", gameStartDesc.QuestLineContentName), singleton.screenManager.Game.Content);
+
+            if (singleton.questLine != questLine)
+            {
+                // set the quest line
+                singleton.questLine = questLine;
+            }
+        }
+
         /// <summary>
         /// Save the current state of the session, with the given storage device.
         /// </summary>

+ 13 - 1
RolePlayingGame/RolePlayingGameData/Quests/Quest.cs

@@ -500,6 +500,8 @@ namespace RolePlaying.Data
                         var mapPosition = new Point(
                             int.Parse(chestRequirement.Element("MapPosition").Value.Split(' ')[0]),
                             int.Parse(chestRequirement.Element("MapPosition").Value.Split(' ')[1]));
+                        var mapContentName = (string)chestRequirement.Element("MapContentName");
+                        var count = (int?)chestRequirement.Element("Count") ?? 1;
 
                         // Load the QuestNpc asset XML using contentName
                         var chestAsset = XmlHelper.GetAssetElementFromXML(Path.Combine("Maps", "Chests", contentName));
@@ -509,12 +511,22 @@ namespace RolePlaying.Data
                         {
                             ContentName = contentName,
                             Content = chest,
+                            Count = count,
                             Direction = direction,
-                            MapPosition = mapPosition
+                            MapContentName = mapContentName,
+                            MapPosition = mapPosition,
+                            MapSprite = null,
                         };
                     }).ToList() ?? new List<WorldEntry<Chest>>(),
             };
 
+            // Load the gear rewards
+            foreach (var gearContentName in quest.GearRewardContentNames)
+            {
+                var gear = Equipment.Load(Path.Combine("Gear", gearContentName), contentManager);
+                quest.GearRewards.Add(gear);
+            }
+
             return quest;
         }
     }