public static bool Initialize(DirectoryInfo directory, out string reason) { if (_initalized) { reason = null; return true; } Sprites = new Dictionary<string, BaseSprite>(); string file = Path.Combine(directory.FullName, "sprites.xml"); string graphicDirectory = Path.Combine(directory.FullName, "graphics"); if (!File.Exists(file)) { reason = "Sprites.xml file does not exist"; return false; } XDocument doc = XDocument.Load(file); XElement root = doc.Element("Sprites"); foreach (XElement sprite in root.Elements()) { var newSprite = new BaseSprite(); if (!newSprite.LoadSprite(sprite, graphicDirectory, out reason)) { return false; } Sprites.Add(newSprite.Name, newSprite); } _initalized = true; reason = null; return true; }
public BBSprite(BaseSprite baseSprite, Random r) { _baseSprite = baseSprite; _currentFrame = 0; _animated = _baseSprite.Frames.Count > 1; if (_animated) { _frameTimer = Utility.GetIntValue(_baseSprite.FrameLength[_currentFrame], r) / 1000.0f; } }