#region File Description
//-----------------------------------------------------------------------------
// GameScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
using System.Xml.Linq;
#endregion
namespace HoneycombRush
{
///
/// Repesent the difficulty mode of the game.
///
public enum DifficultyMode
{
Easy = 1,
Medium = 2,
Hard = 3
}
///
/// Supplies access to configuration data.
///
public static class ConfigurationManager
{
#region Fields
static Dictionary modesConfiguration;
public static Dictionary ModesConfiguration
{
get
{
return modesConfiguration;
}
}
static bool isLoaded = false;
public static bool IsLoaded
{
get
{
return isLoaded;
}
}
public static DifficultyMode? DifficultyMode { get; set; }
#endregion
#region Public Static Methods
///
/// Load configuration from an XML document.
///
/// The XML document containing configuration.
public static void LoadConfiguration(XDocument doc)
{
modesConfiguration = new Dictionary();
foreach (XElement element in doc.Element("Difficulties").Elements("Difficulty"))
{
modesConfiguration.Add((DifficultyMode)Enum.Parse(typeof(DifficultyMode),
element.Attribute("ID").Value, true),
new Configuration()
{
DecreaseAmountSpeed = int.Parse(element.Element("DecreaseAmountSpeed").Value),
GameElapsed = TimeSpan.Parse(element.Element("GameElapsed").Value),
IncreaseAmountSpeed = int.Parse(element.Element("IncreaseAmountSpeed").Value),
MaxSoldierBeeVelocity = int.Parse(element.Element("MaxSoldierBeeVelocity").Value),
MaxWorkerBeeVelocity = int.Parse(element.Element("MaxWorkerBeeVelocity").Value),
MinSoldierBeeVelocity = int.Parse(element.Element("MinSoldierBeeVelocity").Value),
MinWorkerBeeVelocity = int.Parse(element.Element("MinWorkerBeeVelocity").Value),
TotalSmokeAmount = int.Parse(element.Element("TotalSmokeAmount").Value),
HighScoreFactor = int.Parse(element.Element("HighScoreFactor").Value)
});
}
isLoaded = true;
}
#endregion
}
///
/// Contains all configuration memebers.
///
public struct Configuration
{
public TimeSpan GameElapsed { get; set; }
public float MinWorkerBeeVelocity { get; set; }
public float MaxWorkerBeeVelocity { get; set; }
public float MinSoldierBeeVelocity { get; set; }
public float MaxSoldierBeeVelocity { get; set; }
public int TotalSmokeAmount { get; set; }
public int DecreaseAmountSpeed { get; set; }
public int IncreaseAmountSpeed { get; set; }
public int HighScoreFactor { get; set; }
}
}