win
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1288 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
38
OpenRa.Game/SequenceProvider.cs
Normal file
38
OpenRa.Game/SequenceProvider.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
static class SequenceProvider
|
||||
{
|
||||
static Dictionary<string, Dictionary<string, Sequence>> units =
|
||||
new Dictionary<string, Dictionary<string, Sequence>>();
|
||||
|
||||
static SequenceProvider()
|
||||
{
|
||||
XmlDocument document = new XmlDocument();
|
||||
document.Load("../../../sequences.xml");
|
||||
|
||||
foreach (XmlElement eUnit in document.SelectNodes("/sequences/unit"))
|
||||
LoadSequencesForUnit(eUnit);
|
||||
}
|
||||
|
||||
static void LoadSequencesForUnit(XmlElement eUnit)
|
||||
{
|
||||
string unitName = eUnit.GetAttribute("name");
|
||||
Dictionary<string, Sequence> sequences = new Dictionary<string, Sequence>();
|
||||
|
||||
foreach (XmlElement eSequence in eUnit.SelectNodes("./sequence"))
|
||||
sequences.Add(eSequence.GetAttribute("name"), new Sequence(unitName, eSequence));
|
||||
|
||||
units.Add(unitName, sequences);
|
||||
}
|
||||
|
||||
public static Sequence GetSequence(string unitName, string sequenceName)
|
||||
{
|
||||
return units[unitName][sequenceName];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user