Esempio n. 1
0
        public static LineShape Load(XmlReader reader)
        {
            LineShape line = new LineShape();

            line.Start = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("start"));
            line.End   = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("end"));
            return(line);
        }
Esempio n. 2
0
        public static Waypoint Load(XmlReader reader)
        {
            Waypoint shape = new Waypoint();

            LoadPositionalData(shape, reader);
            shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position"));
            return(shape);
        }
Esempio n. 3
0
        public static CircleShape Load(XmlReader reader)
        {
            CircleShape circle = new CircleShape();

            circle.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position"));
            circle.Radius   = reader.GetDoubleAttribute("radius");
            return(circle);
        }
Esempio n. 4
0
        public static PointObservation Load(XmlReader reader, Dictionary <Observation, string> observers)
        {
            PointObservation shape = new PointObservation();

            LoadPositionalData(shape, reader);
            shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position"));
            observers.Add(shape, reader.GetAttribute("observer"));
            return(shape);
        }
Esempio n. 5
0
        public static new UnitShape Load(XmlReader reader, Dictionary <Observation, string> observers, Dictionary <string, UnitShape> unitsById)
        {
            UnitShape shape = new UnitShape();

            shape.Name      = reader.GetAttribute("name");
            shape.Position  = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position"));
            shape.Direction = reader.GetDoubleAttribute("course");
            shape.Speed     = reader.GetDoubleAttribute("speed");
            shape.Type      = Utility.ParseEnum <UnitShapeType>(reader.GetStringAttribute("type", "unknown"), true);

            string id = reader.GetAttribute("id");

            if (!string.IsNullOrEmpty(id))
            {
                unitsById.Add(id, shape);
            }

            if (!reader.IsEmptyElement)
            {
                reader.Read();
                while (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.LocalName == "tmaSolution")
                    {
                        shape.TMASolution = TMASolution.Load(reader);
                    }
                    else if (reader.LocalName == "children" && !reader.IsEmptyElement)
                    {
                        reader.Read(); // move to either the first child or the end element
                        while (reader.NodeType == XmlNodeType.Element)
                        {
                            shape.Children.Add(Shape.Load(reader, observers, unitsById));
                        }
                        reader.ReadEndElement();
                    }
                    else
                    {
                        throw new InvalidDataException("Expected element " + reader.LocalName);
                    }
                }
            }

            return(shape);
        }