//-----------------------------------------------------------------------------
// GameStartDescription.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace RolePlaying.Data
{
///
/// The data needed to start a new game.
///
public class GameStartDescription
{
///
/// The content name of the map for a new game.
///
private string mapContentName;
///
/// The content name of the map for a new game.
///
public string MapContentName
{
get { return mapContentName; }
set { mapContentName = value; }
}
///
/// The content names of the players in the party from the beginning.
///
private List playerContentNames = new List();
///
/// The content names of the players in the party from the beginning.
///
public List PlayerContentNames
{
get { return playerContentNames; }
set { playerContentNames = value; }
}
///
/// The quest line in action when the game starts.
///
/// The first quest will be started before the world is shown.
private string questLineContentName;
///
/// The quest line in action when the game starts.
///
/// The first quest will be started before the world is shown.
[ContentSerializer(Optional = true)]
public string QuestLineContentName
{
get { return questLineContentName; }
set { questLineContentName = value; }
}
public static GameStartDescription Load(string description)
{
XElement asset = XmlHelper.GetAssetElementFromXML(description);
var gameStartDescription = new GameStartDescription
{
MapContentName = (string)asset.Element("MapContentName"),
PlayerContentNames = asset.Element("PlayerContentNames")
.Elements("Item")
.Select(x => (string)x)
.ToList(),
QuestLineContentName = (string)asset.Element("QuestLineContentName"),
};
return gameStartDescription;
}
}
}