Ejemplo n.º 1
0
        private static SignpostBase CreateSignpostFromXmlNode(XElement node)
        {
            SignpostBase newSignpost = null;

            switch (node.Name.ToString())
            {
            case OneWaySignpost.Save_Node_Name:
                newSignpost = Factory.CreateOneWaySignpost(node.Attribute("texture").Value);
                ((OneWaySignpost)newSignpost).Mirror = (bool)node.Attribute("mirror");
                break;

            case SpeedLimitSignpost.Save_Node_Name:
                newSignpost = Factory.CreateSpeedLimitSignpost(node.Attribute("texture").Value);
                ((SpeedLimitSignpost)newSignpost).SpeedLimits = new Range((int)node.Attribute("minimum-speed"), (int)node.Attribute("maximum-speed"));
                break;
            }

            if (newSignpost != null)
            {
                newSignpost.GroupNodeName          = Data_Group_Node_Name;
                newSignpost.CollisionZoneTopOffset = (float)node.Attribute("zone-top");
            }

            return(newSignpost);
        }
Ejemplo n.º 2
0
 public static void LoadSignposts(XElement SignpostDataGroup, Data.RegistrationCallback registerComponent)
 {
     if (SignpostDataGroup != null)
     {
         foreach (XElement node in SignpostDataGroup.Elements())
         {
             if (node.Name == RouteMarker.Save_Node_Name)
             {
                 RouteMarker toAdd = CreateRouteMarkerFromXmlNode(node);
                 toAdd.WorldPosition = new Vector2((float)node.Attribute("x"), (float)node.Attribute("y"));
                 registerComponent(toAdd);
             }
             else
             {
                 SignpostBase toAdd = CreateSignpostFromXmlNode(node);
                 toAdd.WorldPosition = new Vector2((float)node.Attribute("x"), (float)node.Attribute("y"));
                 registerComponent(toAdd);
             }
         }
     }
 }