public MeterInfo LoadMeter(XElement meterNode, string basePath) { MeterInfo meter = new MeterInfo(); meter.Name = meterNode.TryAttribute<string>("name") ?? ""; meter.Position = new PointF(meterNode.GetAttribute<float>("x"), meterNode.GetAttribute<float>("y")); XAttribute imageAttr = meterNode.RequireAttribute("image"); meter.TickImage = FilePath.FromRelative(imageAttr.Value, basePath); XAttribute backAttr = meterNode.Attribute("background"); if (backAttr != null) { meter.Background = FilePath.FromRelative(backAttr.Value, basePath); } bool horiz = false; XAttribute dirAttr = meterNode.Attribute("orientation"); if (dirAttr != null) { horiz = (dirAttr.Value == "horizontal"); } meter.Orient = horiz ? MegaMan.Common.MeterInfo.Orientation.Horizontal : MegaMan.Common.MeterInfo.Orientation.Vertical; int x = meterNode.TryAttribute<int>("tickX"); int y = meterNode.TryAttribute<int>("tickY"); meter.TickOffset = new Point(x, y); XElement soundNode = meterNode.Element("Sound"); if (soundNode != null) meter.Sound = IncludeFileXmlReader.LoadSound(soundNode, basePath); XElement bindingNode = meterNode.Element("Binding"); if (bindingNode != null) meter.Binding = _bindingReader.Load(bindingNode); return meter; }
public static MeterInfo FromXml(XElement meterNode, string basePath) { MeterInfo meter = new MeterInfo(); meter.Position = new PointF(meterNode.GetFloat("x"), meterNode.GetFloat("y")); XAttribute imageAttr = meterNode.RequireAttribute("image"); meter.TickImage = FilePath.FromRelative(imageAttr.Value, basePath); XAttribute backAttr = meterNode.Attribute("background"); if (backAttr != null) { meter.Background = FilePath.FromRelative(backAttr.Value, basePath); } bool horiz = false; XAttribute dirAttr = meterNode.Attribute("orientation"); if (dirAttr != null) { horiz = (dirAttr.Value == "horizontal"); } meter.Orient = horiz? Orientation.Horizontal : Orientation.Vertical; int x = 0; int y = 0; meterNode.TryInteger("tickX", out x); meterNode.TryInteger("tickY", out y); meter.TickOffset = new Point(x, y); XElement soundNode = meterNode.Element("Sound"); if (soundNode != null) meter.Sound = SoundInfo.FromXml(soundNode, basePath); XElement bindingNode = meterNode.Element("Binding"); if (bindingNode != null) meter.Binding = SceneBindingInfo.FromXml(bindingNode); return meter; }
private void LoadInfo(MeterInfo info) { this.info = info; positionX = info.Position.X; positionY = info.Position.Y; if (info.Binding != null) { this.binding = Binding.Create(info.Binding, this); MaxValue = 1; // use 0 - 1 range for values } horizontal = (info.Orient == MeterInfo.Orientation.Horizontal); tickOffset = new MegaMan.Common.Geometry.Point(info.TickOffset.X, info.TickOffset.Y); if (info.Sound != null) sound = Engine.Instance.SoundSystem.EffectFromInfo(info.Sound); }
public static HealthMeter Create(MeterInfo info, bool inGamePlay) { var meter = new HealthMeter(); meter.LoadInfo(info); meter.inGamePlay = inGamePlay; if (inGamePlay) allMeters.Add(meter); return meter; }