git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@2049 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
38
OpenRa.Game/Graphics/Sequence.cs
Normal file
38
OpenRa.Game/Graphics/Sequence.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Xml;
|
||||
using Ijw.DirectX;
|
||||
|
||||
namespace OpenRa.Game.Graphics
|
||||
{
|
||||
class Sequence
|
||||
{
|
||||
readonly int start, length;
|
||||
|
||||
public int Start { get { return start; } }
|
||||
public int End { get { return start + length; } }
|
||||
public int Length { get { return length; } }
|
||||
|
||||
public Sequence(string unit, XmlElement e)
|
||||
{
|
||||
string srcOverride = e.GetAttribute("src");
|
||||
|
||||
Range<int> src = UnitSheetBuilder.GetUnit(
|
||||
string.IsNullOrEmpty(srcOverride) ? unit : srcOverride);
|
||||
|
||||
start = src.Start + int.Parse(e.GetAttribute("start"));
|
||||
|
||||
if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*")
|
||||
length = src.End - start;
|
||||
else if (e.HasAttribute("length"))
|
||||
length = int.Parse(e.GetAttribute("length"));
|
||||
else if (e.HasAttribute("end"))
|
||||
length = int.Parse(e.GetAttribute("end")) - start;
|
||||
else
|
||||
length = 1;
|
||||
}
|
||||
|
||||
public Sprite GetSprite(int frame)
|
||||
{
|
||||
return UnitSheetBuilder.sprites[frame + start];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user